基于最新的gpt-3.5-turbo-0301模型

This commit is contained in:
cookeem
2023-03-04 07:28:34 +08:00
parent b461c75222
commit 1d4ffa603d
4 changed files with 8 additions and 27 deletions

View File

@@ -2,11 +2,11 @@ FROM alpine:3.15.3
LABEL maintainer="cookeem"
LABEL email="cookeem@qq.com"
LABEL version="v1.0.0"
LABEL version="v1.0.1"
RUN adduser -h /chatgpt-service -u 1000 -D dory
COPY chatgpt-service /chatgpt-service/
WORKDIR /chatgpt-service
USER dory
# docker build -t doryengine/chatgpt-service:v1.0.0-alpine .
# docker build -t doryengine/chatgpt-service:v1.0.1-alpine .

View File

@@ -1,4 +1,4 @@
# 实时ChatGPT服务
# 实时ChatGPT服务基于最新的gpt-3.5-turbo-0301模型
## chatGPT-service和chatGPT-stream

View File

@@ -2,9 +2,7 @@ package chat
import (
"context"
"errors"
"fmt"
"io"
"net/http"
"strings"
"sync"
@@ -80,7 +78,7 @@ func (api *Api) GetChatMessage(conn *websocket.Conn, cli *gogpt.Client, mutex *s
req := gogpt.ChatCompletionRequest{
Model: gogpt.GPT3Dot5Turbo0301,
MaxTokens: api.Config.MaxLength,
Temperature: 0.6,
Temperature: 1.0,
Messages: []gogpt.ChatCompletionMessage{
{
Role: "user",
@@ -88,7 +86,6 @@ func (api *Api) GetChatMessage(conn *websocket.Conn, cli *gogpt.Client, mutex *s
},
},
Stream: true,
Stop: []string{"\n\n\n"},
TopP: 1,
FrequencyPenalty: 0.1,
PresencePenalty: 0.1,
@@ -117,7 +114,7 @@ func (api *Api) GetChatMessage(conn *websocket.Conn, cli *gogpt.Client, mutex *s
var i int
for {
response, err := stream.Recv()
if errors.Is(err, io.EOF) {
if err != nil {
var s string
var kind string
if i == 0 {
@@ -136,22 +133,6 @@ func (api *Api) GetChatMessage(conn *websocket.Conn, cli *gogpt.Client, mutex *s
mutex.Lock()
_ = conn.WriteJSON(chatMsg)
mutex.Unlock()
if kind == "retry" {
api.Logger.LogError(s)
}
break
} else if err != nil {
err = fmt.Errorf("[ERROR] receive chatGPT stream error: %s", err.Error())
chatMsg := Message{
Kind: "error",
Msg: err.Error(),
MsgId: id,
CreateTime: time.Now().Format("2006-01-02 15:04:05"),
}
mutex.Lock()
_ = conn.WriteJSON(chatMsg)
mutex.Unlock()
api.Logger.LogError(err.Error())
break
}
@@ -177,7 +158,7 @@ func (api *Api) GetChatMessage(conn *websocket.Conn, cli *gogpt.Client, mutex *s
i = i + 1
}
if strResp != "" {
api.Logger.LogInfo(fmt.Sprintf("[RESPONSE] %s", strResp))
api.Logger.LogInfo(fmt.Sprintf("[RESPONSE] %s\n", strResp))
}
}

View File

@@ -1,7 +1,7 @@
version: "3"
services:
chatgpt-stream:
image: "doryengine/chatgpt-stream:v1.0.0"
image: "doryengine/chatgpt-stream:v1.0.1"
hostname: chatgpt-stream
container_name: chatgpt-stream
ports:
@@ -11,7 +11,7 @@ services:
- chatgpt-service
restart: always
chatgpt-service:
image: "doryengine/chatgpt-service:v1.0.0-alpine"
image: "doryengine/chatgpt-service:v1.0.1-alpine"
hostname: chatgpt-service
container_name: chatgpt-service
ports: