-
Notifications
You must be signed in to change notification settings - Fork 9
Document the 5.1 AI & Models feature set #523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c357e0b
Document the 5.1 AI & Models feature set
heskew 802254c
Docs-accuracy fixes from implementation audit
heskew bc180b1
Correct startup-validation semantics for model entries
heskew caba90a
Clarify unresolved env-var placeholder behavior per field type
heskew 803530d
Fix release-notes links to versioned reference path
heskew fe0cc20
AGENTS.md: add Versioning Content conventions
heskew 44bfe49
Drop the 5.1 release-notes draft from this PR
heskew File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| --- | ||
| id: analytics | ||
| title: Analytics | ||
| --- | ||
|
|
||
| <!-- Source: harper resources/models/analyticsTable.ts, resources/models/Models.ts (v5.1) --> | ||
|
|
||
| <VersionBadge version="v5.1.0" /> | ||
|
|
||
| Every model call is recorded for observability and usage accounting, at two levels of granularity: a per-call log table for forensics, and aggregate counters in Harper's [general analytics](../analytics/overview) for dashboards and trends. | ||
|
|
||
| ## Per-call log: `hdb_model_calls` | ||
|
|
||
| Each `embed()`, `generate()`, and `generateStream()` call writes one row to the `hdb_model_calls` system table — on success and on failure. With `toolMode: 'auto'`, each backend round inside the loop records its own row (the outer loop itself does not add one). | ||
|
|
||
| | Field | Description | | ||
| | ------------------- | --------------------------------------------------------------------------------------------------------------- | | ||
| | `tenant` | Tenant identifier, when the call carried one | | ||
| | `app` | Resource path of the calling resource, when called from one | | ||
| | `model` | Logical model name the caller used | | ||
| | `backend` | Backend that served the call (`ollama`, `openai`, …); `unknown` for pre-dispatch failures | | ||
| | `method` | `embed`, `generate`, or `generateStream` | | ||
| | `prompt_tokens` | Prompt token count, when the backend reported usage | | ||
| | `completion_tokens` | Completion token count, when the backend reported usage | | ||
| | `embedding_tokens` | Embedding token count, when the backend reported usage | | ||
| | `latency_ms` | Wall-clock call duration | | ||
| | `success` | Whether the call completed | | ||
| | `error_code` | On failure: `backend_error`, `aborted`, `capability_unsupported`, `backend_not_found`, or `pending_unsupported` | | ||
|
|
||
| Rows are buffered in memory and flushed every 10 seconds, or immediately once 1,000 rows accumulate; rows older than 90 days are purged. Buffered rows may be lost on abrupt shutdown — treat the table as operational telemetry, not an audit log. | ||
|
|
||
| Query it like any table, for example through the operations API: | ||
|
|
||
| ```json | ||
| { | ||
| "operation": "search_by_conditions", | ||
| "database": "system", | ||
| "table": "hdb_model_calls", | ||
| "conditions": [{ "search_attribute": "success", "search_type": "equals", "search_value": false }] | ||
| } | ||
| ``` | ||
|
|
||
| ## Aggregate metrics | ||
|
|
||
| Each call also increments Harper's aggregate analytics (visible in `hdb_raw_analytics` alongside the other [analytics metrics](../analytics/overview)): | ||
|
|
||
| - `model-embed`, `model-generate`, `model-generateStream` — call counts | ||
| - `model-embed-tokens`, `model-generate-tokens`, `model-generateStream-tokens` — token totals | ||
|
|
||
| Metrics are broken down by backend name, so usage can be charted per provider. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an equivalent to automatically embed on the search side of the equation? When we
Document.search({. I'm not seeing an equivalent in the docs, but maybe I missed it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry Dawson. Missed this before merging. No, there's not but the need is now tracked at HarperFast/harper#1277. Great callout.