mirror of
https://github.com/coalaura/whiskr.git
synced 2025-12-02 20:22:52 +00:00
alive chunk
This commit is contained in:
14
chat.go
14
chat.go
@@ -9,6 +9,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/revrost/go-openrouter"
|
||||
)
|
||||
@@ -329,6 +330,19 @@ func HandleChat(w http.ResponseWriter, r *http.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 {
|
||||
debug("iteration %d of %d", iteration+1, raw.Iterations)
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
5: "tool",
|
||||
6: "error",
|
||||
7: "end",
|
||||
8: "alive",
|
||||
};
|
||||
|
||||
const $version = document.getElementById("version"),
|
||||
@@ -1094,6 +1095,10 @@
|
||||
|
||||
buffer = buffer.slice(5 + length);
|
||||
|
||||
if (type === "alive") {
|
||||
continue; // we are still alive
|
||||
}
|
||||
|
||||
callback({
|
||||
type: type,
|
||||
data: data,
|
||||
|
||||
Reference in New Issue
Block a user