Require assistant target for renaming #381
@@ -128,6 +128,9 @@ func FallbackText(act interaction.SpeechAct) string {
|
||||
// of the same request.
|
||||
func PreferredAssistantName(message string) string {
|
||||
tokens := semanticTokens(message)
|
||||
if !hasAssistantNamingTarget(tokens) {
|
||||
return ""
|
||||
}
|
||||
for index, token := range tokens {
|
||||
if !containsStem(token, "называ", "назов", "зов", "имен") {
|
||||
continue
|
||||
@@ -371,6 +374,9 @@ func semanticScores(tokens []string, hasQuestionMark bool, explicitCorrection bo
|
||||
}
|
||||
|
||||
func preferredNameFromTokens(tokens []string) bool {
|
||||
if !hasAssistantNamingTarget(tokens) {
|
||||
return false
|
||||
}
|
||||
for index, token := range tokens {
|
||||
if !containsStem(token, "называ", "назов", "зов", "имен") {
|
||||
continue
|
||||
@@ -385,6 +391,10 @@ func preferredNameFromTokens(tokens []string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func hasAssistantNamingTarget(tokens []string) bool {
|
||||
return containsToken(tokens, "тебя") || containsToken(tokens, "тебе") || containsToken(tokens, "ты")
|
||||
}
|
||||
|
||||
// IsRetryRequest identifies a short continuation that asks Domovoy to repeat
|
||||
// the previous task. It deliberately carries no subject-specific knowledge;
|
||||
// the conversation owner supplies the previous task when available.
|
||||
|
||||
@@ -252,6 +252,12 @@ func TestNamingPreferenceIsSemanticAndProducesNaturalAcceptance(t *testing.T) {
|
||||
if name := PreferredAssistantName("давай переименуем тебя в фею. теперь тебя зовут фея"); name != "Фея" {
|
||||
t.Fatalf("rename phrase returned %q", name)
|
||||
}
|
||||
if name := PreferredAssistantName("назови доступные модели"); name != "" {
|
||||
t.Fatalf("model inventory request was mistaken for a name: %q", name)
|
||||
}
|
||||
if result := BuildDeterministicCandidate("назови доступные модели", "", time.Unix(10, 0).UnixMilli()); result.PrimarySpeechAct == interaction.SpeechActPreference {
|
||||
t.Fatalf("model inventory request was mistaken for a preference: %+v", result)
|
||||
}
|
||||
if !IsIdentityInquiry("ты кто?") || !IsIdentityInquiry("как тебя зовут") {
|
||||
t.Fatal("identity variants should be recognized")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user