Spaces:
Running
Running
| """Typed models for the query-history domain.""" | |
| from __future__ import annotations | |
| from dataclasses import dataclass | |
| from typing import Literal | |
| QueryPage = Literal["search", "compare", "allusions"] | |
| class QueryRun: | |
| """One persisted Research run.""" | |
| id: int | |
| timestamp: str | |
| page: QueryPage | |
| mode: str | None # actual final mode (LOOKUP / COMPARISON / CONCEPTUAL) | |
| query: str | |
| params: dict # parsed back from params_json | |
| result: dict # parsed back from result_json | |
| cost_usd: float | |
| duration_ms: int | |
| n_calls: int | |
| pinned: bool | |
| note: str | None | |
| username: str | None = None # who ran it; NULL on rows from before the column existed | |
| def query_preview(self) -> str: | |
| return (self.query or "")[:120] + ("…" if self.query and len(self.query) > 120 else "") | |