1
0
mirror of https://github.com/coalaura/whiskr.git synced 2025-09-08 17:06:42 +00:00
This commit is contained in:
Laura
2025-08-31 23:41:28 +02:00
parent d903521154
commit 2d65c2f484
2 changed files with 17 additions and 1 deletions

View File

@@ -276,6 +276,8 @@ func HandleChat(w http.ResponseWriter, r *http.Request) {
for iteration := range raw.Iterations { for iteration := range raw.Iterations {
debug("iteration %d of %d", iteration+1, raw.Iterations) debug("iteration %d of %d", iteration+1, raw.Iterations)
response.Send(StartChunk())
if len(request.Tools) > 0 && iteration == raw.Iterations-1 { if len(request.Tools) > 0 && iteration == raw.Iterations-1 {
debug("no more tool calls") debug("no more tool calls")
@@ -341,6 +343,8 @@ func HandleChat(w http.ResponseWriter, r *http.Request) {
tool.AsAssistantToolCall(message), tool.AsAssistantToolCall(message),
tool.AsToolMessage(), tool.AsToolMessage(),
) )
response.Send(EndChunk())
} }
} }

View File

@@ -13,7 +13,7 @@ import (
type Chunk struct { type Chunk struct {
Type string `json:"type"` Type string `json:"type"`
Text any `json:"text"` Text any `json:"text,omitempty"`
} }
type Stream struct { type Stream struct {
@@ -72,6 +72,18 @@ func IDChunk(id string) Chunk {
} }
} }
func EndChunk() Chunk {
return Chunk{
Type: "end",
}
}
func StartChunk() Chunk {
return Chunk{
Type: "start",
}
}
func ErrorChunk(err error) Chunk { func ErrorChunk(err error) Chunk {
return Chunk{ return Chunk{
Type: "error", Type: "error",