summaryrefslogtreecommitdiff
path: root/bot.go
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2026-02-06 11:32:06 +0300
committerGrail Finder <wohilas@gmail.com>2026-02-06 11:32:06 +0300
commit478a505869bf26b15dcbc77feb2c09c1f2ff4aac (patch)
tree8103c459a1db2e202f9ea1acc80c2d982b1b7ff1 /bot.go
parentd0722c6f98aa4755f271aefdd8af1cca28fb6f35 (diff)
Enha: client stop string for completion only
Diffstat (limited to 'bot.go')
-rw-r--r--bot.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/bot.go b/bot.go
index bbb3f65..c6c1e77 100644
--- a/bot.go
+++ b/bot.go
@@ -682,8 +682,10 @@ func sendMsgToLLM(body io.Reader) {
answerText = strings.ReplaceAll(chunk.Chunk, "\n\n", "\n")
// Accumulate text to check for stop strings that might span across chunks
// check if chunk is in stopstrings => stop
- if slices.Contains(stopStrings, answerText) {
- logger.Debug("Stop string detected and handled", "stop_string", answerText)
+ // this check is needed only for openrouter /v1/completion, since it does not respect stop slice
+ if chunkParser.GetAPIType() == models.APITypeCompletion &&
+ slices.Contains(stopStrings, answerText) {
+ logger.Debug("stop string detected on client side for completion endpoint", "stop_string", answerText)
streamDone <- true
}
chunkChan <- answerText