Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb76171af4 | ||
|
|
213f06661d | ||
|
|
d350b9a565 | ||
|
|
f862c3ac13 | ||
|
|
5e18eb6082 |
@@ -1810,6 +1810,12 @@ func renderResearchReply(query string, result epistemics.ResearchResult, researc
|
|||||||
excerpt = string([]rune(excerpt)[:limit]) + "…"
|
excerpt = string([]rune(excerpt)[:limit]) + "…"
|
||||||
}
|
}
|
||||||
lines = append(lines, excerpt+"\nИсточник: "+researchSourceLabel(finding))
|
lines = append(lines, excerpt+"\nИсточник: "+researchSourceLabel(finding))
|
||||||
|
// A nearest-flight request needs one route-relevant schedule result.
|
||||||
|
// Appending weaker matches makes unrelated category pages look like
|
||||||
|
// alternatives even after the relevance check has accepted the route.
|
||||||
|
if nearestFlightQuery(query) {
|
||||||
|
break
|
||||||
|
}
|
||||||
if len(lines) == 2 {
|
if len(lines) == 2 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -2029,7 +2035,12 @@ func stableKnowledgeAnswer(answer string) bool {
|
|||||||
// completed entirely in the reply. It excludes specialized routes and durable
|
// completed entirely in the reply. It excludes specialized routes and durable
|
||||||
// work, so cognition can produce content but cannot stand in for an executor.
|
// work, so cognition can produce content but cannot stand in for an executor.
|
||||||
func shouldGenerateNonMutatingTextDirective(semantic interactiondomain.SemanticResult, routes []chatRoute, helpPath work.HelpPath, creativeRequest bool) bool {
|
func shouldGenerateNonMutatingTextDirective(semantic interactiondomain.SemanticResult, routes []chatRoute, helpPath work.HelpPath, creativeRequest bool) bool {
|
||||||
if semantic.Interpretation.SpeechAct != interaction.SpeechActDirective || creativeRequest || helpPath.Kind != "" || helpPath.NeedsDurableWork {
|
if semantic.Interpretation.SpeechAct != interaction.SpeechActDirective || creativeRequest || helpPath.NeedsDurableWork {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
// ANSWER and COGNITION are reply-only help paths. They do not execute an
|
||||||
|
// external action, unlike direct capabilities, gaps or durable work.
|
||||||
|
if helpPath.Kind != work.HelpPathAnswer && helpPath.Kind != work.HelpPathCognition && helpPath.Kind != "" {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return !hasChatRoute(routes, chatRouteResearch) && !hasChatRoute(routes, chatRouteMedia) && !hasChatRoute(routes, chatRouteAgent)
|
return !hasChatRoute(routes, chatRouteResearch) && !hasChatRoute(routes, chatRouteMedia) && !hasChatRoute(routes, chatRouteAgent)
|
||||||
|
|||||||
@@ -47,6 +47,17 @@ func TestNearestFlightReplyFiltersUnrelatedSearchSnippets(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNearestFlightReplyDoesNotAppendWeakerSecondMatch(t *testing.T) {
|
||||||
|
result := epistemics.ResearchResult{Findings: []epistemics.ResearchFinding{
|
||||||
|
{State: epistemics.FindingSupported, Source: epistemics.Source{Locator: "https://schedule.example", Title: "Рейсы Москва — Казань"}, Excerpt: epistemics.SourceExcerpt{Text: "Расписание авиарейсов Москва — Казань, время вылета и прилёта."}},
|
||||||
|
{State: epistemics.FindingSupported, Source: epistemics.Source{Locator: "https://category.example", Title: "Категория направлений"}, Excerpt: epistemics.SourceExcerpt{Text: "Список близлежащих городов и ориентировочные цены."}},
|
||||||
|
}}
|
||||||
|
reply, backed := renderResearchReply("ближайшие авиарейсы Москва Казань сегодня", result, nil)
|
||||||
|
if !backed || !strings.Contains(reply, "Рейсы Москва") || strings.Contains(reply, "Категория направлений") {
|
||||||
|
t.Fatalf("weaker second finding leaked into nearest-flight reply: %q", reply)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestNearestFlightEvidenceRequiresBothRouteEndpointsWhenKnown(t *testing.T) {
|
func TestNearestFlightEvidenceRequiresBothRouteEndpointsWhenKnown(t *testing.T) {
|
||||||
query := "ближайшие авиарейсы Москва Казань сегодня"
|
query := "ближайшие авиарейсы Москва Казань сегодня"
|
||||||
matched := epistemics.ResearchFinding{Source: epistemics.Source{Title: "Рейсы Москва — Казань"}, Excerpt: epistemics.SourceExcerpt{Text: "Расписание авиарейсов из Москвы в Казань."}}
|
matched := epistemics.ResearchFinding{Source: epistemics.Source{Title: "Рейсы Москва — Казань"}, Excerpt: epistemics.SourceExcerpt{Text: "Расписание авиарейсов из Москвы в Казань."}}
|
||||||
@@ -151,6 +162,12 @@ func TestNonMutatingTextDirectiveCanUseCognitiveReply(t *testing.T) {
|
|||||||
if !shouldGenerateNonMutatingTextDirective(semantic, nil, work.HelpPath{}, false) {
|
if !shouldGenerateNonMutatingTextDirective(semantic, nil, work.HelpPath{}, false) {
|
||||||
t.Fatal("ordinary formatting directive was not eligible for a cognitive reply")
|
t.Fatal("ordinary formatting directive was not eligible for a cognitive reply")
|
||||||
}
|
}
|
||||||
|
if !shouldGenerateNonMutatingTextDirective(semantic, nil, work.HelpPath{Kind: work.HelpPathCognition}, false) {
|
||||||
|
t.Fatal("reply-only cognition path was incorrectly rejected")
|
||||||
|
}
|
||||||
|
if shouldGenerateNonMutatingTextDirective(semantic, nil, work.HelpPath{Kind: work.HelpPathDirectCapability}, false) {
|
||||||
|
t.Fatal("direct capability was incorrectly replaced by a textual reply")
|
||||||
|
}
|
||||||
if shouldGenerateNonMutatingTextDirective(semantic, []chatRoute{{Kind: chatRouteMedia}}, work.HelpPath{}, false) {
|
if shouldGenerateNonMutatingTextDirective(semantic, []chatRoute{{Kind: chatRouteMedia}}, work.HelpPath{}, false) {
|
||||||
t.Fatal("media route was incorrectly replaced by a textual reply")
|
t.Fatal("media route was incorrectly replaced by a textual reply")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user