Add a Value slot to dialogue.Slots
router.Slots already carries the fact payload; the dialogue copy did not, so a clarifying answer had nowhere to put it. InheritSlots carries it like Key. Reviewer: check the new inherit block does not overwrite a filled value. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CGeSZxh1DCtRxmFVSYVGvJ
This commit is contained in:
@@ -21,6 +21,7 @@ type Slots struct {
|
|||||||
Time time.Time
|
Time time.Time
|
||||||
HasTime bool
|
HasTime bool
|
||||||
Key string
|
Key string
|
||||||
|
Value string // payload for a fact key, mirrors router.Slots.Value
|
||||||
HasKey bool
|
HasKey bool
|
||||||
Text string
|
Text string
|
||||||
Fn string
|
Fn string
|
||||||
@@ -104,6 +105,9 @@ func InheritSlots(prev, cur Slots) Slots {
|
|||||||
out.Key = prev.Key
|
out.Key = prev.Key
|
||||||
out.HasKey = true
|
out.HasKey = true
|
||||||
}
|
}
|
||||||
|
if out.Value == "" && prev.Value != "" {
|
||||||
|
out.Value = prev.Value
|
||||||
|
}
|
||||||
if out.Text == "" && prev.Text != "" {
|
if out.Text == "" && prev.Text != "" {
|
||||||
out.Text = prev.Text
|
out.Text = prev.Text
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,4 +113,14 @@ func TestInheritSlots(t *testing.T) {
|
|||||||
if inherited6.Text != "какая погода в москве" {
|
if inherited6.Text != "какая погода в москве" {
|
||||||
t.Error("should inherit text when current is empty")
|
t.Error("should inherit text when current is empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prevValue := Slots{Key: "water", HasKey: true, Value: `"drank"`}
|
||||||
|
inherited7 := InheritSlots(prevValue, Slots{})
|
||||||
|
if inherited7.Value != `"drank"` {
|
||||||
|
t.Error("should inherit value when current is empty")
|
||||||
|
}
|
||||||
|
kept := InheritSlots(prevValue, Slots{Value: "2l"})
|
||||||
|
if kept.Value != "2l" {
|
||||||
|
t.Error("should keep current value")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user