coo7 commited on
Commit
3ebc2f7
·
verified ·
1 Parent(s): d37fab8

Update internal/monica/sse.go

Browse files
Files changed (1) hide show
  1. internal/monica/sse.go +17 -45
internal/monica/sse.go CHANGED
@@ -26,14 +26,8 @@ const (
26
 
27
  // SSEData 用于解析 Monica SSE json
28
  type SSEData struct {
29
- Text string `json:"text"`
30
- Finished bool `json:"finished"`
31
- AgentStatus struct {
32
- Type string `json:"type"`
33
- Metadata struct {
34
- ReasoningDetail string `json:"reasoning_detail"`
35
- } `json:"metadata"`
36
- } `json:"agent_status"`
37
  }
38
 
39
  var sseDataPool = sync.Pool{
@@ -122,44 +116,22 @@ func StreamMonicaSSEToClient(model string, w io.Writer, r io.Reader) error {
122
  },
123
  }
124
  } else {
125
- // 检查是否是思考内容
126
- if sseObj.AgentStatus.Type == "thinking_detail_stream" {
127
- sseMsg = types.ChatCompletionStreamResponse{
128
- ID: "chatcmpl-" + chatId,
129
- Object: sseObject,
130
- SystemFingerprint: fingerprint,
131
- Created: now,
132
- Model: model,
133
- ReasoningContent: sseObj.AgentStatus.Metadata.ReasoningDetail,
134
- Choices: []types.ChatCompletionStreamChoice{
135
- {
136
- Index: 0,
137
- Delta: openai.ChatCompletionStreamChoiceDelta{
138
- Role: openai.ChatMessageRoleAssistant,
139
- Content: "",
140
- },
141
- FinishReason: openai.FinishReasonNull,
142
- },
143
- },
144
- }
145
- } else {
146
- sseMsg = types.ChatCompletionStreamResponse{
147
- ID: "chatcmpl-" + chatId,
148
- Object: sseObject,
149
- SystemFingerprint: fingerprint,
150
- Created: now,
151
- Model: model,
152
- Choices: []types.ChatCompletionStreamChoice{
153
- {
154
- Index: 0,
155
- Delta: openai.ChatCompletionStreamChoiceDelta{
156
- Role: openai.ChatMessageRoleAssistant,
157
- Content: sseObj.Text,
158
- },
159
- FinishReason: openai.FinishReasonNull,
160
  },
 
161
  },
162
- }
163
  }
164
  }
165
 
@@ -189,4 +161,4 @@ func StreamMonicaSSEToClient(model string, w io.Writer, r io.Reader) error {
189
  // 将对象放回对象池
190
  sseDataPool.Put(sseObj)
191
  }
192
- }
 
26
 
27
  // SSEData 用于解析 Monica SSE json
28
  type SSEData struct {
29
+ Text string `json:"text"`
30
+ Finished bool `json:"finished"`
 
 
 
 
 
 
31
  }
32
 
33
  var sseDataPool = sync.Pool{
 
116
  },
117
  }
118
  } else {
119
+ sseMsg = types.ChatCompletionStreamResponse{
120
+ ID: "chatcmpl-" + chatId,
121
+ Object: sseObject,
122
+ SystemFingerprint: fingerprint,
123
+ Created: now,
124
+ Model: model,
125
+ Choices: []types.ChatCompletionStreamChoice{
126
+ {
127
+ Index: 0,
128
+ Delta: openai.ChatCompletionStreamChoiceDelta{
129
+ Role: openai.ChatMessageRoleAssistant,
130
+ Content: sseObj.Text,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  },
132
+ FinishReason: openai.FinishReasonNull,
133
  },
134
+ },
135
  }
136
  }
137
 
 
161
  // 将对象放回对象池
162
  sseDataPool.Put(sseObj)
163
  }
164
+ }