Add local creative fallback
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user