{Content:" </think> Based on my analysis,",Done:false,PromptEvalCount:1,PromptEvalDuration:1},
{Content:" the solution is straightforward.",Done:true,DoneReason:llm.DoneReasonStop,PromptEvalCount:1,PromptEvalDuration:1,EvalCount:1,EvalDuration:1},
}
for_,resp:=rangeresponses{
select{
case<-ctx.Done():
returnctx.Err()
default:
fn(resp)
time.Sleep(10*time.Millisecond)
}
}
returnnil
}
think:=true
w:=createRequest(t,s.ChatHandler,api.ChatRequest{
Model:"test-thinking",
Messages:[]api.Message{{Role:"user",Content:"Analyze this complex problem"}},
Think:&api.ThinkValue{Value:think},
Stream:&stream,
})
wg.Wait()
ifw.Code!=http.StatusOK{
t.Fatalf("expected status 200, got %d",w.Code)
}
// Parse streaming responses
decoder:=json.NewDecoder(w.Body)
varallThinking,allContentstrings.Builder
for{
varrespapi.ChatResponse
iferr:=decoder.Decode(&resp);err==io.EOF{
break
}elseiferr!=nil{
t.Fatal(err)
}
allThinking.WriteString(resp.Message.Thinking)
allContent.WriteString(resp.Message.Content)
}
// Note: Leading whitespace after <think> is eaten by the parser
ifgot:=allThinking.String();got!="I need to consider multiple factors here... "{
t.Errorf("expected thinking %q, got %q","I need to consider multiple factors here... ",got)
}
ifgot:=allContent.String();got!="Based on my analysis, the solution is straightforward."{
t.Errorf("expected content %q, got %q","Based on my analysis, the solution is straightforward.",got)