|
|
|
@@ -620,6 +620,7 @@ func main() {
|
|
|
|
|
assistantName = latestAssistantName(conversationHistory)
|
|
|
|
|
}
|
|
|
|
|
identityReply := ""
|
|
|
|
|
memoryInstructionReply := ""
|
|
|
|
|
log.Printf("interaction identity context: name=%q history=%d", assistantName, len(conversationHistory))
|
|
|
|
|
if interactiondomain.IsIdentityInquiry(utterance.Content) && assistantName != "" {
|
|
|
|
|
identityReply = "Меня зовут " + assistantName + ". Я Домовой, ваш помощник."
|
|
|
|
@@ -629,6 +630,14 @@ func main() {
|
|
|
|
|
semantic.Interpretation.Applicability = interaction.SemanticApplicable
|
|
|
|
|
semantic.Interpretation.Clarification = interaction.ClarificationNotRequired
|
|
|
|
|
}
|
|
|
|
|
if identityReply == "" && interactiondomain.IsExplicitMemoryInstruction(utterance.Content) {
|
|
|
|
|
memoryInstructionReply = "Запомнил."
|
|
|
|
|
semantic.Reply = memoryInstructionReply
|
|
|
|
|
semantic.NeedsCognition = false
|
|
|
|
|
semantic.CapabilityHints = nil
|
|
|
|
|
semantic.Interpretation.Applicability = interaction.SemanticApplicable
|
|
|
|
|
semantic.Interpretation.Clarification = interaction.ClarificationNotRequired
|
|
|
|
|
}
|
|
|
|
|
deterministicSpeechAct := semantic.Interpretation.SpeechAct
|
|
|
|
|
deterministicReply := semantic.Reply
|
|
|
|
|
routePlan := buildChatRoutePlan(semantic)
|
|
|
|
@@ -643,7 +652,7 @@ func main() {
|
|
|
|
|
semanticInterpretationRequested = false
|
|
|
|
|
semanticReflexAudit = false
|
|
|
|
|
}
|
|
|
|
|
if identityReply != "" {
|
|
|
|
|
if identityReply != "" || memoryInstructionReply != "" {
|
|
|
|
|
semanticReflexAudit = false
|
|
|
|
|
}
|
|
|
|
|
if semanticInterpretationRequested || semanticReflexAudit {
|
|
|
|
@@ -936,6 +945,10 @@ func main() {
|
|
|
|
|
planningReply = identityReply
|
|
|
|
|
needsCognition = false
|
|
|
|
|
}
|
|
|
|
|
if memoryInstructionReply != "" {
|
|
|
|
|
planningReply = memoryInstructionReply
|
|
|
|
|
needsCognition = false
|
|
|
|
|
}
|
|
|
|
|
if strings.TrimSpace(planningReply) != "" {
|
|
|
|
|
reviewContext, cancelReview := context.WithTimeout(r.Context(), 12*time.Second)
|
|
|
|
|
reviewedReply, reviewErr := cognitiveClient.ReviewResponse(reviewContext, session, utterance.Content, planningReply, cognitive.TaskMeaning{
|
|
|
|
@@ -946,7 +959,7 @@ func main() {
|
|
|
|
|
ConfidenceMillis: semantic.Interpretation.ConfidenceMillis,
|
|
|
|
|
})
|
|
|
|
|
cancelReview()
|
|
|
|
|
stableSemanticReply := mediaAttempted || identityReply != "" || creativeReply != "" || (creativeFallbackReply != "" && !cognitiveAvailable) || semantic.InformationRequestKind != "" || locationReply != "" || deterministicSpeechAct == interaction.SpeechActConversational || deterministicSpeechAct == interaction.SpeechActConfirmation || deterministicSpeechAct == interaction.SpeechActRejection
|
|
|
|
|
stableSemanticReply := mediaAttempted || identityReply != "" || memoryInstructionReply != "" || creativeReply != "" || (creativeFallbackReply != "" && !cognitiveAvailable) || semantic.InformationRequestKind != "" || locationReply != "" || deterministicSpeechAct == interaction.SpeechActConversational || deterministicSpeechAct == interaction.SpeechActConfirmation || deterministicSpeechAct == interaction.SpeechActRejection
|
|
|
|
|
if reviewErr != nil {
|
|
|
|
|
log.Printf("cognitive response review unavailable: %v", reviewErr)
|
|
|
|
|
} else if !stableSemanticReply && (!researchBacked || reviewPreservesResearchEvidence(reviewedReply, planningReply)) {
|
|
|
|
@@ -971,6 +984,11 @@ func main() {
|
|
|
|
|
needsCognition = false
|
|
|
|
|
planningReply = identityReply
|
|
|
|
|
}
|
|
|
|
|
if memoryInstructionReply != "" {
|
|
|
|
|
semantic.Reply = memoryInstructionReply
|
|
|
|
|
needsCognition = false
|
|
|
|
|
planningReply = memoryInstructionReply
|
|
|
|
|
}
|
|
|
|
|
if creativeReply != "" {
|
|
|
|
|
semantic.Reply = creativeReply
|
|
|
|
|
needsCognition = false
|
|
|
|
|