31 lines
1.3 KiB
Go
31 lines
1.3 KiB
Go
package domain
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.cin.su/m/Assistant/contracts/interaction"
|
|
)
|
|
|
|
func TestCompilePersonalMemoryKeepsLatestLocationAndPreferences(t *testing.T) {
|
|
memory := CompilePersonalMemory([]interaction.HumanUtterance{
|
|
{ID: "location-old", Content: "я сейчас в Санкт-Петербурге", ReceivedAtUnixMillis: 100},
|
|
{ID: "color", Content: "мне нравится красный цвет", ReceivedAtUnixMillis: 200},
|
|
{ID: "location-new", Content: "я сейчас в Москве", ReceivedAtUnixMillis: 300},
|
|
})
|
|
if got := memory.CurrentLocation(); got != "Москве" {
|
|
t.Fatalf("current location = %q", got)
|
|
}
|
|
context := memory.ContextText()
|
|
if !strings.Contains(context, "Москве") || !strings.Contains(context, "красный цвет") || strings.Contains(context, "Санкт-Петербурге") {
|
|
t.Fatalf("unexpected compact memory context: %q", context)
|
|
}
|
|
}
|
|
|
|
func TestCompilePersonalMemoryDoesNotTreatThirdPartyStatementAsPersonalFact(t *testing.T) {
|
|
memory := CompilePersonalMemory([]interaction.HumanUtterance{{Content: "Погода сейчас в Москве", ReceivedAtUnixMillis: 100}})
|
|
if memory.CurrentLocation() != "" || memory.ContextText() != "" {
|
|
t.Fatalf("ordinary factual question became personal memory: %+v", memory)
|
|
}
|
|
}
|