tracia 0.3.2 → 0.3.4
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/README.md +9 -1
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +26 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,15 @@ TypeScript SDK for [Tracia](https://tracia.io) - store, test, and trace LLM prom
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install tracia
|
|
8
|
+
npm install tracia ai
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
When using `runLocal()` or `runResponses()`, install the provider for your model:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @ai-sdk/openai # for GPT, o1, o3, etc.
|
|
15
|
+
npm install @ai-sdk/anthropic # for Claude
|
|
16
|
+
npm install @ai-sdk/google # for Gemini
|
|
9
17
|
```
|
|
10
18
|
|
|
11
19
|
## Quick Start
|
package/dist/index.d.mts
CHANGED
|
@@ -267,8 +267,8 @@ interface RunLocalInput {
|
|
|
267
267
|
stopSequences?: string[];
|
|
268
268
|
/** Timeout in milliseconds for the LLM call */
|
|
269
269
|
timeoutMs?: number;
|
|
270
|
-
/** Provider-specific options passed directly to the SDK */
|
|
271
|
-
customOptions?: Record<string, unknown
|
|
270
|
+
/** Provider-specific options passed directly to the AI SDK (e.g., { openai: { strictJsonSchema: true } }) */
|
|
271
|
+
customOptions?: Record<string, Record<string, unknown>>;
|
|
272
272
|
variables?: Record<string, string>;
|
|
273
273
|
providerApiKey?: string;
|
|
274
274
|
tags?: string[];
|
|
@@ -466,6 +466,8 @@ interface RunResponsesInput {
|
|
|
466
466
|
traceId?: string;
|
|
467
467
|
/** Parent span ID for chaining spans in a sequence */
|
|
468
468
|
parentSpanId?: string;
|
|
469
|
+
/** Provider-specific options passed directly to the AI SDK (e.g., { openai: { strictJsonSchema: true } }) */
|
|
470
|
+
customOptions?: Record<string, Record<string, unknown>>;
|
|
469
471
|
}
|
|
470
472
|
/**
|
|
471
473
|
* Final result from a Responses API call.
|
package/dist/index.d.ts
CHANGED
|
@@ -267,8 +267,8 @@ interface RunLocalInput {
|
|
|
267
267
|
stopSequences?: string[];
|
|
268
268
|
/** Timeout in milliseconds for the LLM call */
|
|
269
269
|
timeoutMs?: number;
|
|
270
|
-
/** Provider-specific options passed directly to the SDK */
|
|
271
|
-
customOptions?: Record<string, unknown
|
|
270
|
+
/** Provider-specific options passed directly to the AI SDK (e.g., { openai: { strictJsonSchema: true } }) */
|
|
271
|
+
customOptions?: Record<string, Record<string, unknown>>;
|
|
272
272
|
variables?: Record<string, string>;
|
|
273
273
|
providerApiKey?: string;
|
|
274
274
|
tags?: string[];
|
|
@@ -466,6 +466,8 @@ interface RunResponsesInput {
|
|
|
466
466
|
traceId?: string;
|
|
467
467
|
/** Parent span ID for chaining spans in a sequence */
|
|
468
468
|
parentSpanId?: string;
|
|
469
|
+
/** Provider-specific options passed directly to the AI SDK (e.g., { openai: { strictJsonSchema: true } }) */
|
|
470
|
+
customOptions?: Record<string, Record<string, unknown>>;
|
|
469
471
|
}
|
|
470
472
|
/**
|
|
471
473
|
* Final result from a Responses API call.
|
package/dist/index.js
CHANGED
|
@@ -76,7 +76,7 @@ var LLMProvider = /* @__PURE__ */ ((LLMProvider2) => {
|
|
|
76
76
|
})(LLMProvider || {});
|
|
77
77
|
|
|
78
78
|
// src/client.ts
|
|
79
|
-
var SDK_VERSION = "0.3.
|
|
79
|
+
var SDK_VERSION = "0.3.4";
|
|
80
80
|
var DEFAULT_TIMEOUT_MS = 12e4;
|
|
81
81
|
function mapApiErrorCodeToTraciaErrorCode(apiCode) {
|
|
82
82
|
const codeMap = {
|
|
@@ -484,12 +484,13 @@ async function convertTools(tools) {
|
|
|
484
484
|
const { tool, jsonSchema } = await loadAISdk();
|
|
485
485
|
const result = {};
|
|
486
486
|
for (const toolDef of tools) {
|
|
487
|
-
|
|
487
|
+
const t = tool({
|
|
488
488
|
description: toolDef.description,
|
|
489
489
|
inputSchema: jsonSchema(toolDef.parameters),
|
|
490
490
|
execute: async (args) => args
|
|
491
|
-
// No-op execute function
|
|
492
491
|
});
|
|
492
|
+
t.strict = false;
|
|
493
|
+
result[toolDef.name] = t;
|
|
493
494
|
}
|
|
494
495
|
return result;
|
|
495
496
|
}
|
|
@@ -513,6 +514,17 @@ function extractToolCalls(toolCalls) {
|
|
|
513
514
|
arguments: tc.input ?? {}
|
|
514
515
|
}));
|
|
515
516
|
}
|
|
517
|
+
function mergeProviderOptions(userOptions) {
|
|
518
|
+
const defaults = {
|
|
519
|
+
openai: { strictJsonSchema: false }
|
|
520
|
+
};
|
|
521
|
+
if (!userOptions) return defaults;
|
|
522
|
+
const merged = { ...defaults };
|
|
523
|
+
for (const [provider, options] of Object.entries(userOptions)) {
|
|
524
|
+
merged[provider] = { ...merged[provider], ...options };
|
|
525
|
+
}
|
|
526
|
+
return merged;
|
|
527
|
+
}
|
|
516
528
|
async function complete(options) {
|
|
517
529
|
const { generateText } = await loadAISdk();
|
|
518
530
|
const provider = resolveProvider(options.model, options.provider);
|
|
@@ -531,7 +543,8 @@ async function complete(options) {
|
|
|
531
543
|
stopSequences: options.stopSequences,
|
|
532
544
|
tools: convertedTools,
|
|
533
545
|
toolChoice: convertedToolChoice,
|
|
534
|
-
abortSignal: options.timeoutMs ? AbortSignal.timeout(options.timeoutMs) : void 0
|
|
546
|
+
abortSignal: options.timeoutMs ? AbortSignal.timeout(options.timeoutMs) : void 0,
|
|
547
|
+
providerOptions: mergeProviderOptions(options.providerOptions)
|
|
535
548
|
});
|
|
536
549
|
const toolCalls = extractToolCalls(result.toolCalls);
|
|
537
550
|
return {
|
|
@@ -578,7 +591,8 @@ function stream(options) {
|
|
|
578
591
|
stopSequences: options.stopSequences,
|
|
579
592
|
tools: convertedTools,
|
|
580
593
|
toolChoice: convertedToolChoice,
|
|
581
|
-
abortSignal
|
|
594
|
+
abortSignal,
|
|
595
|
+
providerOptions: mergeProviderOptions(options.providerOptions)
|
|
582
596
|
});
|
|
583
597
|
for await (const chunk of result.textStream) {
|
|
584
598
|
yield chunk;
|
|
@@ -683,7 +697,8 @@ function responsesStream(options) {
|
|
|
683
697
|
messages: convertedMessages,
|
|
684
698
|
maxOutputTokens: options.maxOutputTokens,
|
|
685
699
|
tools: convertedTools,
|
|
686
|
-
abortSignal
|
|
700
|
+
abortSignal,
|
|
701
|
+
providerOptions: mergeProviderOptions(options.providerOptions)
|
|
687
702
|
});
|
|
688
703
|
for await (const chunk of result.textStream) {
|
|
689
704
|
fullText += chunk;
|
|
@@ -1066,6 +1081,7 @@ var Tracia = class {
|
|
|
1066
1081
|
stopSequences: input.stopSequences,
|
|
1067
1082
|
tools: input.tools,
|
|
1068
1083
|
toolChoice: input.toolChoice,
|
|
1084
|
+
providerOptions: input.customOptions,
|
|
1069
1085
|
timeoutMs: input.timeoutMs
|
|
1070
1086
|
});
|
|
1071
1087
|
} catch (error) {
|
|
@@ -1224,7 +1240,8 @@ var Tracia = class {
|
|
|
1224
1240
|
tools: input.tools,
|
|
1225
1241
|
maxOutputTokens: input.maxOutputTokens,
|
|
1226
1242
|
timeoutMs: input.timeoutMs,
|
|
1227
|
-
signal
|
|
1243
|
+
signal,
|
|
1244
|
+
providerOptions: input.customOptions
|
|
1228
1245
|
});
|
|
1229
1246
|
let collectedText = "";
|
|
1230
1247
|
const scheduleSpan = this.scheduleSpanCreation.bind(this);
|
|
@@ -1354,7 +1371,8 @@ var Tracia = class {
|
|
|
1354
1371
|
tools: input.tools,
|
|
1355
1372
|
toolChoice: input.toolChoice,
|
|
1356
1373
|
timeoutMs: input.timeoutMs,
|
|
1357
|
-
signal
|
|
1374
|
+
signal,
|
|
1375
|
+
providerOptions: input.customOptions
|
|
1358
1376
|
});
|
|
1359
1377
|
let collectedText = "";
|
|
1360
1378
|
const scheduleSpan = this.scheduleSpanCreation.bind(this);
|