Merge pull request 'Continue location follow-ups from recent context' (#322) from codex/chat-semantic-inventory into main
CI / test (push) Successful in 1m9s
CI / test (push) Successful in 1m9s
This commit was merged in pull request #322.
This commit is contained in:
@@ -511,7 +511,6 @@ func main() {
|
||||
var effectiveTaskMessage = interactiondomain.StripAssistantVocative(utterance.Content)
|
||||
var previousTask *interaction.HumanUtterance
|
||||
var conversationHistory []interaction.HumanUtterance
|
||||
var conversationOnlyHistory []interaction.HumanUtterance
|
||||
if request.ConversationID != "" {
|
||||
var historyErr error
|
||||
conversationHistory, historyErr = interactionRepository.Utterances(r.Context(), conversation.ID)
|
||||
@@ -519,7 +518,6 @@ func main() {
|
||||
log.Printf("interaction conversation history unavailable: %v", historyErr)
|
||||
}
|
||||
}
|
||||
conversationOnlyHistory = append(conversationOnlyHistory, conversationHistory...)
|
||||
// Keep durable user context available even when the web client carries a
|
||||
// conversation ID; a new or rotated conversation must not erase learned
|
||||
// preferences.
|
||||
@@ -530,7 +528,7 @@ func main() {
|
||||
log.Printf("interaction principal history loaded: %d utterances", len(recentUserHistory))
|
||||
}
|
||||
conversationHistory = append(conversationHistory, recentUserHistory...)
|
||||
if continuation := interactiondomain.ContinueLocalSearch(effectiveTaskMessage, conversationOnlyHistory); continuation != "" {
|
||||
if continuation := interactiondomain.ContinueLocalSearch(effectiveTaskMessage, conversationHistory); continuation != "" {
|
||||
effectiveTaskMessage = continuation
|
||||
}
|
||||
if request.ConversationID != "" && interactiondomain.IsRetryRequest(utterance.Content) {
|
||||
|
||||
@@ -73,8 +73,15 @@ func ContinueLocalSearch(message string, history []interaction.HumanUtterance) s
|
||||
if len(tokens) == 0 || len(tokens) > 3 || (tokens[0] != "в" && tokens[0] != "на" && tokens[0] != "около") {
|
||||
return ""
|
||||
}
|
||||
for index := len(history) - 1; index >= 0; index-- {
|
||||
previous := strings.TrimSpace(StripAssistantVocative(history[index].Content))
|
||||
var latest *interaction.HumanUtterance
|
||||
for index := range history {
|
||||
if latest == nil || history[index].ReceivedAtUnixMillis > latest.ReceivedAtUnixMillis {
|
||||
candidate := history[index]
|
||||
latest = &candidate
|
||||
}
|
||||
}
|
||||
if latest != nil {
|
||||
previous := strings.TrimSpace(StripAssistantVocative(latest.Content))
|
||||
previousTokens := semanticTokens(previous)
|
||||
if containsStemInTokens(previousTokens, "ресторан", "кафе") && containsStemInTokens(previousTokens, "ближ", "рядом") {
|
||||
return strings.TrimSpace(previous + " " + current)
|
||||
|
||||
Reference in New Issue
Block a user