summaryrefslogtreecommitdiff
path: root/bot.go
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2025-12-28 11:37:52 +0300
committerGrail Finder <wohilas@gmail.com>2025-12-28 11:37:52 +0300
commit033d9bf78ac5afdb2a95696742aea67018a54a17 (patch)
tree15233b6a91e7421311724350cf99202b7d2738b8 /bot.go
parent9d91685e9adde94d20313fb405c4301b4dd59a75 (diff)
Enha: drain chunkChan to avoid missing tokensHEADmaster
Diffstat (limited to 'bot.go')
-rw-r--r--bot.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/bot.go b/bot.go
index efd72be..fe1e56e 100644
--- a/bot.go
+++ b/bot.go
@@ -677,7 +677,6 @@ out:
tv.ScrollToEnd()
// Send chunk to audio stream handler
if cfg.TTS_ENABLED {
- // audioStream.TextChan <- chunk
extra.TTSTextChan <- chunk
}
case toolChunk := <-openAIToolChan:
@@ -685,11 +684,15 @@ out:
toolResp.WriteString(toolChunk)
tv.ScrollToEnd()
case <-streamDone:
- botRespMode = false
- if cfg.TTS_ENABLED {
- // audioStream.TextChan <- chunk
- extra.TTSFlushChan <- true
- logger.Debug("sending flushchan signal")
+ // rrain any remaining chunks from chunkChan before exiting
+ for chunk := range chunkChan {
+ fmt.Fprint(tv, chunk)
+ respText.WriteString(chunk)
+ tv.ScrollToEnd()
+ // Send chunk to audio stream handler
+ if cfg.TTS_ENABLED {
+ extra.TTSTextChan <- chunk
+ }
}
break out
}