feat(AI): streaming response

This commit is contained in:
Yiyang Kang 2023-03-19 14:45:20 +08:00
parent 7b2d3c31e5
commit bd5e8112a1
Signed by: kkyy
GPG key ID: 80FD317ECAF06CC3
3 changed files with 168 additions and 14 deletions

View file

@ -44,3 +44,28 @@ type ChatResponse struct {
Usage map[string]int `json:"usage"`
Choices []ChatResponseChoice `json:"choices"`
}
type ChatResponseStream struct {
ID string
Object string
Created int
Model string
Stream chan string
Err error
}
type ChatResponseStreamChunk struct {
ID string
Object string
Created int
Model string
Choices []ChatResponseStreamChoice
}
type ChatResponseStreamChoice struct {
Index int `json:"index"`
FinishReason string `json:"finish_reason"`
Delta struct {
Content string `json:"content"`
} `json:"delta"`
}