Skip to content

Commit

Permalink
fix test, comments
Browse files Browse the repository at this point in the history
  • Loading branch information
semioz committed Feb 1, 2025
1 parent 1bea9fb commit bbacf8c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 24 deletions.
3 changes: 1 addition & 2 deletions llms/chat_messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ type AIChatMessage struct {
// ToolCalls represents the model choosing to call tools.
ToolCalls []ToolCall `json:"tool_calls,omitempty"`

// This field only used for 'deepseek-reasoner' model.
// The reasoning contents of the assistant message, before the final answer.
// This field is only used with the deepseek-reasoner model and represents the reasoning contents of the assistant message before the final answer.
ReasoningContent string `json:"reasoning_content,omitempty"`
}

Expand Down
5 changes: 1 addition & 4 deletions llms/generatecontent.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,7 @@ type ContentChoice struct {
// ToolCalls is a list of tool calls the model asks to invoke.
ToolCalls []ToolCall

// ReasoningContent contains the step-by-step reasoning process used by the model.
// This field is only used with the deepseek-reasoner model and represents
// the reasoning contents of the assistant message before the final answer.
// The field is nullable.
// This field is only used with the deepseek-reasoner model and represents the reasoning contents of the assistant message before the final answer.
ReasoningContent string
}

Expand Down
24 changes: 6 additions & 18 deletions llms/openai/internal/openaiclient/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,7 @@ type ChatMessage struct { //nolint:musttag
// Only present in tool messages.
ToolCallID string `json:"tool_call_id,omitempty"`

// ReasoningContent contains the step-by-step reasoning process used by the model.
// This field is only used with the deepseek-reasoner model and represents
// the reasoning contents of the assistant message before the final answer.
// The field is nullable.
// This field is only used with the deepseek-reasoner model and represents the reasoning contents of the assistant message before the final answer.
ReasoningContent string `json:"reasoning_content,omitempty"`
}

Expand All @@ -188,10 +185,7 @@ func (m ChatMessage) MarshalJSON() ([]byte, error) {
// Only present in tool messages.
ToolCallID string `json:"tool_call_id,omitempty"`

// ReasoningContent contains the step-by-step reasoning process used by the model.
// This field is only used with the deepseek-reasoner model and represents
// the reasoning contents of the assistant message before the final answer.
// The field is nullable.
// This field is only used with the deepseek-reasoner model and represents the reasoning contents of the assistant message before the final answer.
ReasoningContent string `json:"reasoning_content,omitempty"`
}(m)
return json.Marshal(msg)
Expand All @@ -209,10 +203,7 @@ func (m ChatMessage) MarshalJSON() ([]byte, error) {
// Only present in tool messages.
ToolCallID string `json:"tool_call_id,omitempty"`

// ReasoningContent contains the step-by-step reasoning process used by the model.
// This field is only used with the deepseek-reasoner model and represents
// the reasoning contents of the assistant message before the final answer.
// The field is nullable.
// This field is only used with the deepseek-reasoner model and represents the reasoning contents of the assistant message before the final answer.
ReasoningContent string `json:"reasoning_content,omitempty"`
}(m)
return json.Marshal(msg)
Expand Down Expand Up @@ -240,10 +231,7 @@ func (m *ChatMessage) UnmarshalJSON(data []byte) error {
// Only present in tool messages.
ToolCallID string `json:"tool_call_id,omitempty"`

// ReasoningContent contains the step-by-step reasoning process used by the model.
// This field is only used with the deepseek-reasoner model and represents
// the reasoning contents of the assistant message before the final answer.
// The field is nullable.
// This field is only used with the deepseek-reasoner model and represents the reasoning contents of the assistant message before the final answer.
ReasoningContent string `json:"reasoning_content,omitempty"`
}{}
err := json.Unmarshal(data, &msg)
Expand Down Expand Up @@ -346,8 +334,7 @@ type StreamedChatResponsePayload struct {
FunctionCall *FunctionCall `json:"function_call,omitempty"`
// ToolCalls is a list of tools that were called in the message.
ToolCalls []*ToolCall `json:"tool_calls,omitempty"`
// This field only used for 'deepseek-reasoner' model.
// The reasoning contents of the assistant message, before the final answer.
// This field is only used with the deepseek-reasoner model and represents the reasoning contents of the assistant message before the final answer.
ReasoningContent string `json:"reasoning_content,omitempty"`
} `json:"delta,omitempty"`
FinishReason FinishReason `json:"finish_reason,omitempty"`
Expand Down Expand Up @@ -508,6 +495,7 @@ func combineStreamingChatResponse(
chunk := []byte(choice.Delta.Content)
response.Choices[0].Message.Content += choice.Delta.Content
response.Choices[0].FinishReason = choice.FinishReason
response.Choices[0].Message.ReasoningContent = choice.Delta.ReasoningContent

if choice.Delta.FunctionCall != nil {
chunk = updateFunctionCall(response.Choices[0].Message, choice.Delta.FunctionCall)
Expand Down

0 comments on commit bbacf8c

Please sign in to comment.