Add local creative fallback
CI / test (push) Successful in 1m23s
CI / test (pull_request) Successful in 1m40s

This commit is contained in:
m
2026-08-25 11:46:03 +03:00
parent 0904a4ade7
commit 342a93caa4
3 changed files with 29 additions and 1 deletions
+11
View File
@@ -668,6 +668,17 @@ func CreativeDeterministicReply(message string) string {
return ""
}
// CreativeFallbackReply keeps a small creative conversation useful when the
// cognitive channel is unavailable. It is not used when cognition returns a
// completed richer answer.
func CreativeFallbackReply(message string) string {
tokens := semanticTokens(message)
if IsCreativeRequest(message) && containsStemInTokens(tokens, "сказк", "басн") && containsStemInTokens(tokens, "колоб") {
return "Жили-были дед и баба. Испекли они Колобка, а он убежал в лес. Встретил зайца, волка и медведя — от всех укатился, но лису перехитрить не смог. Так Колобок понял: хвастовство и беспечность до добра не доводят."
}
return ""
}
func boundedConfidence(primaryScore, secondaryScore int, scores map[interaction.SpeechAct]int) int64 {
total := 0
for _, score := range scores {
+4
View File
@@ -1,6 +1,7 @@
package domain
import (
"strings"
"testing"
"time"
@@ -243,6 +244,9 @@ func TestInterpretCreativeRequestDoesNotRequireExternalEvidence(t *testing.T) {
if !IsCreativeRequest("расскажи сказку о колобке") {
t.Fatal("story request was not recognized as creative")
}
if got := CreativeFallbackReply("расскажи сказку о колобке"); !strings.Contains(got, "Колоб") {
t.Fatalf("story fallback = %q", got)
}
}
func containsString(values []string, expected string) bool {