Explain current cognitive response route #373
@@ -767,6 +767,10 @@ func main() {
|
||||
candidates, inventoryErr := capabilityRepository.LoadCognitiveCandidates(r.Context(), capability.CapabilityID("creator-advisory"), session.PrincipalID)
|
||||
planningReply = humanCognitiveModelInventory(candidates, inventoryErr)
|
||||
needsCognition = false
|
||||
case interaction.InformationRequestCognitiveCurrentModel:
|
||||
health, healthErr := capabilityRepository.LoadHealth(r.Context(), capability.CapabilityID("cognitive-proposal"))
|
||||
planningReply = humanCurrentCognitiveModelReply(health, healthErr)
|
||||
needsCognition = false
|
||||
case interaction.InformationRequestCognitiveChannelStatus, interaction.InformationRequestCognitiveRecovery:
|
||||
health, healthErr := capabilityRepository.LoadHealth(r.Context(), capability.CapabilityID("cognitive-proposal"))
|
||||
planningReply = humanCognitiveChannelReply(semantic.InformationRequestKind, semantic.Interpretation.SpeechAct, health, healthErr)
|
||||
@@ -2011,6 +2015,26 @@ func humanCognitiveChannelReply(kind interaction.InformationRequestKind, act int
|
||||
}
|
||||
}
|
||||
|
||||
// humanCurrentCognitiveModelReply answers about the route that produced this
|
||||
// reply. It intentionally does not infer a provider/model name from health:
|
||||
// that would claim a model was used when this direct status path did not call it.
|
||||
func humanCurrentCognitiveModelReply(health capability.Health, healthErr error) string {
|
||||
base := "Этот ответ сформирован встроенным режимом Домового; внешняя модель для него не использовалась."
|
||||
if healthErr != nil {
|
||||
return base + " Состояние канала мышления сейчас не удалось проверить."
|
||||
}
|
||||
switch health.State {
|
||||
case capability.HealthAvailable:
|
||||
return base + " Канал мышления доступен для следующих задач."
|
||||
case capability.HealthDegraded:
|
||||
return base + " Канал мышления работает с ограничениями."
|
||||
case capability.HealthUnavailable:
|
||||
return base + " Канал мышления сейчас недоступен."
|
||||
default:
|
||||
return base + " Состояние канала мышления пока не подтверждено."
|
||||
}
|
||||
}
|
||||
|
||||
func humanCognitiveDegradedReply(message string) string {
|
||||
if strings.TrimSpace(message) == "" {
|
||||
return "Сейчас не удалось обработать запрос."
|
||||
|
||||
@@ -83,6 +83,13 @@ func TestCognitiveChannelQuestionUsesHumanSafeHealthReply(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCurrentModelReplyDoesNotInventProvider(t *testing.T) {
|
||||
reply := humanCurrentCognitiveModelReply(capability.Health{State: capability.HealthDegraded, CapabilityID: "provider-secret-model"}, nil)
|
||||
if !strings.Contains(reply, "встроенным режимом") || !strings.Contains(reply, "ограничениями") || strings.Contains(reply, "provider-secret-model") {
|
||||
t.Fatalf("unexpected current-model reply: %q", reply)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCognitiveConfigurationRequestDoesNotPretendToMutate(t *testing.T) {
|
||||
reply := humanCognitiveChannelReply(interaction.InformationRequestCognitiveRecovery, interaction.SpeechActDirective, capability.Health{State: capability.HealthUnavailable}, nil)
|
||||
if reply != "Канал мышления недоступен. Домовой остаётся на связи." {
|
||||
|
||||
@@ -68,6 +68,7 @@ const (
|
||||
CandidateRejected SemanticCandidateSelectionState = "REJECTED"
|
||||
InformationRequestCapabilityInventory InformationRequestKind = "CAPABILITY_INVENTORY"
|
||||
InformationRequestCognitiveModelInventory InformationRequestKind = "COGNITIVE_MODEL_INVENTORY"
|
||||
InformationRequestCognitiveCurrentModel InformationRequestKind = "COGNITIVE_CURRENT_MODEL"
|
||||
InformationRequestCognitiveChannelStatus InformationRequestKind = "COGNITIVE_CHANNEL_STATUS"
|
||||
InformationRequestCognitiveRecovery InformationRequestKind = "COGNITIVE_RECOVERY"
|
||||
InformationRequestMemoryInventory InformationRequestKind = "MEMORY_INVENTORY"
|
||||
|
||||
@@ -653,6 +653,9 @@ func informationRequestKind(message string, candidate interaction.SemanticCandid
|
||||
}
|
||||
inquiry := candidate.PrimarySpeechAct == interaction.SpeechActQuestion || candidate.PrimarySpeechAct == interaction.SpeechActRequestToInvestigate || candidate.SecondarySpeechAct == interaction.SpeechActQuestion || candidate.SecondarySpeechAct == interaction.SpeechActRequestToInvestigate
|
||||
cognitiveSubject := containsStemInTokens(tokens, "модел", "ии", "ai", "локальн", "когнитив", "канал")
|
||||
if cognitiveSubject && inquiry && containsStemInTokens(tokens, "какая", "какой", "текущ", "сейчас", "отвеч") && containsStemInTokens(tokens, "модел") {
|
||||
return interaction.InformationRequestCognitiveCurrentModel
|
||||
}
|
||||
inventoryCue := containsStemInTokens(tokens, "список", "доступ", "подключ", "вариант") || (containsMeaningfulInterrogative(tokens) && containsStemInTokens(tokens, "настро"))
|
||||
inventoryRequest := inquiry || containsStemInTokens(tokens, "назов", "напиш", "покаж", "перечисл", "сообщ", "вывед", "предостав")
|
||||
if cognitiveSubject && inventoryRequest && inventoryCue {
|
||||
|
||||
@@ -119,6 +119,7 @@ func TestInformationRequestsAreClassifiedOnceByInteraction(t *testing.T) {
|
||||
}{
|
||||
{"какие модели доступны?", interaction.InformationRequestCognitiveModelInventory},
|
||||
{"назови доступные модели", interaction.InformationRequestCognitiveModelInventory},
|
||||
{"какая модель отвечает?", interaction.InformationRequestCognitiveCurrentModel},
|
||||
{"что ты умеешь?", interaction.InformationRequestCapabilityInventory},
|
||||
{"проверь состояние локального канала", interaction.InformationRequestCognitiveChannelStatus},
|
||||
{"нет связи с ИИ, восстанови канал", interaction.InformationRequestCognitiveRecovery},
|
||||
|
||||
Reference in New Issue
Block a user