From bbacf8cccbc2467e550c9ea604d54f7b69e1fcbb Mon Sep 17 00:00:00 2001 From: semioz <90466553+semioz@users.noreply.github.com> Date: Sat, 1 Feb 2025 13:15:07 +0300 Subject: [PATCH] fix test, comments --- llms/chat_messages.go | 3 +-- llms/generatecontent.go | 5 +---- llms/openai/internal/openaiclient/chat.go | 24 ++++++----------------- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/llms/chat_messages.go b/llms/chat_messages.go index 37d1307ad..6c7819372 100644 --- a/llms/chat_messages.go +++ b/llms/chat_messages.go @@ -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"` } diff --git a/llms/generatecontent.go b/llms/generatecontent.go index 73da64144..d81160463 100644 --- a/llms/generatecontent.go +++ b/llms/generatecontent.go @@ -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 } diff --git a/llms/openai/internal/openaiclient/chat.go b/llms/openai/internal/openaiclient/chat.go index 6488c0f9f..74ca0d844 100644 --- a/llms/openai/internal/openaiclient/chat.go +++ b/llms/openai/internal/openaiclient/chat.go @@ -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"` } @@ -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) @@ -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) @@ -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) @@ -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"` @@ -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)