Route independent chat actions separately
This commit is contained in:
@@ -69,6 +69,13 @@ func TestStripAssistantVocative(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIndependentRequestParts(t *testing.T) {
|
||||
parts := IndependentRequestParts("Дед, узнай погоду в Сочи и найди ресторан")
|
||||
if len(parts) != 2 || parts[0] != "узнай погоду в Сочи" || parts[1] != "найди ресторан" {
|
||||
t.Fatalf("unexpected request parts: %#v", parts)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTravelSearchClarification(t *testing.T) {
|
||||
if got := TravelSearchClarification("Найди билеты", nil); got == "" {
|
||||
t.Fatal("underspecified travel request must ask for missing route and date")
|
||||
|
||||
@@ -25,6 +25,28 @@ func StripAssistantVocative(message string) string {
|
||||
return trimmed
|
||||
}
|
||||
|
||||
// IndependentRequestParts keeps separate user actions visible to the
|
||||
// orchestrator. It is intentionally limited to the ordinary coordinating
|
||||
// conjunction; the cognitive route remains responsible for ambiguous prose.
|
||||
func IndependentRequestParts(message string) []string {
|
||||
cleaned := StripAssistantVocative(message)
|
||||
parts := strings.Split(cleaned, " и ")
|
||||
if len(parts) < 2 {
|
||||
return []string{cleaned}
|
||||
}
|
||||
result := make([]string, 0, len(parts))
|
||||
for _, part := range parts {
|
||||
part = strings.TrimSpace(part)
|
||||
if part != "" {
|
||||
result = append(result, part)
|
||||
}
|
||||
}
|
||||
if len(result) < 2 {
|
||||
return []string{cleaned}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// TravelSearchClarification keeps an incomplete travel request in dialogue
|
||||
// instead of reducing it to an unrelated generic web search.
|
||||
func TravelSearchClarification(message string, history []interaction.HumanUtterance) string {
|
||||
|
||||
Reference in New Issue
Block a user