@runtypelabs/sdk 1.7.2 → 1.8.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.
Files changed (80) hide show
  1. package/dist/index.cjs +7254 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +5195 -0
  4. package/dist/index.d.ts +5194 -27
  5. package/dist/index.js +7182 -77
  6. package/dist/index.js.map +1 -1
  7. package/package.json +14 -7
  8. package/dist/batch-builder.d.ts +0 -106
  9. package/dist/batch-builder.d.ts.map +0 -1
  10. package/dist/batch-builder.js +0 -124
  11. package/dist/batch-builder.js.map +0 -1
  12. package/dist/batches-namespace.d.ts +0 -132
  13. package/dist/batches-namespace.d.ts.map +0 -1
  14. package/dist/batches-namespace.js +0 -128
  15. package/dist/batches-namespace.js.map +0 -1
  16. package/dist/case-types.d.ts +0 -42
  17. package/dist/case-types.d.ts.map +0 -1
  18. package/dist/case-types.js +0 -16
  19. package/dist/case-types.js.map +0 -1
  20. package/dist/client-token-types.d.ts +0 -143
  21. package/dist/client-token-types.d.ts.map +0 -1
  22. package/dist/client-token-types.js +0 -11
  23. package/dist/client-token-types.js.map +0 -1
  24. package/dist/client.d.ts +0 -135
  25. package/dist/client.d.ts.map +0 -1
  26. package/dist/client.js +0 -522
  27. package/dist/client.js.map +0 -1
  28. package/dist/endpoints.d.ts +0 -1353
  29. package/dist/endpoints.d.ts.map +0 -1
  30. package/dist/endpoints.js +0 -2936
  31. package/dist/endpoints.js.map +0 -1
  32. package/dist/error-handling-types.d.ts +0 -71
  33. package/dist/error-handling-types.d.ts.map +0 -1
  34. package/dist/error-handling-types.js +0 -12
  35. package/dist/error-handling-types.js.map +0 -1
  36. package/dist/eval-builder.d.ts +0 -216
  37. package/dist/eval-builder.d.ts.map +0 -1
  38. package/dist/eval-builder.js +0 -225
  39. package/dist/eval-builder.js.map +0 -1
  40. package/dist/evals-namespace.d.ts +0 -205
  41. package/dist/evals-namespace.d.ts.map +0 -1
  42. package/dist/evals-namespace.js +0 -208
  43. package/dist/evals-namespace.js.map +0 -1
  44. package/dist/flow-builder.d.ts +0 -717
  45. package/dist/flow-builder.d.ts.map +0 -1
  46. package/dist/flow-builder.js +0 -592
  47. package/dist/flow-builder.js.map +0 -1
  48. package/dist/flow-result.d.ts +0 -117
  49. package/dist/flow-result.d.ts.map +0 -1
  50. package/dist/flow-result.js +0 -175
  51. package/dist/flow-result.js.map +0 -1
  52. package/dist/flows-namespace.d.ts +0 -442
  53. package/dist/flows-namespace.d.ts.map +0 -1
  54. package/dist/flows-namespace.js +0 -686
  55. package/dist/flows-namespace.js.map +0 -1
  56. package/dist/generated-tool-gate.d.ts +0 -75
  57. package/dist/generated-tool-gate.d.ts.map +0 -1
  58. package/dist/generated-tool-gate.js +0 -314
  59. package/dist/generated-tool-gate.js.map +0 -1
  60. package/dist/index.d.ts.map +0 -1
  61. package/dist/prompts-namespace.d.ts +0 -237
  62. package/dist/prompts-namespace.d.ts.map +0 -1
  63. package/dist/prompts-namespace.js +0 -222
  64. package/dist/prompts-namespace.js.map +0 -1
  65. package/dist/runtype.d.ts +0 -232
  66. package/dist/runtype.d.ts.map +0 -1
  67. package/dist/runtype.js +0 -367
  68. package/dist/runtype.js.map +0 -1
  69. package/dist/stream-utils.d.ts +0 -58
  70. package/dist/stream-utils.d.ts.map +0 -1
  71. package/dist/stream-utils.js +0 -373
  72. package/dist/stream-utils.js.map +0 -1
  73. package/dist/transform.d.ts +0 -30
  74. package/dist/transform.d.ts.map +0 -1
  75. package/dist/transform.js +0 -196
  76. package/dist/transform.js.map +0 -1
  77. package/dist/types.d.ts +0 -717
  78. package/dist/types.d.ts.map +0 -1
  79. package/dist/types.js +0 -7
  80. package/dist/types.js.map +0 -1
