Preserve context across conversation intents (V-542)
Owner explicitly requested direct commits to master; bypass the branch-only hook.
This commit is contained in:
@@ -29,10 +29,13 @@ func TestSessionSurvivesRestart(t *testing.T) {
|
||||
first := openStore(t, path)
|
||||
before := NewPersistentSessionStore(2*time.Minute, first)
|
||||
before.Put("voice", &Session{
|
||||
Intent: IntentReminder,
|
||||
Slots: Slots{Text: "полить цветы", Time: now.Add(time.Hour), HasTime: true},
|
||||
Timestamp: now,
|
||||
TTL: 2 * time.Minute,
|
||||
Intent: IntentReminder,
|
||||
Slots: Slots{Text: "полить цветы", Time: now.Add(time.Hour), HasTime: true},
|
||||
Utterance: "напомни полить цветы",
|
||||
Conversational: true,
|
||||
Timestamp: now,
|
||||
TTL: 2 * time.Minute,
|
||||
History: []Turn{{Intent: IntentChat, Text: "мы говорили о цветах"}},
|
||||
})
|
||||
if err := first.Close(); err != nil {
|
||||
t.Fatalf("close: %v", err)
|
||||
@@ -51,6 +54,15 @@ func TestSessionSurvivesRestart(t *testing.T) {
|
||||
if sess.Intent != IntentReminder {
|
||||
t.Fatalf("intent = %q, want reminder", sess.Intent)
|
||||
}
|
||||
if sess.Utterance != "напомни полить цветы" {
|
||||
t.Fatalf("utterance = %q after restart", sess.Utterance)
|
||||
}
|
||||
if !sess.Conversational {
|
||||
t.Fatal("conversation mode was lost across restart")
|
||||
}
|
||||
if len(sess.History) != 1 || sess.History[0].Text != "мы говорили о цветах" {
|
||||
t.Fatalf("history after restart = %+v", sess.History)
|
||||
}
|
||||
// the follow-up carries no text of its own; it must inherit the old one
|
||||
merged := InheritSlots(sess.Slots, Slots{Time: now.Add(2 * time.Hour), HasTime: true})
|
||||
if merged.Text != "полить цветы" {
|
||||
|
||||
Reference in New Issue
Block a user