Skip to main content

Interface: ITrace

Defined in: internal/trace/types.ts:24

Audit log of every model interaction.

Implemented by Trace; the type of IAIGatewayDeps.trace, so a host may pass its own in overrides.

Methods​

annotate()​

annotate(args): Promise<void>

Defined in: internal/trace/types.ts:56

annotate -- adds what the gateway knows to an entry

About​

The LLMClient recorded the call; the checks that came after are written here.

Loads the entry, merges the chunk ids (a set, no duplicates), appends the issues and notes the template key and version when given, then saves it. Throws 5372588039586 / 404 for an entry the tenant does not have.

Who needs it​

annotateTraces of the orchestration, after the output check of an ask or a run and for the judge entries of every check (D73).

Parameters​

args​
chunkIds​

string[]

issues​

IIssue[]

templateKey?​

EPromptTemplateKey

The template the request was rendered from, and its version.

templateVersion?​

number

tenantId​

string

traceId​

string

Returns​

Promise<void>


anonymizeByUser()​

anonymizeByUser(args): Promise<number>

Defined in: internal/trace/types.ts:121

anonymizeByUser -- keeps a user's entries as an audit skeleton

About​

The numbers stay, the words go.

GDPR pseudonymisation (D54): userId becomes the pseudonym, request and result are removed; usage, cost, model, kind, chunk ids, issues and dates stay. Returns how many entries were changed.

Who needs it​

forgetUser for AIGateway.anonymizeUserData.

Parameters​

args​
pseudonym​

string

tenantId​

string

userId​

string

Returns​

Promise<number>


delete()​

delete(args): Promise<number>

Defined in: internal/trace/types.ts:101

delete -- removes the entries of threads

About​

Hard delete: the audit of a deleted thread goes with it.

The listed thread ids, or "all" for every entry of the tenant, the ones without a thread included; narrowed to one user when userId is given (D119). Returns how many entries went.

Who needs it​

deleteThreads of the gateway's delete; forgetUser for AIGateway.deleteUserData (D54).

Parameters​

args​
tenantId​

string

threadIds​

TThreadIds

userId?​

string

Returns​

Promise<number>


query()​

query(args): Promise<ITraceEntry[]>

Defined in: internal/trace/types.ts:80

query -- the entries of a tenant, filtered and paged

About​

"Why did it say that, what did it cost": the audit page's read.

Passes the filters (ITraceFilters: user, thread, kind, dates) and the page (skip, limit) to the repository and returns the entries as stored, request and result included.

Who needs it​

The host, as gateway.trace.query, for its audit and debugging pages; the tests, to read what a call did.

Parameters​

args​
filters​

ITraceFilters

limit​

number

skip​

number

tenantId​

string

Returns​

Promise<ITraceEntry[]>


record()​

record(args): Promise<void>

Defined in: internal/trace/types.ts:39

record -- writes the entry of one model call

About​

The call already happened; a lost entry is logged, never thrown.

Saves the entry the LLMClient built (save inserts or replaces by id). When the repository throws, the error is logged and the call goes on: the answer belongs to the user, the audit gap to the server log.

Who needs it​

LLMClient.account, after every complete and embed, also for a failed or aborted call.

Parameters​

args​
entry​

ITraceEntry

Returns​

Promise<void>