Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5fb616310d | ||
|
|
5a9cf7a22d | ||
|
|
d649f79ca4 | ||
|
|
ffce659332 | ||
|
|
24b30bf669 | ||
|
|
1bd9137761 |
@@ -0,0 +1,25 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"git.cin.su/m/Assistant/contracts/interaction"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSpecializedInformationReplyIsNotOverwrittenByResearch(t *testing.T) {
|
||||||
|
for _, kind := range []interaction.InformationRequestKind{
|
||||||
|
interaction.InformationRequestMemoryInventory,
|
||||||
|
interaction.InformationRequestTimeDifference,
|
||||||
|
interaction.InformationRequestCapabilityInventory,
|
||||||
|
interaction.InformationRequestCognitiveModelInventory,
|
||||||
|
interaction.InformationRequestCognitiveChannelStatus,
|
||||||
|
interaction.InformationRequestCognitiveRecovery,
|
||||||
|
} {
|
||||||
|
if shouldRunGeneralResearch(kind) {
|
||||||
|
t.Fatalf("specialized information request %q must bypass general research", kind)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !shouldRunGeneralResearch("") {
|
||||||
|
t.Fatal("ordinary research requests must still use general research")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -769,7 +769,7 @@ func main() {
|
|||||||
needsCognition = false
|
needsCognition = false
|
||||||
}
|
}
|
||||||
researchBacked := false
|
researchBacked := false
|
||||||
if hasChatRoute(routePlan, chatRouteResearch) && semantic.Interpretation.Clarification != interaction.ClarificationRequired {
|
if hasChatRoute(routePlan, chatRouteResearch) && semantic.Interpretation.Clarification != interaction.ClarificationRequired && shouldRunGeneralResearch(semantic.InformationRequestKind) {
|
||||||
if planID, idErr := ids.New(); idErr == nil {
|
if planID, idErr := ids.New(); idErr == nil {
|
||||||
parts := interactiondomain.IndependentRequestParts(effectiveTaskMessage)
|
parts := interactiondomain.IndependentRequestParts(effectiveTaskMessage)
|
||||||
replies := make([]string, 0, len(parts))
|
replies := make([]string, 0, len(parts))
|
||||||
@@ -1589,6 +1589,10 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func shouldRunGeneralResearch(kind interaction.InformationRequestKind) bool {
|
||||||
|
return kind == ""
|
||||||
|
}
|
||||||
|
|
||||||
func creatorSessionHandler(bootstrapToken, creatorUsername, creatorPassword string, sessionKey []byte, now func() time.Time) http.HandlerFunc {
|
func creatorSessionHandler(bootstrapToken, creatorUsername, creatorPassword string, sessionKey []byte, now func() time.Time) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
authenticated := identitydomain.BootstrapMatches(bootstrapToken, bearerToken(r))
|
authenticated := identitydomain.BootstrapMatches(bootstrapToken, bearerToken(r))
|
||||||
@@ -1796,7 +1800,13 @@ func humanMemoryInventory(history []interaction.HumanUtterance, assistantName st
|
|||||||
lower := strings.ToLower(message)
|
lower := strings.ToLower(message)
|
||||||
if (strings.Contains(lower, "нравится") || strings.Contains(lower, "люблю")) && utterance.ReceivedAtUnixMillis >= latestPreferenceAt {
|
if (strings.Contains(lower, "нравится") || strings.Contains(lower, "люблю")) && utterance.ReceivedAtUnixMillis >= latestPreferenceAt {
|
||||||
latestPreferenceAt = utterance.ReceivedAtUnixMillis
|
latestPreferenceAt = utterance.ReceivedAtUnixMillis
|
||||||
latestPreference = message
|
latestPreference = strings.TrimSpace(message)
|
||||||
|
for _, prefix := range []string{"запомни:", "запомни", "помни:"} {
|
||||||
|
if strings.HasPrefix(strings.ToLower(latestPreference), prefix) {
|
||||||
|
latestPreference = strings.TrimSpace(latestPreference[len(prefix):])
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if latestPreference != "" {
|
if latestPreference != "" {
|
||||||
|
|||||||
@@ -304,6 +304,10 @@ func semanticScores(tokens []string, hasQuestionMark bool, explicitCorrection bo
|
|||||||
scores[interaction.SpeechActPreference] += 8
|
scores[interaction.SpeechActPreference] += 8
|
||||||
scores[interaction.SpeechActAssertion] = 0
|
scores[interaction.SpeechActAssertion] = 0
|
||||||
}
|
}
|
||||||
|
if containsToken(tokens, "запомни") && containsStemInTokens(tokens, "нрав", "люб", "предпочит") {
|
||||||
|
scores[interaction.SpeechActPreference] += 6
|
||||||
|
scores[interaction.SpeechActAssertion] = 0
|
||||||
|
}
|
||||||
if len(tokens) >= 2 && tokens[0] == "я" && containsStemInTokens(tokens[1:], "настро", "сдела", "исправ", "удал", "созда", "перезапуст", "поменя", "добави") {
|
if len(tokens) >= 2 && tokens[0] == "я" && containsStemInTokens(tokens[1:], "настро", "сдела", "исправ", "удал", "созда", "перезапуст", "поменя", "добави") {
|
||||||
scores[interaction.SpeechActAssertion] += 5
|
scores[interaction.SpeechActAssertion] += 5
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -254,6 +254,16 @@ func TestMemoryInventoryRequestIsSemantic(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRememberedPreferenceIsNotRenderedAsIdentity(t *testing.T) {
|
||||||
|
result := BuildDeterministicCandidate("запомни: мне нравится красный цвет", "", time.Unix(10, 0).UnixMilli())
|
||||||
|
if result.PrimarySpeechAct != interaction.SpeechActPreference {
|
||||||
|
t.Fatalf("expected remembered preference, got %+v", result)
|
||||||
|
}
|
||||||
|
if got := semanticReply("запомни: мне нравится красный цвет", SemanticResult{Interpretation: interaction.UtteranceInterpretation{SpeechAct: result.PrimarySpeechAct}}, nil); got != "Хорошо, учту это дальше." {
|
||||||
|
t.Fatalf("unexpected preference reply %q", got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestCreativeRequestsDoNotRouteToWebResearch(t *testing.T) {
|
func TestCreativeRequestsDoNotRouteToWebResearch(t *testing.T) {
|
||||||
for _, message := range []string{"нарисуй круг", "расскажи сказку о колобке"} {
|
for _, message := range []string{"нарисуй круг", "расскажи сказку о колобке"} {
|
||||||
candidate := BuildDeterministicCandidate(message, "", time.Now().UnixMilli())
|
candidate := BuildDeterministicCandidate(message, "", time.Now().UnixMilli())
|
||||||
|
|||||||
Reference in New Issue
Block a user