| 1 | package chat |
| 2 | |
| 3 | import "time" |
| 4 | |
| 5 | // lookupRecord is one lookup (spec 2026-11-26-assistant-abilities §4.7): |
| 6 | // its turn and attempt, its order in the turn, the call it answered, its |
| 7 | // state (running, shown or failed), the queries and the backends that |
| 8 | // answered them ([{q, backend}]), the reads ([{url, final_url, status, |
| 9 | // bytes, sha256, code}]), the answer and its sources, and its code. |
| 10 | // Never page text. |
| 11 | type lookupRecord struct { |
| 12 | ID string `gorm:"primaryKey"` |
| 13 | Person string `gorm:"not null;index:chat_lookup_person,priority:1"` |
| 14 | TurnID string `gorm:"not null;index:chat_lookup_turn,priority:1"` |
| 15 | Attempt int64 `gorm:"not null;index:chat_lookup_turn,priority:2"` |
| 16 | Seq int64 `gorm:"not null;index:chat_lookup_turn,priority:3"` |
| 17 | CallID string `gorm:"not null"` |
| 18 | State string `gorm:"not null"` |
| 19 | Queries string |
| 20 | Reads string |
| 21 | Answer string |
| 22 | Sources string |
| 23 | Code string |
| 24 | CreatedAt time.Time `gorm:"not null;index:chat_lookup_person,priority:2"` |
| 25 | } |
| 26 | |
| 27 | func (lookupRecord) TableName() string { return "chat_lookups" } |
| 28 | |
| 29 | // A lookup's states. |
| 30 | const ( |
| 31 | lookupRunning = "running" |
| 32 | lookupShown = "shown" |
| 33 | lookupFailed = "failed" |
| 34 | ) |
| 35 | |
| 36 | // webSearchUsageRecord is one search backend's queries in one UTC month, |
| 37 | // against its cap (websearch.DBUsage reads and writes it). |
| 38 | type webSearchUsageRecord struct { |
| 39 | Backend string `gorm:"primaryKey"` |
| 40 | Month string `gorm:"primaryKey"` |
| 41 | Used int64 `gorm:"not null;default:0"` |
| 42 | } |
| 43 | |
| 44 | func (webSearchUsageRecord) TableName() string { return "chat_web_search_usage" } |
| 45 | |