From 104b5d3aac67b1e60d84b274a4e87ac94d2862c9 Mon Sep 17 00:00:00 2001 From: Zhang Minghan Date: Sun, 18 Feb 2024 21:08:44 +0800 Subject: [PATCH] fix: remove role in relay stream response --- manager/chat_completions.go | 3 +-- manager/types.go | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/manager/chat_completions.go b/manager/chat_completions.go index a87ab0a..c9b1907 100644 --- a/manager/chat_completions.go +++ b/manager/chat_completions.go @@ -165,8 +165,7 @@ func getStreamTranshipmentForm(id string, created int64, form RelayForm, data *g Choices: []ChoiceDelta{ { Index: 0, - Delta: globals.Message{ - Role: globals.Assistant, + Delta: Message{ Content: data.Content, ToolCalls: data.ToolCall, FunctionCall: data.FunctionCall, diff --git a/manager/types.go b/manager/types.go index 4f1149c..09aa27a 100644 --- a/manager/types.go +++ b/manager/types.go @@ -50,6 +50,15 @@ type Choice struct { FinishReason string `json:"finish_reason"` } +type StreamMessage struct { + Role *string `json:"role"` + Content string `json:"content"` + Name *string `json:"name,omitempty"` + FunctionCall *globals.FunctionCall `json:"function_call,omitempty"` // only `function` role + ToolCallId *string `json:"tool_call_id,omitempty"` // only `tool` role + ToolCalls *globals.ToolCalls `json:"tool_calls,omitempty"` // only `assistant` role +} + type Usage struct { PromptTokens int `json:"prompt_tokens"` CompletionTokens int `json:"completion_tokens"` @@ -67,9 +76,9 @@ type RelayResponse struct { } type ChoiceDelta struct { - Index int `json:"index"` - Delta globals.Message `json:"delta"` - FinishReason interface{} `json:"finish_reason"` + Index int `json:"index"` + Delta Message `json:"delta"` + FinishReason interface{} `json:"finish_reason"` } type RelayStreamResponse struct {