mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-09-17 16:56:38 +08:00
Merge branch 'main' of github.com:yangjian102621/chatgpt-plus
This commit is contained in:
commit
ecadfeab19
@ -65,6 +65,7 @@ func (h *ChatHandler) sendOpenAiMessage(
|
|||||||
var toolCall = false
|
var toolCall = false
|
||||||
var arguments = make([]string, 0)
|
var arguments = make([]string, 0)
|
||||||
scanner := bufio.NewScanner(response.Body)
|
scanner := bufio.NewScanner(response.Body)
|
||||||
|
var isNew = true
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
line := scanner.Text()
|
line := scanner.Text()
|
||||||
if !strings.Contains(line, "data:") || len(line) < 30 {
|
if !strings.Contains(line, "data:") || len(line) < 30 {
|
||||||
@ -117,13 +118,16 @@ func (h *ChatHandler) sendOpenAiMessage(
|
|||||||
// 初始化 role
|
// 初始化 role
|
||||||
if responseBody.Choices[0].Delta.Role != "" && message.Role == "" {
|
if responseBody.Choices[0].Delta.Role != "" && message.Role == "" {
|
||||||
message.Role = responseBody.Choices[0].Delta.Role
|
message.Role = responseBody.Choices[0].Delta.Role
|
||||||
utils.ReplyChunkMessage(ws, types.WsMessage{Type: types.WsStart})
|
|
||||||
continue
|
continue
|
||||||
} else if responseBody.Choices[0].FinishReason != "" {
|
} else if responseBody.Choices[0].FinishReason != "" {
|
||||||
break // 输出完成或者输出中断了
|
break // 输出完成或者输出中断了
|
||||||
} else {
|
} else {
|
||||||
content := responseBody.Choices[0].Delta.Content
|
content := responseBody.Choices[0].Delta.Content
|
||||||
contents = append(contents, utils.InterfaceToString(content))
|
contents = append(contents, utils.InterfaceToString(content))
|
||||||
|
if isNew {
|
||||||
|
utils.ReplyChunkMessage(ws, types.WsMessage{Type: types.WsStart})
|
||||||
|
isNew = false
|
||||||
|
}
|
||||||
utils.ReplyChunkMessage(ws, types.WsMessage{
|
utils.ReplyChunkMessage(ws, types.WsMessage{
|
||||||
Type: types.WsMiddle,
|
Type: types.WsMiddle,
|
||||||
Content: utils.InterfaceToString(responseBody.Choices[0].Delta.Content),
|
Content: utils.InterfaceToString(responseBody.Choices[0].Delta.Content),
|
||||||
|
@ -53,7 +53,7 @@ services:
|
|||||||
|
|
||||||
# 后端 API 程序
|
# 后端 API 程序
|
||||||
chatgpt-plus-api:
|
chatgpt-plus-api:
|
||||||
image: registry.cn-shenzhen.aliyuncs.com/geekmaster/chatgpt-plus-api:v4.0.2-amd64
|
image: registry.cn-shenzhen.aliyuncs.com/geekmaster/chatgpt-plus-api:v4.0.3-amd64
|
||||||
container_name: chatgpt-plus-api
|
container_name: chatgpt-plus-api
|
||||||
restart: always
|
restart: always
|
||||||
depends_on:
|
depends_on:
|
||||||
@ -76,7 +76,7 @@ services:
|
|||||||
|
|
||||||
# 前端应用
|
# 前端应用
|
||||||
chatgpt-plus-web:
|
chatgpt-plus-web:
|
||||||
image: registry.cn-shenzhen.aliyuncs.com/geekmaster/chatgpt-plus-web:v4.0.2-amd64
|
image: registry.cn-shenzhen.aliyuncs.com/geekmaster/chatgpt-plus-web:v4.0.3-amd64
|
||||||
container_name: chatgpt-plus-web
|
container_name: chatgpt-plus-web
|
||||||
restart: always
|
restart: always
|
||||||
depends_on:
|
depends_on:
|
||||||
|
Loading…
Reference in New Issue
Block a user