langsmith 0.5.21 → 0.5.23
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/dist/client.cjs +327 -10
- package/dist/client.d.ts +90 -1
- package/dist/client.js +330 -13
- package/dist/evaluation/_runner.cjs +1 -4
- package/dist/evaluation/_runner.js +1 -4
- package/dist/experimental/sandbox/client.cjs +102 -427
- package/dist/experimental/sandbox/client.d.ts +68 -159
- package/dist/experimental/sandbox/client.js +104 -429
- package/dist/experimental/sandbox/errors.cjs +1 -2
- package/dist/experimental/sandbox/errors.d.ts +1 -2
- package/dist/experimental/sandbox/errors.js +1 -2
- package/dist/experimental/sandbox/helpers.cjs +8 -98
- package/dist/experimental/sandbox/helpers.d.ts +0 -29
- package/dist/experimental/sandbox/helpers.js +9 -95
- package/dist/experimental/sandbox/index.cjs +6 -1
- package/dist/experimental/sandbox/index.d.ts +7 -2
- package/dist/experimental/sandbox/index.js +6 -1
- package/dist/experimental/sandbox/sandbox.cjs +3 -11
- package/dist/experimental/sandbox/sandbox.d.ts +3 -5
- package/dist/experimental/sandbox/sandbox.js +3 -11
- package/dist/experimental/sandbox/types.d.ts +32 -149
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/schemas.d.ts +54 -0
- package/dist/utils/error.cjs +7 -0
- package/dist/utils/error.d.ts +1 -0
- package/dist/utils/error.js +6 -0
- package/dist/utils/fast-safe-stringify/index.cjs +228 -0
- package/dist/utils/fast-safe-stringify/index.d.ts +33 -0
- package/dist/utils/fast-safe-stringify/index.js +227 -0
- package/dist/utils/prompts.cjs +7 -2
- package/dist/utils/prompts.d.ts +6 -1
- package/dist/utils/prompts.js +6 -1
- package/dist/wrappers/openai_agents.cjs +849 -0
- package/dist/wrappers/openai_agents.d.ts +92 -0
- package/dist/wrappers/openai_agents.js +845 -0
- package/package.json +22 -6
- package/wrappers/openai_agents.cjs +1 -0
- package/wrappers/openai_agents.d.cts +1 -0
- package/wrappers/openai_agents.d.ts +1 -0
- package/wrappers/openai_agents.js +1 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LangSmith integration for OpenAI Agents SDK.
|
|
3
|
+
*
|
|
4
|
+
* This module provides tracing support for the OpenAI Agents SDK.
|
|
5
|
+
*/
|
|
6
|
+
import { Client } from "../client.js";
|
|
7
|
+
import type { Span as SDKSpan, SpanData, Trace as SDKTrace } from "@openai/agents";
|
|
8
|
+
type Span<TData extends SpanData = SpanData> = Pick<SDKSpan<TData>, "traceId" | "spanData" | "spanId" | "parentId" | "error" | "startedAt" | "endedAt" | "toJSON">;
|
|
9
|
+
type Trace = Pick<SDKTrace, "traceId" | "name" | "groupId" | "metadata" | "toJSON">;
|
|
10
|
+
interface TracingProcessor {
|
|
11
|
+
start?(): void;
|
|
12
|
+
onTraceStart(trace: Trace): Promise<void>;
|
|
13
|
+
onTraceEnd(trace: Trace): Promise<void>;
|
|
14
|
+
onSpanStart(span: Span): Promise<void>;
|
|
15
|
+
onSpanEnd(span: Span): Promise<void>;
|
|
16
|
+
shutdown(timeout?: number): Promise<void>;
|
|
17
|
+
forceFlush(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Tracing processor for the [OpenAI Agents SDK](https://openai.github.io/openai-agents-js/).
|
|
21
|
+
*
|
|
22
|
+
* Traces all intermediate steps of your OpenAI Agent to LangSmith.
|
|
23
|
+
*
|
|
24
|
+
* Requirements: Make sure to install `npm install @openai/agents`.
|
|
25
|
+
*
|
|
26
|
+
* Installing this processor is itself an explicit opt-in to tracing,
|
|
27
|
+
* so traces will be posted regardless of the `LANGSMITH_TRACING` env
|
|
28
|
+
* variable. Any nested `traceable()` calls made from within an agent
|
|
29
|
+
* run (e.g. inside a tool handler) will inherit this and also post,
|
|
30
|
+
* even if `LANGSMITH_TRACING` is not set.
|
|
31
|
+
*
|
|
32
|
+
* @param client - An instance of `langsmith.Client`. If not provided, a default client is created.
|
|
33
|
+
* @param metadata - Metadata to associate with all traces.
|
|
34
|
+
* @param tags - Tags to associate with all traces.
|
|
35
|
+
* @param projectName - LangSmith project to trace to.
|
|
36
|
+
* @param name - Name of the root trace.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* import { Agent, Runner, function_tool, setTraceProcessors } from "@openai/agents";
|
|
41
|
+
* import { OpenAIAgentsTracingProcessor } from "langsmith/wrappers/openai_agents";
|
|
42
|
+
*
|
|
43
|
+
* setTraceProcessors([new OpenAIAgentsTracingProcessor()]);
|
|
44
|
+
*
|
|
45
|
+
* const getWeather = function_tool({
|
|
46
|
+
* name: "get_weather",
|
|
47
|
+
* description: "Get the weather for a city",
|
|
48
|
+
* parameters: { type: "object", properties: { city: { type: "string" } } },
|
|
49
|
+
* run: async ({ city }: { city: string }) => `The weather in ${city} is sunny`,
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* const agent = new Agent({
|
|
53
|
+
* name: "Assistant",
|
|
54
|
+
* instructions: "You are a helpful assistant",
|
|
55
|
+
* model: "gpt-4.1-mini",
|
|
56
|
+
* tools: [getWeather],
|
|
57
|
+
* });
|
|
58
|
+
*
|
|
59
|
+
* const result = await Runner.run(agent, "What's the weather in New York?");
|
|
60
|
+
* console.log(result.finalOutput);
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare class OpenAIAgentsTracingProcessor implements TracingProcessor {
|
|
64
|
+
private client;
|
|
65
|
+
private _metadata?;
|
|
66
|
+
private _tags?;
|
|
67
|
+
private _projectName?;
|
|
68
|
+
private _name?;
|
|
69
|
+
private _firstResponseInputs;
|
|
70
|
+
private _lastResponseOutputs;
|
|
71
|
+
private _runs;
|
|
72
|
+
private _spanDataTypes;
|
|
73
|
+
private _unpostedTraces;
|
|
74
|
+
private _unpostedSpans;
|
|
75
|
+
private _previousStoreByTrace;
|
|
76
|
+
private _previousStoreBySpan;
|
|
77
|
+
constructor(options?: {
|
|
78
|
+
client?: Client;
|
|
79
|
+
metadata?: Record<string, unknown>;
|
|
80
|
+
tags?: string[];
|
|
81
|
+
projectName?: string;
|
|
82
|
+
name?: string;
|
|
83
|
+
});
|
|
84
|
+
onTraceStart(trace: Trace): Promise<void>;
|
|
85
|
+
onTraceEnd(trace: Trace): Promise<void>;
|
|
86
|
+
onSpanStart(span: Span): Promise<void>;
|
|
87
|
+
onSpanEnd(span: Span): Promise<void>;
|
|
88
|
+
private _maybePostTrace;
|
|
89
|
+
shutdown(): Promise<void>;
|
|
90
|
+
forceFlush(): Promise<void>;
|
|
91
|
+
}
|
|
92
|
+
export {};
|