Prefer current travel context in follow-up answers
CI / test (push) Successful in 1m4s
CI / test (pull_request) Successful in 1m30s

This commit is contained in:
m
2026-08-25 06:59:13 +03:00
parent d7ca5f7e68
commit cbff215f9a
3 changed files with 17 additions and 0 deletions
@@ -113,6 +113,13 @@ func TestTravelSearchClarification(t *testing.T) {
if got := TravelSearchClarification("Найди билеты, какой ближайший самолёт", contextHistory); got != "Из какого города вылетать в Сочи и на какую дату?" {
t.Fatalf("travel destination should be inherited from context, got %q", got)
}
noisyContext := []interaction.HumanUtterance{
{Content: "Как можно добраться до Сочи?"},
{Content: "Какая погода в Питере?"},
}
if got := TravelSearchClarification("Найди билеты", noisyContext); got != "Из какого города вылетать в Сочи и на какую дату?" {
t.Fatalf("unrelated weather history must not replace travel destination, got %q", got)
}
}
func TestInterpretUtteranceDirectiveRecordsOutcomeWithoutExecution(t *testing.T) {
+7
View File
@@ -148,6 +148,9 @@ func TravelSearchClarification(message string, history []interaction.HumanUttera
func travelContextDestination(history []interaction.HumanUtterance) string {
for index := len(history) - 1; index >= 0; index-- {
tokens := semanticTokens(history[index].Content)
if !travelContextCue(tokens) {
continue
}
for tokenIndex, token := range tokens {
if token != "в" && token != "до" {
continue
@@ -160,6 +163,10 @@ func travelContextDestination(history []interaction.HumanUtterance) string {
return ""
}
func travelContextCue(tokens []string) bool {
return travelCue(tokens) || containsStemInTokens(tokens, "добрат", "передвиг", "ехать", "едем", "лететь", "поездк")
}
func capitalizeWord(value string) string {
runes := []rune(value)
if len(runes) == 0 {