fix: remove role in relay stream response

This commit is contained in:
Zhang Minghan 2024-02-18 21:08:44 +08:00
parent e14fb02fb9
commit 104b5d3aac
2 changed files with 13 additions and 5 deletions

View File

@ -165,8 +165,7 @@ func getStreamTranshipmentForm(id string, created int64, form RelayForm, data *g
Choices: []ChoiceDelta{ Choices: []ChoiceDelta{
{ {
Index: 0, Index: 0,
Delta: globals.Message{ Delta: Message{
Role: globals.Assistant,
Content: data.Content, Content: data.Content,
ToolCalls: data.ToolCall, ToolCalls: data.ToolCall,
FunctionCall: data.FunctionCall, FunctionCall: data.FunctionCall,

View File

@ -50,6 +50,15 @@ type Choice struct {
FinishReason string `json:"finish_reason"` 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 { type Usage struct {
PromptTokens int `json:"prompt_tokens"` PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"` CompletionTokens int `json:"completion_tokens"`
@ -68,7 +77,7 @@ type RelayResponse struct {
type ChoiceDelta struct { type ChoiceDelta struct {
Index int `json:"index"` Index int `json:"index"`
Delta globals.Message `json:"delta"` Delta Message `json:"delta"`
FinishReason interface{} `json:"finish_reason"` FinishReason interface{} `json:"finish_reason"`
} }