evalution 1.0.8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSING.md +26 -44
- package/dist/{check-CR4fU1S5.d.ts → check-ci7RhMcB.d.ts} +13 -868
- package/dist/checks/index.d.ts +2 -1
- package/dist/cli/index.js +209 -58
- package/dist/{dataset-types-Dqi5vVg-.d.ts → dataset-types-8cDpOFYi.d.ts} +2 -247
- package/dist/index.d.ts +325 -1303
- package/dist/index.js +127 -475
- package/dist/{trace-DGj5oW7z.d.ts → trace-BlnjMp7o.d.ts} +2 -1
- package/dist/{trace-event-ingestor-BghQcCHe.js → trace-event-ingestor-DwI1hxGX.js} +2143 -8238
- package/dist/views/datasets/index.d.ts +1 -1
- package/dist/views/index.d.ts +3 -2
- package/dist/views/index.js +0 -4
- package/dist/views/react/index.d.ts +1 -1
- package/package.json +18 -15
package/dist/index.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as EvalNotFoundError, At as registerVariationLoaderHook, B as DatasetNotFoundError, C as rollupSpans, Ct as resourceParameterNames, D as toPromptRef, Dt as resource, E as promptIdOf, Et as isStandardSchema, G as shortId, H as isEditable, J as EvalRunner, K as DEFAULT_EVAL_CONCURRENCY, M as DEFAULT_QUERY_TIMEOUT_MS, Mt as registerFreshImportHook, N as SqlQueryError, O as decodeOtlpProtobuf, Ot as LocalFileProvider, S as mkdirSelfIgnoring, St as parameterDetails, T as VariationConflictError, Tt as isResource, V as DatasetValidationError, _ as runDatasetMigrations, a as readKind, b as assertSqliteFile, bt as DEFAULT_PLAYGROUND_INCLUDE_PATTERNS, c as mergeSpans, d as LocalEvalProvider, dt as resolveExecutionInput, f as openLocalEvalProvider, ft as resolveExecutionInputs, g as TursoDatasetProvider, gt as inputReferenceProblems, h as LocalDirectoryDatasetProvider, ht as findInputCycle, i as mapStatus, j as DEFAULT_MAX_QUERY_ROWS, jt as isFreshImportHookRegistered, k as normalizeOtlpRequest, kt as isVariationLoaderHookRegistered, l as TRACE_QUERY_SCHEMA, m as runEvalMigrations, mt as collectInputSlots, n as OtlpTraceIngestor, o as LocalDatabaseTraceProvider, p as TursoEvalProvider, pt as stampReceipts, q as EvalRunRefusedError, r as llmAndPrompt, s as TursoTraceProvider, t as TraceEventIngestor, u as BaseTraceProvider, ut as matchSourcesToSlots, v as MIGRATIONS_TABLE, vt as namedBindings, wt as isValidInstanceName, x as createLocalTursoClient, xt as ResourceRegistry, y as runMigrations, yt as DEFAULT_PLAYGROUND_IGNORE_PATTERNS } from "./trace-event-ingestor-DwI1hxGX.js";
|
|
2
2
|
import { _ as isCheck, g as check, n as builtinCheck, r as builtinCheckInfos } from "./checks-Cq97JU-h.js";
|
|
3
3
|
import "node:module";
|
|
4
4
|
import path, { dirname } from "node:path";
|
|
5
5
|
import { access, realpath } from "node:fs/promises";
|
|
6
6
|
import { minimatch } from "minimatch";
|
|
7
|
-
import fs$1 from "node:fs";
|
|
8
7
|
import { createHash } from "node:crypto";
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
8
|
+
import { SpanStatusCode } from "@opentelemetry/api";
|
|
9
|
+
import { addProperty, buildPropTypeFromType, extractPropertiesFromObjectLiteral, extractPropertiesFromParameters, isOpaqueType, removeProperty, resolveBindings, updateProperty } from "ts-proppy";
|
|
10
|
+
import { BaseTraceIngestor, BaseTraceIngestor as BaseTraceIngestor$1, CHECK_ATTRIBUTE, DEPLOYMENT_ENVIRONMENT_ATTRIBUTE, Evalution, HttpTraceSink, PLAYGROUND_ENVIRONMENT, PLAYGROUND_RESOURCE, PROMPT_ID_ATTRIBUTE, PROMPT_INPUTS_ATTRIBUTE, PROMPT_NAME_ATTRIBUTE, PROMPT_PROVIDER_ID_ATTRIBUTE, PROMPT_VARIATION_ATTRIBUTE, PROMPT_VERSION_ATTRIBUTE, SERVICE_NAME_ATTRIBUTE, SPAN_KIND_ATTRIBUTE, TRACE_EVENTS_PATH, createTracerForPrompt, getPromptSpanAttributes, isCheckSpan, mergePromptIdentity, spanMessages } from "@evalution/sdk";
|
|
11
11
|
import { spawn } from "node:child_process";
|
|
12
12
|
import { drizzle } from "drizzle-orm/tursodatabase-sync";
|
|
13
13
|
import { and, asc, desc, eq, inArray, or, sql } from "drizzle-orm";
|
|
14
14
|
import { integer, primaryKey, real, sqliteTable, text, uniqueIndex } from "drizzle-orm/sqlite-core";
|
|
15
|
+
import ts from "typescript";
|
|
16
|
+
import { assertUpdateStyle } from "@evalution/sdk/adapter";
|
|
15
17
|
//#region \0rolldown/runtime.js
|
|
16
18
|
var __defProp = Object.defineProperty;
|
|
17
19
|
var __exportAll = (all, no_symbols) => {
|
|
@@ -168,6 +170,125 @@ var OverlayFileProvider = class {
|
|
|
168
170
|
}
|
|
169
171
|
};
|
|
170
172
|
//#endregion
|
|
173
|
+
//#region src/trace/otel-trace-ingestor.ts
|
|
174
|
+
function hrTimeToMs(time) {
|
|
175
|
+
return time[0] * 1e3 + time[1] / 1e6;
|
|
176
|
+
}
|
|
177
|
+
/** `span`'s resource attributes as a {@link Span.resource}, if it has any. */
|
|
178
|
+
function resourceOf(span) {
|
|
179
|
+
const attributes = span.resource?.attributes;
|
|
180
|
+
return attributes && Object.keys(attributes).length > 0 ? { resource: { ...attributes } } : {};
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* {@link TraceIngestor} populated by OpenTelemetry spans. Register the
|
|
184
|
+
* processor returned by {@link getSpanProcessor} on a `BasicTracerProvider`
|
|
185
|
+
* (from `@opentelemetry/sdk-trace-base`).
|
|
186
|
+
*
|
|
187
|
+
* Because OpenTelemetry is a single process-global pipeline, at most one
|
|
188
|
+
* `OTelTraceIngestor` should be active per server — {@link isRedundant}
|
|
189
|
+
* reports any other instance redundant so server wiring can consolidate.
|
|
190
|
+
*/
|
|
191
|
+
var OTelTraceIngestor = class OTelTraceIngestor extends BaseTraceIngestor$1 {
|
|
192
|
+
spanPromises = /* @__PURE__ */ new Map();
|
|
193
|
+
isRedundant(other) {
|
|
194
|
+
return other instanceof OTelTraceIngestor;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Returns a `SpanProcessor` that funnels every OpenTelemetry span the
|
|
198
|
+
* caller's tracer produces into this ingestor's sinks.
|
|
199
|
+
*/
|
|
200
|
+
getSpanProcessor() {
|
|
201
|
+
return {
|
|
202
|
+
onStart: (span) => {
|
|
203
|
+
const spanId = span.spanContext().spanId;
|
|
204
|
+
const p = this.handleStart(span).catch(console.error);
|
|
205
|
+
this.spanPromises.set(spanId, p);
|
|
206
|
+
p.finally(() => this.spanPromises.delete(spanId));
|
|
207
|
+
},
|
|
208
|
+
onEnd: (span) => {
|
|
209
|
+
const spanId = span.spanContext().spanId;
|
|
210
|
+
const p = (this.spanPromises.get(spanId) ?? Promise.resolve()).then(() => this.handleEnd(span)).catch(console.error);
|
|
211
|
+
this.spanPromises.set(spanId, p);
|
|
212
|
+
p.finally(() => this.spanPromises.delete(spanId));
|
|
213
|
+
},
|
|
214
|
+
forceFlush: async () => {},
|
|
215
|
+
shutdown: async () => {}
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
async handleStart(span) {
|
|
219
|
+
const ctx = span.spanContext();
|
|
220
|
+
const traceId = ctx.traceId;
|
|
221
|
+
const spanId = ctx.spanId;
|
|
222
|
+
const parentCtx = span.parentSpanContext;
|
|
223
|
+
const ourSpan = {
|
|
224
|
+
id: spanId,
|
|
225
|
+
traceId,
|
|
226
|
+
parentId: parentCtx && parentCtx.traceId === traceId ? parentCtx.spanId : void 0,
|
|
227
|
+
name: span.name,
|
|
228
|
+
kind: readKind(span.attributes),
|
|
229
|
+
startTime: hrTimeToMs(span.startTime),
|
|
230
|
+
attributes: { ...span.attributes },
|
|
231
|
+
...resourceOf(span),
|
|
232
|
+
...llmAndPrompt(span.attributes)
|
|
233
|
+
};
|
|
234
|
+
await this.recordSpanStart(ourSpan);
|
|
235
|
+
}
|
|
236
|
+
async handleEnd(span) {
|
|
237
|
+
const ctx = span.spanContext();
|
|
238
|
+
const traceId = ctx.traceId;
|
|
239
|
+
const ended = {
|
|
240
|
+
id: ctx.spanId,
|
|
241
|
+
traceId,
|
|
242
|
+
parentId: span.parentSpanContext && span.parentSpanContext.traceId === traceId ? span.parentSpanContext.spanId : void 0,
|
|
243
|
+
name: span.name,
|
|
244
|
+
kind: readKind(span.attributes),
|
|
245
|
+
startTime: hrTimeToMs(span.startTime),
|
|
246
|
+
endTime: hrTimeToMs(span.endTime),
|
|
247
|
+
status: mapStatus(span.status),
|
|
248
|
+
errorMessage: span.status.code === SpanStatusCode.ERROR ? span.status.message : void 0,
|
|
249
|
+
attributes: { ...span.attributes },
|
|
250
|
+
...resourceOf(span),
|
|
251
|
+
...llmAndPrompt(span.attributes)
|
|
252
|
+
};
|
|
253
|
+
await this.recordSpanEnd(ended);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Waits for every in-flight `onStart`/`onEnd` handler to settle. Used by
|
|
257
|
+
* tests to deterministically assert on the resulting trace store.
|
|
258
|
+
*/
|
|
259
|
+
async drainPendingHandlers() {
|
|
260
|
+
while (this.spanPromises.size > 0) await Promise.all([...this.spanPromises.values()]);
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/trace/otel-global-pipeline.ts
|
|
265
|
+
let globalOTelPipeline;
|
|
266
|
+
/**
|
|
267
|
+
* Stands up the process-global OpenTelemetry tracer provider and
|
|
268
|
+
* `AsyncLocalStorageContextManager`, if not already done, and returns the
|
|
269
|
+
* {@link OTelTraceIngestor} feeding it.
|
|
270
|
+
*
|
|
271
|
+
* Safe to call from multiple SDK adapters: the underlying setup runs at most
|
|
272
|
+
* once per process, and every caller is resolved with the same ingestor
|
|
273
|
+
* instance.
|
|
274
|
+
*/
|
|
275
|
+
function setupGlobalOTelPipeline() {
|
|
276
|
+
globalOTelPipeline ??= doSetup();
|
|
277
|
+
return globalOTelPipeline;
|
|
278
|
+
}
|
|
279
|
+
async function doSetup() {
|
|
280
|
+
const { context, trace } = await import("@opentelemetry/api");
|
|
281
|
+
const { AsyncLocalStorageContextManager } = await import("@opentelemetry/context-async-hooks");
|
|
282
|
+
const { BasicTracerProvider } = await import("@opentelemetry/sdk-trace-base");
|
|
283
|
+
const ingestor = new OTelTraceIngestor();
|
|
284
|
+
const tracerProvider = new BasicTracerProvider({ spanProcessors: [ingestor.getSpanProcessor()] });
|
|
285
|
+
trace.setGlobalTracerProvider(tracerProvider);
|
|
286
|
+
const contextManager = new AsyncLocalStorageContextManager();
|
|
287
|
+
contextManager.enable();
|
|
288
|
+
context.setGlobalContextManager(contextManager);
|
|
289
|
+
return ingestor;
|
|
290
|
+
}
|
|
291
|
+
//#endregion
|
|
171
292
|
//#region src/prompt/variations/canonical-updates.ts
|
|
172
293
|
/** Prefix of a per-parameter field name, e.g. `modelParameters.temperature`. */
|
|
173
294
|
const MODEL_PARAMETER_PREFIX = "modelParameters.";
|
|
@@ -3145,7 +3266,7 @@ var FilePromptProvider = class {
|
|
|
3145
3266
|
}
|
|
3146
3267
|
}
|
|
3147
3268
|
async setupTraceIngestion() {
|
|
3148
|
-
return this.sdkAdapter.setupTraceIngestion?.();
|
|
3269
|
+
return this.sdkAdapter.setupTraceIngestion?.({ setupGlobalOTelPipeline });
|
|
3149
3270
|
}
|
|
3150
3271
|
async renamePrompt(promptId, newName) {
|
|
3151
3272
|
const [filePath, oldName] = this.parsePromptId(promptId);
|
|
@@ -3835,475 +3956,6 @@ var GitVersioning = class GitVersioning {
|
|
|
3835
3956
|
}
|
|
3836
3957
|
};
|
|
3837
3958
|
//#endregion
|
|
3838
|
-
//#region src/sdk/gemini-interactions-sdk.ts
|
|
3839
|
-
const MODEL_KEY = "model";
|
|
3840
|
-
const AGENT_KEY = "agent";
|
|
3841
|
-
const SYSTEM_KEY = "system_instruction";
|
|
3842
|
-
const INPUT_KEY = "input";
|
|
3843
|
-
const GENERATION_CONFIG_KEY = "generation_config";
|
|
3844
|
-
const AGENT_CONFIG_KEY = "agent_config";
|
|
3845
|
-
const FALLBACK_GENERATION_CONFIG_PARAMS = [
|
|
3846
|
-
{
|
|
3847
|
-
name: "temperature",
|
|
3848
|
-
description: "Controls the randomness of the output.",
|
|
3849
|
-
type: {
|
|
3850
|
-
kind: "primitive",
|
|
3851
|
-
syntax: "number"
|
|
3852
|
-
},
|
|
3853
|
-
optional: true
|
|
3854
|
-
},
|
|
3855
|
-
{
|
|
3856
|
-
name: "top_p",
|
|
3857
|
-
description: "The maximum cumulative probability of tokens to consider when sampling.",
|
|
3858
|
-
type: {
|
|
3859
|
-
kind: "primitive",
|
|
3860
|
-
syntax: "number"
|
|
3861
|
-
},
|
|
3862
|
-
optional: true
|
|
3863
|
-
},
|
|
3864
|
-
{
|
|
3865
|
-
name: "max_output_tokens",
|
|
3866
|
-
description: "The maximum number of tokens to include in the response.",
|
|
3867
|
-
type: {
|
|
3868
|
-
kind: "primitive",
|
|
3869
|
-
syntax: "number"
|
|
3870
|
-
},
|
|
3871
|
-
optional: true
|
|
3872
|
-
},
|
|
3873
|
-
{
|
|
3874
|
-
name: "seed",
|
|
3875
|
-
description: "Seed used in decoding for reproducibility.",
|
|
3876
|
-
type: {
|
|
3877
|
-
kind: "primitive",
|
|
3878
|
-
syntax: "number"
|
|
3879
|
-
},
|
|
3880
|
-
optional: true
|
|
3881
|
-
},
|
|
3882
|
-
{
|
|
3883
|
-
name: "stop_sequences",
|
|
3884
|
-
description: "A list of character sequences that will stop output interaction.",
|
|
3885
|
-
type: {
|
|
3886
|
-
kind: "array",
|
|
3887
|
-
syntax: "string[]",
|
|
3888
|
-
element: {
|
|
3889
|
-
name: "",
|
|
3890
|
-
type: {
|
|
3891
|
-
kind: "primitive",
|
|
3892
|
-
syntax: "string"
|
|
3893
|
-
},
|
|
3894
|
-
optional: false
|
|
3895
|
-
}
|
|
3896
|
-
},
|
|
3897
|
-
optional: true
|
|
3898
|
-
},
|
|
3899
|
-
{
|
|
3900
|
-
name: "thinking_level",
|
|
3901
|
-
description: "The level of thought tokens that the model should generate.",
|
|
3902
|
-
type: {
|
|
3903
|
-
kind: "union",
|
|
3904
|
-
syntax: "'minimal' | 'low' | 'medium' | 'high'",
|
|
3905
|
-
types: [
|
|
3906
|
-
{
|
|
3907
|
-
kind: "constant",
|
|
3908
|
-
syntax: "'minimal'",
|
|
3909
|
-
value: "minimal"
|
|
3910
|
-
},
|
|
3911
|
-
{
|
|
3912
|
-
kind: "constant",
|
|
3913
|
-
syntax: "'low'",
|
|
3914
|
-
value: "low"
|
|
3915
|
-
},
|
|
3916
|
-
{
|
|
3917
|
-
kind: "constant",
|
|
3918
|
-
syntax: "'medium'",
|
|
3919
|
-
value: "medium"
|
|
3920
|
-
},
|
|
3921
|
-
{
|
|
3922
|
-
kind: "constant",
|
|
3923
|
-
syntax: "'high'",
|
|
3924
|
-
value: "high"
|
|
3925
|
-
}
|
|
3926
|
-
]
|
|
3927
|
-
},
|
|
3928
|
-
optional: true
|
|
3929
|
-
},
|
|
3930
|
-
{
|
|
3931
|
-
name: "thinking_summaries",
|
|
3932
|
-
description: "Whether to include thought summaries in the response.",
|
|
3933
|
-
type: {
|
|
3934
|
-
kind: "union",
|
|
3935
|
-
syntax: "'auto' | 'none'",
|
|
3936
|
-
types: [{
|
|
3937
|
-
kind: "constant",
|
|
3938
|
-
syntax: "'auto'",
|
|
3939
|
-
value: "auto"
|
|
3940
|
-
}, {
|
|
3941
|
-
kind: "constant",
|
|
3942
|
-
syntax: "'none'",
|
|
3943
|
-
value: "none"
|
|
3944
|
-
}]
|
|
3945
|
-
},
|
|
3946
|
-
optional: true
|
|
3947
|
-
}
|
|
3948
|
-
];
|
|
3949
|
-
/**
|
|
3950
|
-
* The models `interactions.create` accepts — a subset of the full Gemini
|
|
3951
|
-
* lineup. See https://ai.google.dev/gemini-api/docs/interactions
|
|
3952
|
-
*/
|
|
3953
|
-
const CURATED_MODELS = [
|
|
3954
|
-
{
|
|
3955
|
-
label: "Gemini 3.8 Flash",
|
|
3956
|
-
id: "gemini-3.8-flash"
|
|
3957
|
-
},
|
|
3958
|
-
{
|
|
3959
|
-
label: "Gemini 3.7 Flash",
|
|
3960
|
-
id: "gemini-3.7-flash"
|
|
3961
|
-
},
|
|
3962
|
-
{
|
|
3963
|
-
label: "Gemini 3.6 Flash",
|
|
3964
|
-
id: "gemini-3.6-flash"
|
|
3965
|
-
},
|
|
3966
|
-
{
|
|
3967
|
-
label: "Gemini 3.5 Flash",
|
|
3968
|
-
id: "gemini-3.5-flash"
|
|
3969
|
-
},
|
|
3970
|
-
{
|
|
3971
|
-
label: "Gemini 3.5 Flash-Lite",
|
|
3972
|
-
id: "gemini-3.5-flash-lite"
|
|
3973
|
-
},
|
|
3974
|
-
{
|
|
3975
|
-
label: "Gemini 3.1 Pro Preview",
|
|
3976
|
-
id: "gemini-3.1-pro-preview"
|
|
3977
|
-
},
|
|
3978
|
-
{
|
|
3979
|
-
label: "Gemini 3.1 Flash-Lite",
|
|
3980
|
-
id: "gemini-3.1-flash-lite"
|
|
3981
|
-
},
|
|
3982
|
-
{
|
|
3983
|
-
label: "Gemini 3 Flash Preview",
|
|
3984
|
-
id: "gemini-3-flash-preview"
|
|
3985
|
-
},
|
|
3986
|
-
{
|
|
3987
|
-
label: "Gemini 2.5 Pro",
|
|
3988
|
-
id: "gemini-2.5-pro"
|
|
3989
|
-
},
|
|
3990
|
-
{
|
|
3991
|
-
label: "Gemini 2.5 Flash",
|
|
3992
|
-
id: "gemini-2.5-flash"
|
|
3993
|
-
},
|
|
3994
|
-
{
|
|
3995
|
-
label: "Gemini 2.5 Flash-Lite",
|
|
3996
|
-
id: "gemini-2.5-flash-lite"
|
|
3997
|
-
}
|
|
3998
|
-
];
|
|
3999
|
-
/** The agents `interactions.create` accepts. */
|
|
4000
|
-
const CURATED_AGENTS = [
|
|
4001
|
-
{
|
|
4002
|
-
label: "Deep Research Preview",
|
|
4003
|
-
id: "deep-research-preview-04-2026"
|
|
4004
|
-
},
|
|
4005
|
-
{
|
|
4006
|
-
label: "Deep Research Max Preview",
|
|
4007
|
-
id: "deep-research-max-preview-04-2026"
|
|
4008
|
-
},
|
|
4009
|
-
{
|
|
4010
|
-
label: "Antigravity Preview",
|
|
4011
|
-
id: "antigravity-preview-09-2026"
|
|
4012
|
-
}
|
|
4013
|
-
];
|
|
4014
|
-
/** Each variant's own settings, which are invalid under the other. */
|
|
4015
|
-
const VARIANT_CONFIG_KEY = {
|
|
4016
|
-
model: GENERATION_CONFIG_KEY,
|
|
4017
|
-
agent: AGENT_CONFIG_KEY
|
|
4018
|
-
};
|
|
4019
|
-
const STRING = {
|
|
4020
|
-
kind: "primitive",
|
|
4021
|
-
syntax: "string",
|
|
4022
|
-
base: "string"
|
|
4023
|
-
};
|
|
4024
|
-
/** One variant's fragment of the config, `{ model: … }` or `{ agent: … }`. */
|
|
4025
|
-
function variantType(key, idType = STRING) {
|
|
4026
|
-
return {
|
|
4027
|
-
kind: "object",
|
|
4028
|
-
syntax: `{ ${key}: ${key === MODEL_KEY ? "Model" : "AgentOption"} }`,
|
|
4029
|
-
properties: [{
|
|
4030
|
-
name: key,
|
|
4031
|
-
type: idType,
|
|
4032
|
-
optional: false
|
|
4033
|
-
}]
|
|
4034
|
-
};
|
|
4035
|
-
}
|
|
4036
|
-
/** The model slot's type when it couldn't be resolved. */
|
|
4037
|
-
const FALLBACK_MODEL_TYPE = {
|
|
4038
|
-
kind: "union",
|
|
4039
|
-
syntax: "{ model: Model } | { agent: AgentOption }",
|
|
4040
|
-
types: [variantType(MODEL_KEY), variantType(AGENT_KEY)]
|
|
4041
|
-
};
|
|
4042
|
-
/** Probe name for the model slot's type, as reported in project results. */
|
|
4043
|
-
const MODEL_PROBE = "model";
|
|
4044
|
-
/**
|
|
4045
|
-
* The model slot as a union of two config fragments: each variant's own ID
|
|
4046
|
-
* key, read off the SDK's own request types.
|
|
4047
|
-
*/
|
|
4048
|
-
const MODEL_PROJECT_PROBES = [{
|
|
4049
|
-
kind: "type",
|
|
4050
|
-
name: MODEL_PROBE,
|
|
4051
|
-
expression: "Pick<import(\"@google/genai\").Interactions.CreateModelInteraction, \"model\"> | Pick<import(\"@google/genai\").Interactions.CreateAgentInteraction, \"agent\">",
|
|
4052
|
-
syntax: "{ model: Model } | { agent: AgentOption }"
|
|
4053
|
-
}];
|
|
4054
|
-
/** The variant member of a resolved model type, by the key it carries. */
|
|
4055
|
-
function memberFor(type, key) {
|
|
4056
|
-
return (type.kind === "union" ? type.types : [type]).find((m) => m.kind === "object" && m.properties.some((p) => p.name === key)) ?? variantType(key);
|
|
4057
|
-
}
|
|
4058
|
-
function fragment(key, id) {
|
|
4059
|
-
return {
|
|
4060
|
-
kind: "object",
|
|
4061
|
-
properties: { [key]: {
|
|
4062
|
-
kind: "primitive",
|
|
4063
|
-
value: id
|
|
4064
|
-
} },
|
|
4065
|
-
displayValue: id
|
|
4066
|
-
};
|
|
4067
|
-
}
|
|
4068
|
-
/** Which variant a model fragment is, if it is one. */
|
|
4069
|
-
function variantOf(value) {
|
|
4070
|
-
if (value?.kind !== "object") return void 0;
|
|
4071
|
-
if (MODEL_KEY in value.properties) return MODEL_KEY;
|
|
4072
|
-
if (AGENT_KEY in value.properties) return AGENT_KEY;
|
|
4073
|
-
}
|
|
4074
|
-
/**
|
|
4075
|
-
* {@link SDKAdapter} implementation for the Google GenAI
|
|
4076
|
-
* [Interactions API](https://ai.google.dev/gemini-api/docs/interactions)
|
|
4077
|
-
* (`@google/genai` package). Currently experimental and untested.
|
|
4078
|
-
*/
|
|
4079
|
-
var GeminiInteractionsSDK = class {
|
|
4080
|
-
promptsHelperImport = "FIXME";
|
|
4081
|
-
getProjectProbes(language) {
|
|
4082
|
-
return language === "typescript" ? MODEL_PROJECT_PROBES : [];
|
|
4083
|
-
}
|
|
4084
|
-
/**
|
|
4085
|
-
* One model row whose value is an honest config fragment —
|
|
4086
|
-
* `{ model: "gemini-3.5-flash" }` or `{ agent: "deep-research-…" }` —
|
|
4087
|
-
* because `interactions.create` takes one or the other, never both. The
|
|
4088
|
-
* **Models** and **Agents** catalogs each narrow their free-form entry to
|
|
4089
|
-
* their own variant.
|
|
4090
|
-
*/
|
|
4091
|
-
async getModelDefinition(project) {
|
|
4092
|
-
const resolved = project[MODEL_PROBE];
|
|
4093
|
-
const type = resolved && !Array.isArray(resolved) ? resolved.type : FALLBACK_MODEL_TYPE;
|
|
4094
|
-
const catalog = (key, label, ids) => ({
|
|
4095
|
-
label,
|
|
4096
|
-
groups: [{
|
|
4097
|
-
label: "Google",
|
|
4098
|
-
icon: "Google",
|
|
4099
|
-
presets: ids.map(({ label, id }) => ({
|
|
4100
|
-
label,
|
|
4101
|
-
value: fragment(key, id)
|
|
4102
|
-
}))
|
|
4103
|
-
}],
|
|
4104
|
-
literal: {
|
|
4105
|
-
name: "model",
|
|
4106
|
-
type: memberFor(type, key),
|
|
4107
|
-
optional: false
|
|
4108
|
-
}
|
|
4109
|
-
});
|
|
4110
|
-
return {
|
|
4111
|
-
name: "model",
|
|
4112
|
-
type,
|
|
4113
|
-
optional: false,
|
|
4114
|
-
catalogs: [catalog(MODEL_KEY, "Models", CURATED_MODELS), catalog(AGENT_KEY, "Agents", CURATED_AGENTS)]
|
|
4115
|
-
};
|
|
4116
|
-
}
|
|
4117
|
-
getModelParameters(rootDir) {
|
|
4118
|
-
try {
|
|
4119
|
-
const dtsPath = findPackageDts("@google/genai", "dist/genai.d.ts", rootDir);
|
|
4120
|
-
if (dtsPath) {
|
|
4121
|
-
const sourceText = fs$1.readFileSync(dtsPath, "utf-8");
|
|
4122
|
-
const sourceFile = ts.createSourceFile(dtsPath, sourceText, ts.ScriptTarget.Latest, true);
|
|
4123
|
-
const decl = findTypeDeclaration(sourceFile, "GenerationConfig_2");
|
|
4124
|
-
if (decl) return extractPropertiesFromDeclaration(decl, sourceFile).definitions;
|
|
4125
|
-
}
|
|
4126
|
-
} catch {}
|
|
4127
|
-
return FALLBACK_GENERATION_CONFIG_PARAMS;
|
|
4128
|
-
}
|
|
4129
|
-
async executeConfig(config) {
|
|
4130
|
-
let GoogleGenAI;
|
|
4131
|
-
try {
|
|
4132
|
-
({GoogleGenAI} = await import("@google/genai"));
|
|
4133
|
-
} catch (err) {
|
|
4134
|
-
if (!isMissingPackage(err, "@google/genai")) throw err;
|
|
4135
|
-
throw new Error(missingPackageMessage("@google/genai"), { cause: err });
|
|
4136
|
-
}
|
|
4137
|
-
await new GoogleGenAI({}).interactions.create({
|
|
4138
|
-
...config,
|
|
4139
|
-
store: false
|
|
4140
|
-
});
|
|
4141
|
-
}
|
|
4142
|
-
normalizePrompt(prompt) {
|
|
4143
|
-
const { definitions, values } = prompt.extractedProps;
|
|
4144
|
-
const systemValue = values?.[SYSTEM_KEY];
|
|
4145
|
-
const inputValue = values?.[INPUT_KEY];
|
|
4146
|
-
const modelValue = values?.[MODEL_KEY];
|
|
4147
|
-
const agentValue = values?.[AGENT_KEY];
|
|
4148
|
-
const variant = !modelValue && agentValue ? AGENT_KEY : MODEL_KEY;
|
|
4149
|
-
const idValue = variant === MODEL_KEY ? modelValue : agentValue;
|
|
4150
|
-
const model = idValue && {
|
|
4151
|
-
kind: "object",
|
|
4152
|
-
properties: { [variant]: idValue },
|
|
4153
|
-
displayValue: idValue.kind === "primitive" ? String(idValue.value) : valueToSourceText(idValue)
|
|
4154
|
-
};
|
|
4155
|
-
const configKey = VARIANT_CONFIG_KEY[variant];
|
|
4156
|
-
const configDef = definitions.find((d) => d.name === configKey);
|
|
4157
|
-
const configValue = values?.[configKey];
|
|
4158
|
-
const configProps = configValue?.kind === "object" ? configValue.properties : {};
|
|
4159
|
-
const modelParameters = (configDef?.type.kind === "object" ? configDef.type.properties : []).map((def) => ({
|
|
4160
|
-
def,
|
|
4161
|
-
value: configProps[def.name]
|
|
4162
|
-
}));
|
|
4163
|
-
return {
|
|
4164
|
-
style: "chat",
|
|
4165
|
-
id: prompt.id,
|
|
4166
|
-
providerId: prompt.providerId,
|
|
4167
|
-
name: prompt.name,
|
|
4168
|
-
functionParameters: prompt.functionParameters,
|
|
4169
|
-
metadata: prompt.metadata,
|
|
4170
|
-
treePath: prompt.treePath,
|
|
4171
|
-
model,
|
|
4172
|
-
modelEditable: true,
|
|
4173
|
-
system: systemValue,
|
|
4174
|
-
systemEditable: true,
|
|
4175
|
-
messages: extractMessages(inputValue),
|
|
4176
|
-
messagesEditable: true,
|
|
4177
|
-
modelParameters
|
|
4178
|
-
};
|
|
4179
|
-
}
|
|
4180
|
-
denormalizeUpdates(updates, currentValues) {
|
|
4181
|
-
assertUpdateStyle(updates, "chat");
|
|
4182
|
-
const out = {};
|
|
4183
|
-
const remove = (key) => {
|
|
4184
|
-
if (currentValues && key in currentValues) out[key] = null;
|
|
4185
|
-
};
|
|
4186
|
-
const currentVariant = currentValues && MODEL_KEY in currentValues ? MODEL_KEY : currentValues && AGENT_KEY in currentValues ? AGENT_KEY : void 0;
|
|
4187
|
-
let variant = currentVariant ?? MODEL_KEY;
|
|
4188
|
-
if ("model" in updates) {
|
|
4189
|
-
const next = variantOf(updates.model);
|
|
4190
|
-
if (!next) {
|
|
4191
|
-
remove(MODEL_KEY);
|
|
4192
|
-
remove(AGENT_KEY);
|
|
4193
|
-
} else if (updates.model?.kind === "object") {
|
|
4194
|
-
const other = next === MODEL_KEY ? AGENT_KEY : MODEL_KEY;
|
|
4195
|
-
out[next] = updates.model.properties[next];
|
|
4196
|
-
remove(other);
|
|
4197
|
-
if (currentVariant && currentVariant !== next) remove(VARIANT_CONFIG_KEY[other]);
|
|
4198
|
-
variant = next;
|
|
4199
|
-
}
|
|
4200
|
-
}
|
|
4201
|
-
if ("system" in updates) out[SYSTEM_KEY] = updates.system ?? null;
|
|
4202
|
-
if ("messages" in updates) out[INPUT_KEY] = updates.messages == null ? null : messagesToValue(updates.messages);
|
|
4203
|
-
if (updates.modelParameters) {
|
|
4204
|
-
const configKey = VARIANT_CONFIG_KEY[variant];
|
|
4205
|
-
const current = variant === currentVariant ? currentValues?.[configKey] : void 0;
|
|
4206
|
-
const merged = current?.kind === "object" ? { ...current.properties } : {};
|
|
4207
|
-
for (const [name, value] of Object.entries(updates.modelParameters)) if (value === null) delete merged[name];
|
|
4208
|
-
else merged[name] = value;
|
|
4209
|
-
if (Object.keys(merged).length > 0) out[configKey] = {
|
|
4210
|
-
kind: "object",
|
|
4211
|
-
properties: merged
|
|
4212
|
-
};
|
|
4213
|
-
else remove(configKey);
|
|
4214
|
-
}
|
|
4215
|
-
return out;
|
|
4216
|
-
}
|
|
4217
|
-
};
|
|
4218
|
-
/**
|
|
4219
|
-
* Convert a {@link NormalizedMessage} array into a PropValue representing the
|
|
4220
|
-
* `input` property: an array of [Step](https://ai.google.dev/api/interactions-api#Resource:Step)
|
|
4221
|
-
* objects (`{type: 'user_input' | 'model_output', content: [...]}`), each
|
|
4222
|
-
* carrying a single text [Content](https://ai.google.dev/api/interactions-api#schema-example-Content-text).
|
|
4223
|
-
*/
|
|
4224
|
-
function messagesToValue(msgs) {
|
|
4225
|
-
return {
|
|
4226
|
-
kind: "array",
|
|
4227
|
-
elements: msgs.map((msg) => ({
|
|
4228
|
-
kind: "object",
|
|
4229
|
-
properties: {
|
|
4230
|
-
type: {
|
|
4231
|
-
kind: "primitive",
|
|
4232
|
-
value: msg.role === "assistant" ? "model_output" : "user_input"
|
|
4233
|
-
},
|
|
4234
|
-
content: {
|
|
4235
|
-
kind: "array",
|
|
4236
|
-
elements: [{
|
|
4237
|
-
kind: "object",
|
|
4238
|
-
properties: {
|
|
4239
|
-
type: {
|
|
4240
|
-
kind: "primitive",
|
|
4241
|
-
value: "text"
|
|
4242
|
-
},
|
|
4243
|
-
text: msg.content
|
|
4244
|
-
}
|
|
4245
|
-
}]
|
|
4246
|
-
}
|
|
4247
|
-
}
|
|
4248
|
-
}))
|
|
4249
|
-
};
|
|
4250
|
-
}
|
|
4251
|
-
const EMPTY_CONTENT = {
|
|
4252
|
-
kind: "primitive",
|
|
4253
|
-
value: ""
|
|
4254
|
-
};
|
|
4255
|
-
function extractContent(el) {
|
|
4256
|
-
if (el?.kind !== "object" || el.properties.type?.kind !== "primitive") return;
|
|
4257
|
-
switch (el.properties.type.value) {
|
|
4258
|
-
case "text": return {
|
|
4259
|
-
role: "user",
|
|
4260
|
-
content: el.properties.text ?? EMPTY_CONTENT
|
|
4261
|
-
};
|
|
4262
|
-
}
|
|
4263
|
-
}
|
|
4264
|
-
/**
|
|
4265
|
-
* Extract a {@link NormalizedMessage} array from the `input` PropValue.
|
|
4266
|
-
*
|
|
4267
|
-
* The `input` field can be:
|
|
4268
|
-
* - A primitive string (single user message)
|
|
4269
|
-
* - A single content object (e.g. `{type: 'text', text: '...'}`)
|
|
4270
|
-
* - An array of Step objects (https://ai.google.dev/api/interactions-api#Resource:Step)
|
|
4271
|
-
* - An array of Content objects (https://ai.google.dev/api/interactions-api#schema-example-Content-text)
|
|
4272
|
-
*
|
|
4273
|
-
* The Interactions API uses `"model"` for assistant messages; we translate
|
|
4274
|
-
* `"model"` → `"assistant"` on the way in.
|
|
4275
|
-
*/
|
|
4276
|
-
function extractMessages(value) {
|
|
4277
|
-
if (!value) return [];
|
|
4278
|
-
const content = extractContent(value);
|
|
4279
|
-
if (content) return [content];
|
|
4280
|
-
if (value.kind !== "array") return [{
|
|
4281
|
-
role: "user",
|
|
4282
|
-
content: value
|
|
4283
|
-
}];
|
|
4284
|
-
const results = [];
|
|
4285
|
-
for (const el of value.elements) {
|
|
4286
|
-
const content = extractContent(el);
|
|
4287
|
-
if (content) {
|
|
4288
|
-
results.push(content);
|
|
4289
|
-
continue;
|
|
4290
|
-
}
|
|
4291
|
-
if (el.kind !== "object" || el.properties.type?.kind !== "primitive") continue;
|
|
4292
|
-
switch (el.properties.type.value) {
|
|
4293
|
-
case "user_input":
|
|
4294
|
-
results.push(...extractMessages(el.properties.content));
|
|
4295
|
-
break;
|
|
4296
|
-
case "model_output":
|
|
4297
|
-
for (const msg of extractMessages(el.properties.content)) results.push({
|
|
4298
|
-
...msg,
|
|
4299
|
-
role: "assistant"
|
|
4300
|
-
});
|
|
4301
|
-
break;
|
|
4302
|
-
}
|
|
4303
|
-
}
|
|
4304
|
-
return results;
|
|
4305
|
-
}
|
|
4306
|
-
//#endregion
|
|
4307
3959
|
//#region src/trace/memory-trace-provider.ts
|
|
4308
3960
|
/**
|
|
4309
3961
|
* In-memory {@link TraceProvider}, populated by one or more
|
|
@@ -4374,4 +4026,4 @@ var MemoryTraceProvider = class extends BaseTraceProvider {
|
|
|
4374
4026
|
}
|
|
4375
4027
|
};
|
|
4376
4028
|
//#endregion
|
|
4377
|
-
export { BaseTraceIngestor, BaseTraceProvider, CHECK_ATTRIBUTE, DEFAULT_EVAL_CONCURRENCY, DEFAULT_MAX_QUERY_ROWS, DEFAULT_PLAYGROUND_IGNORE_PATTERNS, DEFAULT_PLAYGROUND_INCLUDE_PATTERNS, DEFAULT_QUERY_TIMEOUT_MS, DEPLOYMENT_ENVIRONMENT_ATTRIBUTE, DatasetNotFoundError, DatasetValidationError, EvalNotFoundError, EvalRunRefusedError, EvalRunner,
|
|
4029
|
+
export { BaseTraceIngestor, BaseTraceProvider, CHECK_ATTRIBUTE, DEFAULT_EVAL_CONCURRENCY, DEFAULT_MAX_QUERY_ROWS, DEFAULT_PLAYGROUND_IGNORE_PATTERNS, DEFAULT_PLAYGROUND_INCLUDE_PATTERNS, DEFAULT_QUERY_TIMEOUT_MS, DEPLOYMENT_ENVIRONMENT_ATTRIBUTE, DatasetNotFoundError, DatasetValidationError, EvalNotFoundError, EvalRunRefusedError, EvalRunner, Evalution, FilePromptProvider, GitVersioning, HttpTraceSink, LocalDatabaseTraceProvider, LocalDirectoryDatasetProvider, LocalEvalProvider, LocalFileProvider, LocalVariationStore, MIGRATIONS_TABLE, MemoryFileProvider, MemoryTraceProvider, OTelTraceIngestor, OtlpTraceIngestor, OverlayFileProvider, PLAYGROUND_ENVIRONMENT, PLAYGROUND_RESOURCE, PROMPT_FIELD, PROMPT_ID_ATTRIBUTE, PROMPT_INPUTS_ATTRIBUTE, PROMPT_NAME_ATTRIBUTE, PROMPT_PROVIDER_ID_ATTRIBUTE, PROMPT_VARIATION_ATTRIBUTE, PROMPT_VERSION_ATTRIBUTE, ResourceRegistry, SERVICE_NAME_ATTRIBUTE, SPAN_KIND_ATTRIBUTE, SqlQueryError, TRACE_EVENTS_PATH, TRACE_QUERY_SCHEMA, TSPromptFileType, TraceEventIngestor, TursoDatasetProvider, TursoEvalProvider, TursoTraceProvider, TursoVariationStore, VariationConflictError, assertUpdateStyle, canonicalizeUpdates, check, collectInputSlots, createLocalTursoClient, createTracerForPrompt, decodeOtlpProtobuf, fieldValuesOf, findInputCycle, getPromptSpanAttributes, inputReferenceProblems, isCheck, isCheckSpan, isFreshImportHookRegistered, isResource, isStandardSchema, isValidInstanceName, isVariationLoaderHookRegistered, matchSourcesToSlots, mergeIntoWip, mergePromptIdentity, mergeSpans, mergeUpdates, namedBindings, normalizeOtlpRequest, openLocalEvalProvider, openLocalVariationStore, promptIdOf, rebaseUpdates, registerFreshImportHook, registerVariationLoaderHook, resolveConflicts, resolveExecutionInput, resolveExecutionInputs, resource, resourceParameterNames, runDatasetMigrations, runEvalMigrations, runMigrations, runVariationMigrations, serializeUpdates, setupGlobalOTelPipeline, spanMessages, stampReceipts, toPromptRef };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { i as DatasetRowsOverview, n as DatasetRow, r as DatasetRowUpdate, t as Dataset
|
|
1
|
+
import { i as DatasetRowsOverview, n as DatasetRow, r as DatasetRowUpdate, t as Dataset } from "./dataset-types-8cDpOFYi.js";
|
|
2
|
+
import { TraceWithSpans } from "@evalution/sdk";
|
|
2
3
|
|
|
3
4
|
//#region src/views/view.d.ts
|
|
4
5
|
/** What every view is given, whatever its surface. */
|