1
0
mirror of https://github.com/coalaura/whiskr.git synced 2025-12-02 20:22:52 +00:00

alive chunk

This commit is contained in:
2025-11-03 03:32:19 +01:00
parent 85ed078058
commit 41210d0b36
3 changed files with 20 additions and 0 deletions

14
chat.go
View File

@@ -9,6 +9,7 @@ import (
"io" "io"
"net/http" "net/http"
"strings" "strings"
"time"
"github.com/revrost/go-openrouter" "github.com/revrost/go-openrouter"
) )
@@ -329,6 +330,19 @@ func HandleChat(w http.ResponseWriter, r *http.Request) {
debug("handling request") debug("handling request")
go func() {
ticker := time.NewTicker(10 * time.Second)
for {
select {
case <-ctx.Done():
return
case <-ticker.C:
response.WriteChunk(NewChunk(ChunkAlive, nil))
}
}
}()
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)

View File

@@ -8,6 +8,7 @@
5: "tool", 5: "tool",
6: "error", 6: "error",
7: "end", 7: "end",
8: "alive",
}; };
const $version = document.getElementById("version"), const $version = document.getElementById("version"),
@@ -1094,6 +1095,10 @@
buffer = buffer.slice(5 + length); buffer = buffer.slice(5 + length);
if (type === "alive") {
continue; // we are still alive
}
callback({ callback({
type: type, type: type,
data: data, data: data,

View File

@@ -21,6 +21,7 @@ const (
ChunkTool ChunkType = 5 ChunkTool ChunkType = 5
ChunkError ChunkType = 6 ChunkError ChunkType = 6
ChunkEnd ChunkType = 7 ChunkEnd ChunkType = 7
ChunkAlive ChunkType = 8
) )
type ChunkType uint8 type ChunkType uint8