| 1 | package openai |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "reasonix/internal/provider" |
| 6 | ) |
| 7 | |
| 8 | func (c *client) ReasoningReplayCapabilities() provider.ReasoningReplayCapabilities { |
| 9 | fallback := "" |
| 10 | if c.AllowsEmptyReasoningFallback() { |
| 11 | fallback = "empty-field" |
| 12 | } |
| 13 | return provider.ReasoningReplayCapabilities{Format: "chat-completions", EmptyFallback: fallback} |
| 14 | } |
| 15 | |
| 16 | func emitChatReasoning(ctx context.Context, out chan<- provider.Chunk, content *string, fallback string) (bool, error) { |
| 17 | text := fallback |
| 18 | if content != nil && *content != "" { |
| 19 | text = *content |
| 20 | } |
| 21 | if content == nil && text == "" { |
| 22 | return false, nil |
| 23 | } |
| 24 | chunk := provider.Chunk{Type: provider.ChunkReasoning, Text: text} |
| 25 | if text == "" { |
| 26 | chunk.ReasoningState = provider.ReasoningEmpty |
| 27 | } |
| 28 | if !sendChunk(ctx, out, chunk) { |
| 29 | return text != "", ctx.Err() |
| 30 | } |
| 31 | return text != "", nil |
| 32 | } |
| 33 |