fix: capture thinking blocks in ChatNonStreaming fallback path
This commit is contained in:
1 parent
152d8b972e
commit
0300af6717
1 file changed
+12
-2
@@ -335,8 +335,8 @@ func (p *AnthropicProvider) ChatStream(ctx context.Context, req llm.ChatRequest)
|
|||||||
// mid-flight; the partial output of the failed stream is discarded so
|
// mid-flight; the partial output of the failed stream is discarded so
|
||||||
// the prompt cache prefix on the next turn stays byte-identical.
|
// the prompt cache prefix on the next turn stays byte-identical.
|
||||||
//
|
//
|
||||||
// Note: thinking blocks (when reasoning is enabled) are NOT surfaced —
|
// Thinking blocks are surfaced as EventThinkingBlock events so the runtime
|
||||||
// matches the streaming path which also doesn't emit thinking deltas.
|
// can store and echo them back in subsequent turns.
|
||||||
// Tool-use input is converted to JSON via the SDK's RawJSON field.
|
// Tool-use input is converted to JSON via the SDK's RawJSON field.
|
||||||
func (p *AnthropicProvider) ChatNonStreaming(ctx context.Context, req llm.ChatRequest) (<-chan llm.ChatEvent, error) {
|
func (p *AnthropicProvider) ChatNonStreaming(ctx context.Context, req llm.ChatRequest) (<-chan llm.ChatEvent, error) {
|
||||||
params := p.buildMessageParams(req)
|
params := p.buildMessageParams(req)
|
||||||
@@ -350,6 +350,16 @@ func (p *AnthropicProvider) ChatNonStreaming(ctx context.Context, req llm.ChatRe
|
|||||||
defer close(events)
|
defer close(events)
|
||||||
for _, block := range msg.Content {
|
for _, block := range msg.Content {
|
||||||
switch block.Type {
|
switch block.Type {
|
||||||
|
case "thinking":
|
||||||
|
if block.Thinking != "" || block.Signature != "" {
|
||||||
|
events <- llm.ChatEvent{
|
||||||
|
Type: llm.EventThinkingBlock,
|
||||||
|
ThinkingBlock: &llm.ThinkingBlock{
|
||||||
|
Thinking: block.Thinking,
|
||||||
|
Signature: block.Signature,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
case "text":
|
case "text":
|
||||||
if block.Text != "" {
|
if block.Text != "" {
|
||||||
events <- llm.ChatEvent{Type: llm.EventTextDelta, Text: block.Text}
|
events <- llm.ChatEvent{Type: llm.EventTextDelta, Text: block.Text}
|
||||||
|
|||||||
Reference in new issue
Block a user