1
0
mirror of https://github.com/coalaura/whiskr.git synced 2025-09-09 09:19:54 +00:00

statistics

This commit is contained in:
Laura
2025-08-11 15:43:00 +02:00
parent c10b657742
commit 8a790df2af
12 changed files with 347 additions and 11 deletions

11
chat.go
View File

@@ -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
}