This commit is contained in:
c菌
2023-09-16 19:39:42 +08:00
parent 69cd825180
commit 71872171c9
+3 -2
View File
@@ -243,12 +243,12 @@ func TransReq(chatreq *openai.ChatCompletionRequest) (*bytes.Buffer, error) {
var prompt string var prompt string
for _, msg := range chatreq.Messages { for _, msg := range chatreq.Messages {
switch msg.Role { switch msg.Role {
case "system":
prompt += fmt.Sprintf("\n\nHuman:%s", msg.Content)
case "user": case "user":
prompt += fmt.Sprintf("\n\nHuman:%s", msg.Content) prompt += fmt.Sprintf("\n\nHuman:%s", msg.Content)
case "assistant": case "assistant":
prompt += fmt.Sprintf("\n\nAssistant:%s", msg.Content) prompt += fmt.Sprintf("\n\nAssistant:%s", msg.Content)
case "system":
prompt += fmt.Sprintf("\n\nSystem:%s", msg.Content)
} }
} }
transReq.Prompt = prompt + "\n\nAssistant:" transReq.Prompt = prompt + "\n\nAssistant:"
@@ -294,6 +294,7 @@ func TransRsp(c *gin.Context, isStream bool, reader *bufio.Reader) {
dataChan = make(chan string) dataChan = make(chan string)
stopChan = make(chan bool) stopChan = make(chan bool)
) )
wg.Add(2)
go func() { go func() {
defer wg.Done() defer wg.Done()
for { for {