@fallom/trace 0.1.5 → 0.1.10
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 +3 -1
- package/dist/chunk-6MSTRIK4.mjs +255 -0
- package/dist/chunk-H2EACSBT.mjs +255 -0
- package/dist/index.d.mts +53 -5
- package/dist/index.d.ts +53 -5
- package/dist/index.js +614 -30
- package/dist/index.mjs +609 -32
- package/dist/prompts-VAN5E3L4.mjs +14 -0
- package/dist/prompts-ZSLS4DHO.mjs +14 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -183,6 +183,45 @@ declare function wrapAnthropic<T extends {
|
|
|
183
183
|
declare function wrapGoogleAI<T extends {
|
|
184
184
|
generateContent: (...args: any[]) => Promise<any>;
|
|
185
185
|
}>(model: T): T;
|
|
186
|
+
/**
|
|
187
|
+
* Wrap the Vercel AI SDK to automatically trace all LLM calls.
|
|
188
|
+
* Works with generateText, streamText, generateObject, streamObject.
|
|
189
|
+
*
|
|
190
|
+
* @param ai - The ai module (import * as ai from "ai")
|
|
191
|
+
* @returns Object with wrapped generateText, streamText, generateObject, streamObject
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```typescript
|
|
195
|
+
* import * as ai from "ai";
|
|
196
|
+
* import { createOpenAI } from "@ai-sdk/openai";
|
|
197
|
+
* import { trace } from "@fallom/trace";
|
|
198
|
+
*
|
|
199
|
+
* await trace.init({ apiKey: process.env.FALLOM_API_KEY });
|
|
200
|
+
* const { generateText, streamText } = trace.wrapAISDK(ai);
|
|
201
|
+
*
|
|
202
|
+
* const openrouter = createOpenAI({
|
|
203
|
+
* apiKey: process.env.OPENROUTER_API_KEY,
|
|
204
|
+
* baseURL: "https://openrouter.ai/api/v1",
|
|
205
|
+
* });
|
|
206
|
+
*
|
|
207
|
+
* trace.setSession("my-config", sessionId);
|
|
208
|
+
* const { text } = await generateText({
|
|
209
|
+
* model: openrouter("openai/gpt-4o-mini"),
|
|
210
|
+
* prompt: "Hello!",
|
|
211
|
+
* }); // Automatically traced!
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
declare function wrapAISDK<T extends {
|
|
215
|
+
generateText: (...args: any[]) => Promise<any>;
|
|
216
|
+
streamText: (...args: any[]) => any;
|
|
217
|
+
generateObject?: (...args: any[]) => Promise<any>;
|
|
218
|
+
streamObject?: (...args: any[]) => any;
|
|
219
|
+
}>(ai: T): {
|
|
220
|
+
generateText: T["generateText"];
|
|
221
|
+
streamText: T["streamText"];
|
|
222
|
+
generateObject: T["generateObject"];
|
|
223
|
+
streamObject: T["streamObject"];
|
|
224
|
+
};
|
|
186
225
|
|
|
187
226
|
declare const trace_clearSession: typeof clearSession;
|
|
188
227
|
declare const trace_getSession: typeof getSession;
|
|
@@ -190,11 +229,12 @@ declare const trace_runWithSession: typeof runWithSession;
|
|
|
190
229
|
declare const trace_setSession: typeof setSession;
|
|
191
230
|
declare const trace_shutdown: typeof shutdown;
|
|
192
231
|
declare const trace_span: typeof span;
|
|
232
|
+
declare const trace_wrapAISDK: typeof wrapAISDK;
|
|
193
233
|
declare const trace_wrapAnthropic: typeof wrapAnthropic;
|
|
194
234
|
declare const trace_wrapGoogleAI: typeof wrapGoogleAI;
|
|
195
235
|
declare const trace_wrapOpenAI: typeof wrapOpenAI;
|
|
196
236
|
declare namespace trace {
|
|
197
|
-
export { trace_clearSession as clearSession, trace_getSession as getSession, init$3 as init, trace_runWithSession as runWithSession, trace_setSession as setSession, trace_shutdown as shutdown, trace_span as span, trace_wrapAnthropic as wrapAnthropic, trace_wrapGoogleAI as wrapGoogleAI, trace_wrapOpenAI as wrapOpenAI };
|
|
237
|
+
export { trace_clearSession as clearSession, trace_getSession as getSession, init$3 as init, trace_runWithSession as runWithSession, trace_setSession as setSession, trace_shutdown as shutdown, trace_span as span, trace_wrapAISDK as wrapAISDK, trace_wrapAnthropic as wrapAnthropic, trace_wrapGoogleAI as wrapGoogleAI, trace_wrapOpenAI as wrapOpenAI };
|
|
198
238
|
}
|
|
199
239
|
|
|
200
240
|
/**
|
|
@@ -368,16 +408,20 @@ declare namespace prompts {
|
|
|
368
408
|
*/
|
|
369
409
|
interface InitOptions {
|
|
370
410
|
apiKey?: string;
|
|
371
|
-
|
|
411
|
+
tracesUrl?: string;
|
|
412
|
+
configsUrl?: string;
|
|
413
|
+
promptsUrl?: string;
|
|
372
414
|
captureContent?: boolean;
|
|
373
415
|
debug?: boolean;
|
|
374
416
|
}
|
|
375
417
|
/**
|
|
376
|
-
* Initialize
|
|
418
|
+
* Initialize trace, models, and prompts at once.
|
|
377
419
|
*
|
|
378
420
|
* @param options - Configuration options
|
|
379
421
|
* @param options.apiKey - Your Fallom API key. Defaults to FALLOM_API_KEY env var.
|
|
380
|
-
* @param options.
|
|
422
|
+
* @param options.tracesUrl - Traces API URL. Defaults to FALLOM_TRACES_URL or https://traces.fallom.com
|
|
423
|
+
* @param options.configsUrl - Configs API URL. Defaults to FALLOM_CONFIGS_URL or https://configs.fallom.com
|
|
424
|
+
* @param options.promptsUrl - Prompts API URL. Defaults to FALLOM_PROMPTS_URL or https://prompts.fallom.com
|
|
381
425
|
* @param options.captureContent - Whether to capture prompt/completion content (default: true)
|
|
382
426
|
*
|
|
383
427
|
* @example
|
|
@@ -388,7 +432,11 @@ interface InitOptions {
|
|
|
388
432
|
* fallom.init({ apiKey: "your-api-key" });
|
|
389
433
|
*
|
|
390
434
|
* // Local development
|
|
391
|
-
* fallom.init({
|
|
435
|
+
* fallom.init({
|
|
436
|
+
* tracesUrl: "http://localhost:3002",
|
|
437
|
+
* configsUrl: "http://localhost:3003",
|
|
438
|
+
* promptsUrl: "http://localhost:3004"
|
|
439
|
+
* });
|
|
392
440
|
*
|
|
393
441
|
* // Privacy mode
|
|
394
442
|
* fallom.init({ captureContent: false });
|