mirror of
https://github.com/coalaura/whiskr.git
synced 2025-09-08 17:06:42 +00:00
tweaks
This commit is contained in:
4
chat.go
4
chat.go
@@ -276,6 +276,8 @@ func HandleChat(w http.ResponseWriter, r *http.Request) {
|
||||
for iteration := range raw.Iterations {
|
||||
debug("iteration %d of %d", iteration+1, raw.Iterations)
|
||||
|
||||
response.Send(StartChunk())
|
||||
|
||||
if len(request.Tools) > 0 && iteration == raw.Iterations-1 {
|
||||
debug("no more tool calls")
|
||||
|
||||
@@ -341,6 +343,8 @@ func HandleChat(w http.ResponseWriter, r *http.Request) {
|
||||
tool.AsAssistantToolCall(message),
|
||||
tool.AsToolMessage(),
|
||||
)
|
||||
|
||||
response.Send(EndChunk())
|
||||
}
|
||||
}
|
||||
|
||||
|
14
stream.go
14
stream.go
@@ -13,7 +13,7 @@ import (
|
||||
|
||||
type Chunk struct {
|
||||
Type string `json:"type"`
|
||||
Text any `json:"text"`
|
||||
Text any `json:"text,omitempty"`
|
||||
}
|
||||
|
||||
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 {
|
||||
return Chunk{
|
||||
Type: "error",
|
||||
|
Reference in New Issue
Block a user