mirror of
https://github.com/coalaura/whiskr.git
synced 2025-09-09 09:19:54 +00:00
statistics
This commit is contained in:
11
chat.go
11
chat.go
@@ -119,6 +119,9 @@ func HandleChat(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
request.Stream = true
|
||||
request.Usage = &openrouter.IncludeUsage{
|
||||
Include: true,
|
||||
}
|
||||
|
||||
// DEBUG
|
||||
dump(request)
|
||||
@@ -145,6 +148,8 @@ func HandleChat(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
var id string
|
||||
|
||||
for {
|
||||
chunk, err := stream.Recv()
|
||||
if err != nil {
|
||||
@@ -157,6 +162,12 @@ func HandleChat(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if id == "" {
|
||||
id = chunk.ID
|
||||
|
||||
response.Send(IDChunk(id))
|
||||
}
|
||||
|
||||
if len(chunk.Choices) == 0 {
|
||||
continue
|
||||
}
|
||||
|
Reference in New Issue
Block a user