Change summary
internal/llm/provider/openai.go | 13 ++++++++++++-
internal/tui/components/chat/messages/messages.go | 3 +++
2 files changed, 15 insertions(+), 1 deletion(-)
Detailed changes
@@ -2,6 +2,7 @@ package provider
import (
"context"
+ "encoding/json"
"errors"
"fmt"
"io"
@@ -348,8 +349,18 @@ func (o *openaiClient) stream(ctx context.Context, messages []message.Message, t
chunk.Choices[0].Delta.ToolCalls[0].Index = 0
}
acc.AddChunk(chunk)
- // This fixes multiple tool calls for some providers
for i, choice := range chunk.Choices {
+ reasoning, ok := choice.Delta.JSON.ExtraFields["reasoning"]
+ if ok && reasoning.Raw() != "" {
+ reasoningStr := ""
+ json.Unmarshal([]byte(reasoning.Raw()), &reasoningStr)
+ if reasoningStr != "" {
+ eventChan <- ProviderEvent{
+ Type: EventThinkingDelta,
+ Thinking: reasoningStr,
+ }
+ }
+ }
if choice.Delta.Content != "" {
eventChan <- ProviderEvent{
Type: EventContentDelta,
@@ -274,6 +274,9 @@ func (m *messageCmp) renderThinkingContent() string {
if reasoningContent.StartedAt > 0 {
duration := m.message.ThinkingDuration()
if reasoningContent.FinishedAt > 0 {
+ if duration.String() == "0s" {
+ return ""
+ }
m.anim.SetLabel("")
opts := core.StatusOpts{
Title: "Thought for",