@@ -1,225 +0,0 @@
1
- "use strict";
2
- /**
3
- * EvalBuilder - Fluent builder for evaluation runs
4
- *
5
- * Provides a chainable API for building evaluation configurations
6
- * that test flows against records with model overrides and comparisons.
7
- *
8
- * @example
9
- * ```typescript
10
- * import { EvalBuilder } from '@runtypelabs/sdk'
11
- *
12
- * // Single model eval with overrides
13
- * const eval1 = await new EvalBuilder()
14
- * .useFlow('flow_abc123')
15
- * .forRecordType('test_data')
16
- * .withModelOverrides([{ stepName: 'Analyze', model: 'gpt-4o' }])
17
- * .run(apiClient)
18
- *
19
- * // Multi-model comparison
20
- * const eval2 = await new EvalBuilder()
21
- * .useFlow('flow_abc123')
22
- * .forRecordType('test_data')
23
- * .compareModels([
24
- * { stepName: 'Analyze', model: 'gpt-4o' },
25
- * { stepName: 'Analyze', model: 'claude-3-opus' },
26
- * ])
27
- * .run(apiClient)
28
- *
29
- * // Virtual flow eval
30
- * const eval3 = await new EvalBuilder()
31
- * .useVirtualFlow(flowBuilder)
32
- * .forRecordType('test_data')
33
- * .run(apiClient)
34
- * ```
35
- */
36
- Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.ClientEvalBuilder = exports.EvalBuilder = void 0;
38
- // ============================================================================
39
- // EvalBuilder Class
40
- // ============================================================================
41
- class EvalBuilder {
42
- constructor() {
43
- this.evalOptions = {};
44
- }
45
- /**
46
- * Use an existing flow by ID for evaluation
47
- */
48
- useFlow(flowId) {
49
- this.flowId = flowId;
50
- this.virtualFlow = undefined;
51
- return this;
52
- }
53
- /**
54
- * Use a virtual flow (from FlowBuilder) for evaluation
55
- *
56
- * @example
57
- * ```typescript
58
- * const flowBuilder = new FlowBuilder()
59
- * .createFlow({ name: 'Test Flow' })
60
- * .prompt({ name: 'Analyze', model: 'gpt-4', userPrompt: '...' })
61
- *
62
- * const eval = await new EvalBuilder()
63
- * .useVirtualFlow(flowBuilder)
64
- * .forRecordType('test_data')
65
- * .run(apiClient)
66
- * ```
67
- */
68
- useVirtualFlow(builder) {
69
- const config = builder.build();
70
- if (config.flow && 'name' in config.flow && 'steps' in config.flow) {
71
- this.virtualFlow = {
72
- name: config.flow.name,
73
- steps: config.flow.steps,
74
- };
75
- }
76
- this.flowId = undefined;
77
- return this;
78
- }
79
- /**
80
- * Specify the record type to evaluate against
81
- */
82
- forRecordType(recordType) {
83
- this.recordType = recordType;
84
- this.inlineRecords = undefined;
85
- return this;
86
- }
87
- /**
88
- * Use inline records for ad-hoc evaluation (no record type lookup)
89
- *
90
- * @example
91
- * ```typescript
92
- * .withRecords([
93
- * { name: 'Test 1', type: 'test', metadata: { input: 'hello' } },
94
- * { name: 'Test 2', type: 'test', metadata: { input: 'world' } },
95
- * ])
96
- * ```
97
- */
98
- withRecords(records) {
99
- this.inlineRecords = records;
100
- this.recordType = undefined;
101
- return this;
102
- }
103
- /**
104
- * Set model overrides for single-model evaluation
105
- *
106
- * @example
107
- * ```typescript
108
- * .withModelOverrides([
109
- * { stepName: 'Analyze', model: 'gpt-4o', temperature: 0.2 }
110
- * ])
111
- * ```
112
- */
113
- withModelOverrides(overrides) {
114
- this.modelOverrides = overrides;
115
- this.modelConfigs = undefined;
116
- return this;
117
- }
118
- /**
119
- * Compare multiple model configurations
120
- *
121
- * @example
122
- * ```typescript
123
- * .compareModels([
124
- * [{ stepName: 'Analyze', model: 'gpt-4o' }],
125
- * [{ stepName: 'Analyze', model: 'claude-3-opus' }],
126
- * [{ stepName: 'Analyze', model: 'gemini-pro' }],
127
- * ])
128
- * ```
129
- */
130
- compareModels(configs) {
131
- this.modelConfigs = configs;
132
- this.modelOverrides = undefined;
133
- return this;
134
- }
135
- /**
136
- * Set evaluation options
137
- */
138
- withOptions(options) {
139
- this.evalOptions = { ...this.evalOptions, ...options };
140
- return this;
141
- }
142
- /**
143
- * Filter records to evaluate
144
- */
145
- withFilter(filter) {
146
- this.filterConfig = filter;
147
- return this;
148
- }
149
- /**
150
- * Limit the number of records to evaluate
151
- */
152
- withLimit(limit) {
153
- this.limitConfig = limit;
154
- return this;
155
- }
156
- /**
157
- * Build the eval request configuration
158
- */
159
- build() {
160
- if (!this.flowId && !this.virtualFlow) {
161
- throw new Error('EvalBuilder: flow is required. Call .useFlow(id) or .useVirtualFlow(builder) first.');
162
- }
163
- if (!this.recordType && !this.inlineRecords) {
164
- throw new Error('EvalBuilder: records are required. Call .forRecordType(type) or .withRecords([...]) first.');
165
- }
166
- const request = {};
167
- if (this.flowId) {
168
- request.flowId = this.flowId;
169
- }
170
- else if (this.virtualFlow) {
171
- request.flow = this.virtualFlow;
172
- }
173
- if (this.recordType) {
174
- request.recordType = this.recordType;
175
- }
176
- else if (this.inlineRecords) {
177
- request.records = this.inlineRecords;
178
- }
179
- if (this.modelOverrides) {
180
- request.modelOverrides = this.modelOverrides;
181
- }
182
- else if (this.modelConfigs) {
183
- request.modelConfigs = this.modelConfigs;
184
- }
185
- if (Object.keys(this.evalOptions).length > 0) {
186
- request.options = this.evalOptions;
187
- }
188
- if (this.filterConfig) {
189
- request.filter = this.filterConfig;
190
- }
191
- if (this.limitConfig !== undefined) {
192
- request.limit = this.limitConfig;
193
- }
194
- return request;
195
- }
196
- /**
197
- * Execute the evaluation
198
- *
199
- * @param client - Client with eval capability
200
- * @returns EvalResult with evaluation status and results
201
- */
202
- async run(client) {
203
- const config = this.build();
204
- return client.eval(config);
205
- }
206
- }
207
- exports.EvalBuilder = EvalBuilder;
208
- /**
209
- * EvalBuilder that is bound to a client for direct execution
210
- */
211
- class ClientEvalBuilder extends EvalBuilder {
212
- constructor(client) {
213
- super();
214
- this.boundClient = client;
215
- }
216
- /**
217
- * Execute the evaluation using the bound client
218
- */
219
- async run() {
220
- const config = this.build();
221
- return this.boundClient.eval(config);
222
- }
223
- }
224
- exports.ClientEvalBuilder = ClientEvalBuilder;
225
- //# sourceMappingURL=eval-builder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"eval-builder.js","sourceRoot":"","sources":["../src/eval-builder.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;;;AAkFH,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E,MAAa,WAAW;IAAxB;QAOU,gBAAW,GAAgB,EAAE,CAAA;IAwLvC,CAAC;IAp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AC;YACxB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAA;QAC9C,CAAC;aAAM,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YAC7B,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAA;QAC1C,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7C,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,WAAW,CAAA;QACpC,CAAC;QAED,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,CAAA;QACpC,CAAC;QAED,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YACnC,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,WAAW,CAAA;QAClC,CAAC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CAAC,MAAkB;QAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,CAAA;QAC3B,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC5B,CAAC;CACF;AA/LD,kCA+LC;AAaD;;GAEG;AACH,MAAa,iBAAkB,SAAQ,WAAW;IAGhD,YAAY,MAAkB;QAC5B,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,WAAW,GAAG,MAAM,CAAA;IAC3B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG;QACP,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,CAAA;QAC3B,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACtC,CAAC;CACF;AAfD,8CAeC"}
@@ -1,205 +0,0 @@
1
- /**
2
- * EvalsNamespace - Static namespace for evaluation operations
3
- *
4
- * Provides methods for running evaluations and comparing model performance.
5
- * Evals can be streamed for real-time results or submitted as batch jobs.
6
- */
7
- import type { RuntypeClient } from './runtype';
8
- import { FlowResult } from './flow-result';
9
- import type { StreamCallbacks } from './flow-builder';
10
- export interface ModelOverride {
11
- /** Name of the step to override */
12
- stepName: string;
13
- /** Model to use for this step */
14
- model: string;
15
- /** Optional temperature override */
16
- temperature?: number;
17
- /** Optional max tokens override */
18
- maxTokens?: number;
19
- }
20
- export interface EvalRunConfig {
21
- /** Flow ID to evaluate */
22
- flowId?: string;
23
- /** Virtual flow definition (alternative to flowId) */
24
- flow?: {
25
- name: string;
26
- steps: any[];
27
- };
28
- /** Record type to evaluate against */
29
- recordType?: string;
30
- /** Inline records for ad-hoc evaluation */
31
- records?: Array<{
32
- name: string;
33
- type: string;
34
- metadata: Record<string, any>;
35
- }>;
36
- /** Model overrides for single-model evaluation */
37
- models?: ModelOverride[];
38
- /** Multiple model configurations for comparison */
39
- compareModels?: ModelOverride[][];
40
- /** Store evaluation results */
41
- storeResults?: boolean;
42
- /** Run evaluations in parallel */
43
- parallel?: boolean;
44
- /** Maximum concurrent evaluations */
45
- concurrency?: number;
46
- /** Continue on individual record failures */
47
- continueOnError?: boolean;
48
- /** Optional filter for records */
49
- filter?: Record<string, any>;
50
- /** Optional limit on number of records */
51
- limit?: number;
52
- }
53
- export interface EvalStatus {
54
- evalId: string;
55
- status: 'queued' | 'running' | 'completed' | 'failed';
56
- totalRecords: number;
57
- completedRecords: number;
58
- failedRecords: number;
59
- results?: Array<{
60
- modelConfig: ModelOverride[];
61
- records: Array<{
62
- recordId: string;
63
- status: 'success' | 'error';
64
- result?: any;
65
- error?: string;
66
- executionTime: number;
67
- }>;
68
- }>;
69
- }
70
- export interface EvalListParams {
71
- /** Filter by status */
72
- status?: 'queued' | 'running' | 'completed' | 'failed';
73
- /** Filter by flow ID */
74
- flowId?: string;
75
- /** Pagination limit */
76
- limit?: number;
77
- /** Pagination offset */
78
- offset?: number;
79
- }
80
- /**
81
- * EvalRunner - Builder returned by Runtype.evals.run()
82
- *
83
- * Provides terminal methods for executing evaluations:
84
- * - .stream() - Execute and stream results in real-time
85
- * - .submit() - Submit as a batch job for async processing
86
- */
87
- export declare class EvalRunner {
88
- private getClient;
89
- private config;
90
- constructor(getClient: () => RuntypeClient, config: EvalRunConfig);
91
- /**
92
- * Execute the evaluation with streaming results
93
- *
94
- * Streams evaluation results as they complete.
95
- * Good for real-time feedback during development/testing.
96
- *
97
- * @example
98
- * ```typescript
99
- * const result = await Runtype.evals.run({
100
- * flowId: 'flow_123',
101
- * recordType: 'test_data',
102
- * models: [{ stepName: 'Analyze', model: 'gpt-4o' }]
103
- * }).stream()
104
- *
105
- * // Process with callbacks
106
- * await result.stream({
107
- * onStepComplete: (result, event) => {
108
- * console.log('Step completed:', event.name, result)
109
- * },
110
- * })
111
- * ```
112
- */
113
- stream(callbacks?: StreamCallbacks): Promise<FlowResult>;
114
- /**
115
- * Submit the evaluation as a batch job
116
- *
117
- * Queues the evaluation to run asynchronously.
118
- * Good for large evaluations or scheduled runs.
119
- *
120
- * @example
121
- * ```typescript
122
- * const eval = await Runtype.evals.run({
123
- * flowId: 'flow_123',
124
- * recordType: 'test_data',
125
- * compareModels: [
126
- * [{ stepName: 'Analyze', model: 'gpt-4o' }],
127
- * [{ stepName: 'Analyze', model: 'claude-3-opus' }],
128
- * ]
129
- * }).submit()
130
- *
131
- * console.log('Eval queued:', eval.evalId)
132
- *
133
- * // Check status later
134
- * const status = await Runtype.evals.get(eval.evalId)
135
- * ```
136
- */
137
- submit(): Promise<EvalStatus>;
138
- /**
139
- * Build the evaluation payload
140
- */
141
- private buildPayload;
142
- }
143
- export declare class EvalsNamespace {
144
- private getClient;
145
- constructor(getClient: () => RuntypeClient);
146
- /**
147
- * Run an evaluation
148
- *
149
- * Returns an EvalRunner with terminal methods:
150
- * - .stream() - Execute and stream results
151
- * - .submit() - Submit as batch job
152
- *
153
- * @example
154
- * ```typescript
155
- * // Single model evaluation with streaming
156
- * const result = await Runtype.evals.run({
157
- * flowId: 'flow_123',
158
- * recordType: 'test_data',
159
- * models: [{ stepName: 'Analyze', model: 'gpt-4o' }]
160
- * }).stream()
161
- *
162
- * // Multi-model comparison as batch
163
- * const eval = await Runtype.evals.run({
164
- * flowId: 'flow_123',
165
- * recordType: 'test_data',
166
- * compareModels: [
167
- * [{ stepName: 'Analyze', model: 'gpt-4o' }],
168
- * [{ stepName: 'Analyze', model: 'claude-3-opus' }],
169
- * [{ stepName: 'Analyze', model: 'gemini-pro' }],
170
- * ]
171
- * }).submit()
172
- * ```
173
- */
174
- run(config: EvalRunConfig): EvalRunner;
175
- /**
176
- * Get evaluation status by ID
177
- *
178
- * @example
179
- * ```typescript
180
- * const status = await Runtype.evals.get('eval_123')
181
- * console.log(status.status, status.completedRecords, '/', status.totalRecords)
182
- * ```
183
- */
184
- get(evalId: string): Promise<EvalStatus>;
185
- /**
186
- * List evaluations
187
- *
188
- * @example
189
- * ```typescript
190
- * // List all evals
191
- * const evals = await Runtype.evals.list()
192
- *
193
- * // Filter by status
194
- * const running = await Runtype.evals.list({ status: 'running' })
195
- *
196
- * // Filter by flow
197
- * const flowEvals = await Runtype.evals.list({ flowId: 'flow_123' })
198
- * ```
199
- */
200
- list(params?: EvalListParams): Promise<{
201
- data: EvalStatus[];
202
- total: number;
203
- }>;
204
- }
205
- //# sourceMappingURL=evals-namespace.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"evals-namespace.d.ts","sourceRoot":"","sources":["../src/evals-namespace.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,gBAAgB,CAAA;AAMlE,MAAM,WAAW,aAAa;IAC5B,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAA;IAChB,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAA;I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C,MAAM,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,UAAU,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAIpF"}
@@ -1,208 +0,0 @@
1
- "use strict";
2
- /**
3
- * EvalsNamespace - Static namespace for evaluation operations
4
- *
5
- * Provides methods for running evaluations and comparing model performance.
6
- * Evals can be streamed for real-time results or submitted as batch jobs.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.EvalsNamespace = exports.EvalRunner = void 0;
10
- const flow_result_1 = require("./flow-result");
11
- // ============================================================================
12
- // EvalRunner
13
- // ============================================================================
14
- /**
15
- * EvalRunner - Builder returned by Runtype.evals.run()
16
- *
17
- * Provides terminal methods for executing evaluations:
18
- * - .stream() - Execute and stream results in real-time
19
- * - .submit() - Submit as a batch job for async processing
20
- */
21
- class EvalRunner {
22
- constructor(getClient, config) {
23
- this.getClient = getClient;
24
- this.config = config;
25
- }
26
- /**
27
- * Execute the evaluation with streaming results
28
- *
29
- * Streams evaluation results as they complete.
30
- * Good for real-time feedback during development/testing.
31
- *
32
- * @example
33
- * ```typescript
34
- * const result = await Runtype.evals.run({
35
- * flowId: 'flow_123',
36
- * recordType: 'test_data',
37
- * models: [{ stepName: 'Analyze', model: 'gpt-4o' }]
38
- * }).stream()
39
- *
40
- * // Process with callbacks
41
- * await result.stream({
42
- * onStepComplete: (result, event) => {
43
- * console.log('Step completed:', event.name, result)
44
- * },
45
- * })
46
- * ```
47
- */
48
- async stream(callbacks) {
49
- const client = this.getClient();
50
- const payload = this.buildPayload();
51
- payload.stream = true;
52
- const response = await client.requestStream('/eval/stream', {
53
- method: 'POST',
54
- body: JSON.stringify(payload),
55
- });
56
- const result = new flow_result_1.FlowResult(response);
57
- if (callbacks) {
58
- await result.stream(callbacks);
59
- }
60
- return result;
61
- }
62
- /**
63
- * Submit the evaluation as a batch job
64
- *
65
- * Queues the evaluation to run asynchronously.
66
- * Good for large evaluations or scheduled runs.
67
- *
68
- * @example
69
- * ```typescript
70
- * const eval = await Runtype.evals.run({
71
- * flowId: 'flow_123',
72
- * recordType: 'test_data',
73
- * compareModels: [
74
- * [{ stepName: 'Analyze', model: 'gpt-4o' }],
75
- * [{ stepName: 'Analyze', model: 'claude-3-opus' }],
76
- * ]
77
- * }).submit()
78
- *
79
- * console.log('Eval queued:', eval.evalId)
80
- *
81
- * // Check status later
82
- * const status = await Runtype.evals.get(eval.evalId)
83
- * ```
84
- */
85
- async submit() {
86
- const client = this.getClient();
87
- const payload = this.buildPayload();
88
- payload.async = true;
89
- return client.post('/evals', payload);
90
- }
91
- /**
92
- * Build the evaluation payload
93
- */
94
- buildPayload() {
95
- const payload = {};
96
- if (this.config.flowId) {
97
- payload.flowId = this.config.flowId;
98
- }
99
- else if (this.config.flow) {
100
- payload.flow = this.config.flow;
101
- }
102
- if (this.config.recordType) {
103
- payload.recordType = this.config.recordType;
104
- }
105
- else if (this.config.records) {
106
- payload.records = this.config.records;
107
- }
108
- if (this.config.models) {
109
- payload.modelOverrides = this.config.models;
110
- }
111
- else if (this.config.compareModels) {
112
- payload.modelConfigs = this.config.compareModels;
113
- }
114
- const options = {};
115
- if (this.config.storeResults !== undefined)
116
- options.storeResults = this.config.storeResults;
117
- if (this.config.parallel !== undefined)
118
- options.parallel = this.config.parallel;
119
- if (this.config.concurrency !== undefined)
120
- options.concurrency = this.config.concurrency;
121
- if (this.config.continueOnError !== undefined)
122
- options.continueOnError = this.config.continueOnError;
123
- if (Object.keys(options).length > 0) {
124
- payload.options = options;
125
- }
126
- if (this.config.filter) {
127
- payload.filter = this.config.filter;
128
- }
129
- if (this.config.limit !== undefined) {
130
- payload.limit = this.config.limit;
131
- }
132
- return payload;
133
- }
134
- }
135
- exports.EvalRunner = EvalRunner;
136
- // ============================================================================
137
- // EvalsNamespace
138
- // ============================================================================
139
- class EvalsNamespace {
140
- constructor(getClient) {
141
- this.getClient = getClient;
142
- }
143
- /**
144
- * Run an evaluation
145
- *
146
- * Returns an EvalRunner with terminal methods:
147
- * - .stream() - Execute and stream results
148
- * - .submit() - Submit as batch job
149
- *
150
- * @example
151
- * ```typescript
152
- * // Single model evaluation with streaming
153
- * const result = await Runtype.evals.run({
154
- * flowId: 'flow_123',
155
- * recordType: 'test_data',
156
- * models: [{ stepName: 'Analyze', model: 'gpt-4o' }]
157
- * }).stream()
158
- *
159
- * // Multi-model comparison as batch
160
- * const eval = await Runtype.evals.run({
161
- * flowId: 'flow_123',
162
- * recordType: 'test_data',
163
- * compareModels: [
164
- * [{ stepName: 'Analyze', model: 'gpt-4o' }],
165
- * [{ stepName: 'Analyze', model: 'claude-3-opus' }],
166
- * [{ stepName: 'Analyze', model: 'gemini-pro' }],
167
- * ]
168
- * }).submit()
169
- * ```
170
- */
171
- run(config) {
172
- return new EvalRunner(this.getClient, config);
173
- }
174
- /**
175
- * Get evaluation status by ID
176
- *
177
- * @example
178
- * ```typescript
179
- * const status = await Runtype.evals.get('eval_123')
180
- * console.log(status.status, status.completedRecords, '/', status.totalRecords)
181
- * ```
182
- */
183
- async get(evalId) {
184
- const client = this.getClient();
185
- return client.get(`/evals/${evalId}`);
186
- }
187
- /**
188
- * List evaluations
189
- *
190
- * @example
191
- * ```typescript
192
- * // List all evals
193
- * const evals = await Runtype.evals.list()
194
- *
195
- * // Filter by status
196
- * const running = await Runtype.evals.list({ status: 'running' })
197
- *
198
- * // Filter by flow
199
- * const flowEvals = await Runtype.evals.list({ flowId: 'flow_123' })
200
- * ```
201
- */
202
- async list(params) {
203
- const client = this.getClient();
204
- return client.get('/evals', params);
205
- }
206
- }
207
- exports.EvalsNamespace = EvalsNamespace;
208
- //# sourceMappingURL=evals-namespace.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"evals-namespace.js","sourceRoot":"","sources":["../src/evals-namespace.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,+CAA0C;AAiF1C,+EAA+E;AAC/E,aAAa;AACb,+EAA+E;AAE/E;;;;;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