summaryrefslogtreecommitdiff
path: root/bot.go
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2025-12-29 12:09:18 +0300
committerGrail Finder <wohilas@gmail.com>2025-12-29 12:09:18 +0300
commit3eaf87cd9d38e845cd4eb5f1396b2aa4c9acd44d (patch)
tree9343c6969bc782aca3ac94016db3f5eb05bbde39 /bot.go
parentcae7dea2e7c149edd055b542a2a08b53af8a0ac8 (diff)
parent631c3b6a9b4c8b23f88885f257cd90ae1f45834a (diff)
Merge branch 'master' into doc/tutorial
Diffstat (limited to 'bot.go')
-rw-r--r--bot.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/bot.go b/bot.go
index efd72be..d09fa63 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,16 @@ 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")
+ // drain any remaining chunks from chunkChan before exiting
+ for len(chunkChan) > 0 {
+ chunk := <-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
}