fix: route model inventory by semantic intent
This commit is contained in:
@@ -194,6 +194,9 @@ func semanticScores(tokens []string, hasQuestionMark bool, explicitCorrection bo
|
||||
if hasQuestionMark {
|
||||
scores[interaction.SpeechActQuestion]++
|
||||
}
|
||||
if containsMeaningfulInterrogative(tokens) {
|
||||
scores[interaction.SpeechActQuestion] += 2
|
||||
}
|
||||
if explicitCorrection {
|
||||
scores[interaction.SpeechActCorrection] += 6
|
||||
}
|
||||
@@ -432,6 +435,9 @@ func capabilityHintsFor(primary, secondary interaction.SpeechAct, tokens []strin
|
||||
if containsToken(tokens, "свободно") || containsToken(tokens, "гб") || containsToken(tokens, "модель") {
|
||||
add("VERIFY_FACT")
|
||||
}
|
||||
if containsStemInTokens(tokens, "модел", "ии") && containsStemInTokens(tokens, "настро", "список", "доступ", "подключ") {
|
||||
add("VERIFY_FACT")
|
||||
}
|
||||
values := make([]string, 0, len(seen))
|
||||
for kind := range seen {
|
||||
values = append(values, kind)
|
||||
@@ -439,6 +445,18 @@ func capabilityHintsFor(primary, secondary interaction.SpeechAct, tokens []strin
|
||||
return values
|
||||
}
|
||||
|
||||
func informationRequestKind(message string) InformationRequestKind {
|
||||
tokens := semanticTokens(message)
|
||||
if len(tokens) == 0 || containsStem(tokens[0], "настро") || !containsStemInTokens(tokens, "модел", "ии") {
|
||||
return ""
|
||||
}
|
||||
inventoryCue := containsStemInTokens(tokens, "список", "доступ", "подключ") || (containsMeaningfulInterrogative(tokens) && containsStemInTokens(tokens, "настро"))
|
||||
if !inventoryCue {
|
||||
return ""
|
||||
}
|
||||
return InformationRequestCognitiveModelInventory
|
||||
}
|
||||
|
||||
func boundedConfidence(primaryScore, secondaryScore int, scores map[interaction.SpeechAct]int) int64 {
|
||||
total := 0
|
||||
for _, score := range scores {
|
||||
|
||||
@@ -11,16 +11,21 @@ import (
|
||||
)
|
||||
|
||||
type SemanticResult struct {
|
||||
Interpretation interaction.UtteranceInterpretation
|
||||
Candidates []interaction.SemanticCandidate
|
||||
Projects []interaction.ProjectReference
|
||||
Relations []interaction.InteractionRelation
|
||||
ActiveFocus *situation.ActiveProjectFocus
|
||||
Reply string
|
||||
NeedsCognition bool
|
||||
CapabilityHints []string
|
||||
Interpretation interaction.UtteranceInterpretation
|
||||
Candidates []interaction.SemanticCandidate
|
||||
Projects []interaction.ProjectReference
|
||||
Relations []interaction.InteractionRelation
|
||||
ActiveFocus *situation.ActiveProjectFocus
|
||||
Reply string
|
||||
NeedsCognition bool
|
||||
CapabilityHints []string
|
||||
InformationRequestKind InformationRequestKind
|
||||
}
|
||||
|
||||
type InformationRequestKind string
|
||||
|
||||
const InformationRequestCognitiveModelInventory InformationRequestKind = "COGNITIVE_MODEL_INVENTORY"
|
||||
|
||||
func InterpretUtterance(utterance interaction.HumanUtterance, projects []situation.ProjectDescriptor, previousFocus *situation.ActiveProjectFocus, now time.Time) (SemanticResult, error) {
|
||||
interpretationID, err := ids.New()
|
||||
if err != nil {
|
||||
@@ -46,9 +51,10 @@ func InterpretUtterance(utterance interaction.HumanUtterance, projects []situati
|
||||
SelectionReason: selectedCandidate.SelectionReason,
|
||||
RecordedAtUnixMillis: millis,
|
||||
},
|
||||
Candidates: []interaction.SemanticCandidate{deterministicCandidate},
|
||||
NeedsCognition: selectedCandidate.NeedsCognition,
|
||||
CapabilityHints: append([]string(nil), selectedCandidate.CapabilityHints...),
|
||||
Candidates: []interaction.SemanticCandidate{deterministicCandidate},
|
||||
NeedsCognition: selectedCandidate.NeedsCognition,
|
||||
CapabilityHints: append([]string(nil), selectedCandidate.CapabilityHints...),
|
||||
InformationRequestKind: informationRequestKind(utterance.Content),
|
||||
}
|
||||
explicitFocus := explicitProjectFocus(utterance.Content, projects)
|
||||
projectRefs, err := projectReferences(utterance, projects, explicitFocus, previousFocus, millis)
|
||||
|
||||
Reference in New Issue
Block a user