DEV-000066 resolve prospective responses by summary
This commit is contained in:
@@ -168,7 +168,11 @@ func matchingCandidates(message string, candidates []ResponseCandidate) []Respon
|
||||
lower := strings.ToLower(message)
|
||||
var matched []ResponseCandidate
|
||||
for _, candidate := range candidates {
|
||||
if summaryMatches(lower, candidate.Attention.Summary) {
|
||||
summary := candidate.Attention.Summary
|
||||
if summary == "" {
|
||||
summary = candidate.Prospective.Summary
|
||||
}
|
||||
if summaryMatches(lower, summary) {
|
||||
matched = append(matched, candidate)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,16 @@ func TestInterpretHumanResponseCancelsArmedProspectiveBeforeAttention(t *testing
|
||||
}
|
||||
}
|
||||
|
||||
func TestInterpretHumanResponseResolvesArmedProspectiveByNaturalSummaryReference(t *testing.T) {
|
||||
result := interpretResponseForTest(t, "Отмени встретить курьера", []ResponseCandidate{
|
||||
{Prospective: continuity.ProspectiveItem{ID: "p1", OwnerPrincipalID: "principal-1", ScopeID: "scope-1", Summary: "позвонить врачу", State: continuity.ProspectiveArmed, Revision: 1}},
|
||||
{Prospective: continuity.ProspectiveItem{ID: "p2", OwnerPrincipalID: "principal-1", ScopeID: "scope-1", Summary: "встретить курьера", State: continuity.ProspectiveArmed, Revision: 1}},
|
||||
})
|
||||
if !result.Handled || result.Response.TargetKind != continuity.ResponseTargetProspectiveItem || result.Response.TargetProspectiveID != "p2" || result.Response.Outcome != continuity.ResponseOutcomeCancelled {
|
||||
t.Fatalf("unexpected prospective natural target response: %#v", result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestInterpretHumanResponseAmbiguousTargetAsksClarificationWithoutResolvedMutation(t *testing.T) {
|
||||
result := interpretResponseForTest(t, "Готово", []ResponseCandidate{responseCandidate("a1", "p1", "первое"), responseCandidate("a2", "p2", "второе")})
|
||||
if !result.Handled || result.Response.ResolutionState != continuity.ResponseAmbiguous || result.Response.Outcome != continuity.ResponseOutcomeClarificationNeeded || !strings.Contains(result.Reply, "несколько") {
|
||||
|
||||
Reference in New Issue
Block a user