feat: support channel ai.ls now (close #99)

This commit is contained in:
JustSong
2023-05-19 11:07:17 +08:00
parent 7c6bf3e97b
commit 3711f4a741
5 changed files with 15 additions and 7 deletions

View File

@@ -14,9 +14,9 @@ import (
)
type Message struct {
Role string `json:"role"`
Content string `json:"content"`
Name string `json:"name"`
Role string `json:"role"`
Content string `json:"content"`
Name *string `json:"name,omitempty"`
}
type ChatRequest struct {
@@ -232,6 +232,10 @@ func relayHelper(c *gin.Context) *OpenAIErrorWithStatusCode {
go func() {
for scanner.Scan() {
data := scanner.Text()
if len(data) < 6 { // must be something wrong!
common.SysError("Invalid stream response: " + data)
continue
}
dataChan <- data
data = data[6:]
if !strings.HasPrefix(data, "[DONE]") {