Restore stable replies after cognitive routing #309
@@ -813,6 +813,11 @@ func main() {
|
|||||||
log.Printf("cognitive response review proposed stable semantic rewrite; preserving semantic reply")
|
log.Printf("cognitive response review proposed stable semantic rewrite; preserving semantic reply")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !responseResult.Handled && identityReply == "" {
|
||||||
|
if stableReply, stable := interactiondomain.StableConversationalReply(utterance.Content, deterministicSpeechAct); stable {
|
||||||
|
planningReply = stableReply
|
||||||
|
}
|
||||||
|
}
|
||||||
response := interaction.ChatMessageResponse{
|
response := interaction.ChatMessageResponse{
|
||||||
ConversationID: conversation.ID,
|
ConversationID: conversation.ID,
|
||||||
UtteranceID: utterance.ID,
|
UtteranceID: utterance.ID,
|
||||||
|
|||||||
@@ -358,6 +358,29 @@ func semanticReply(message string, result SemanticResult, previousFocus *situati
|
|||||||
return FallbackText(result.Interpretation.SpeechAct)
|
return FallbackText(result.Interpretation.SpeechAct)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StableConversationalReply returns the small set of low-risk conversational
|
||||||
|
// replies whose meaning must remain owned by interaction even after a sampled
|
||||||
|
// cognitive audit or a capability fast path.
|
||||||
|
func StableConversationalReply(message string, act interaction.SpeechAct) (string, bool) {
|
||||||
|
switch act {
|
||||||
|
case interaction.SpeechActConversational:
|
||||||
|
lower := strings.ToLower(message)
|
||||||
|
if strings.Contains(lower, "спасибо") || strings.Contains(lower, "благодар") {
|
||||||
|
return "Пожалуйста.", true
|
||||||
|
}
|
||||||
|
if strings.Contains(lower, "привет") || strings.Contains(lower, "здравств") {
|
||||||
|
return "Здравствуйте.", true
|
||||||
|
}
|
||||||
|
return "Я рядом.", true
|
||||||
|
case interaction.SpeechActConfirmation:
|
||||||
|
return "Хорошо.", true
|
||||||
|
case interaction.SpeechActRejection:
|
||||||
|
return "Понял.", true
|
||||||
|
default:
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func isCurrentFocusQuestion(message string, act interaction.SpeechAct) bool {
|
func isCurrentFocusQuestion(message string, act interaction.SpeechAct) bool {
|
||||||
if act != interaction.SpeechActQuestion {
|
if act != interaction.SpeechActQuestion {
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -53,6 +53,13 @@ func TestInterpretUtteranceThanksHasNaturalConversationalReply(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestStableConversationalReplySurvivesCognitiveRewrite(t *testing.T) {
|
||||||
|
reply, stable := StableConversationalReply("спасибо", interaction.SpeechActConversational)
|
||||||
|
if !stable || reply != "Пожалуйста." {
|
||||||
|
t.Fatalf("unexpected stable conversational reply: stable=%t reply=%q", stable, reply)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestInterpretUtteranceDirectiveRecordsOutcomeWithoutExecution(t *testing.T) {
|
func TestInterpretUtteranceDirectiveRecordsOutcomeWithoutExecution(t *testing.T) {
|
||||||
result := interpretForTest(t, "Поменяй базу на УПО1.", activeFocus("upo", "УПО"), "")
|
result := interpretForTest(t, "Поменяй базу на УПО1.", activeFocus("upo", "УПО"), "")
|
||||||
if result.Interpretation.SpeechAct != interaction.SpeechActDirective {
|
if result.Interpretation.SpeechAct != interaction.SpeechActDirective {
|
||||||
|
|||||||
Reference in New Issue
Block a user