| 84 | } |
| 85 | |
| 86 | func ConstructChatCompletionStreamReponse(model, answerID string, answer string) openai.ChatCompletionStreamResponse { |
| 87 | resp := openai.ChatCompletionStreamResponse{ |
| 88 | ID: answerID, |
| 89 | Object: "chat.completion.chunk", |
| 90 | Created: time.Now().Unix(), |
| 91 | Model: model, |
| 92 | Choices: []openai.ChatCompletionStreamChoice{ |
| 93 | { |
| 94 | Index: 0, |
| 95 | Delta: openai.ChatCompletionStreamChoiceDelta{ |
| 96 | Content: answer, |
| 97 | }, |
| 98 | }, |
| 99 | }, |
| 100 | } |
| 101 | return resp |
| 102 | } |
| 103 | |
| 104 | func SendChatData(w http.ResponseWriter, model string, chatID, data string) { |
| 105 | dataRune := []rune(data) |