Files
story/internal/contentmodel/memory_intents.go
T
Codex Local bf1233d5df
ci / verify (push) Canceled after 0s
feat: expand companion platform, device controls, and memoir workflows
Add customer and operator login, BLE provisioning, device fleet controls, call memory, memoir generation, and refreshed family and maintenance portals. Include API contracts, migrations, firmware sources, tests, assets, and deployment documentation.
2026-10-08 10:06:44 +08:00

36 lines
964 B
Go

package contentmodel
import (
"context"
"data-terminal-cloud/internal/callmemory"
"data-terminal-cloud/internal/extraction"
"encoding/json"
"errors"
"github.com/jackc/pgx/v5"
)
func (r *Registry) ExtractMemoryIntents(ctx context.Context, tenant string, turns []callmemory.SourceTurn, records []map[string]any) ([]callmemory.Intent, error) {
var generator extraction.Generator = r.fallback
item, e := r.active(ctx, tenant)
if e != nil && !errors.Is(e, pgx.ErrNoRows) {
return nil, e
}
if e == nil {
generator, e = r.generator(item)
if e != nil {
return nil, e
}
}
structured, ok := generator.(interface {
GenerateJSON(context.Context, string, string) (json.RawMessage, error)
})
if !ok {
return nil, errors.New("memory intent model is not configured")
}
raw, e := structured.GenerateJSON(ctx, callmemory.IntentInput(turns, records), callmemory.IntentPrompt)
if e != nil {
return nil, e
}
return callmemory.ParseIntents(raw)
}