feat: support custom tracer when creating run in ts sdk (#4924)

This commit is contained in:
lc-arjun
2025-06-02 18:10:01 -07:00
committed by GitHub
3 changed files with 50 additions and 32 deletions
+7
View File
@@ -979,6 +979,7 @@ export class RunsClient<
after_seconds: payload?.afterSeconds,
if_not_exists: payload?.ifNotExists,
checkpoint_during: payload?.checkpointDuring,
langsmith_tracer: payload?._langsmithTracer,
};
const [run, response] = await this.fetch<Run>(`/threads/${threadId}/runs`, {
@@ -1059,6 +1060,12 @@ export class RunsClient<
after_seconds: payload?.afterSeconds,
if_not_exists: payload?.ifNotExists,
checkpoint_during: payload?.checkpointDuring,
langsmith_tracer: payload?._langsmithTracer
? {
project_name: payload?._langsmithTracer?.projectName,
example_id: payload?._langsmithTracer?.exampleId,
}
: undefined,
};
const endpoint =
threadId == null ? `/runs/wait` : `/threads/${threadId}/runs/wait`;
+35 -31
View File
@@ -2,51 +2,55 @@ export { Client, getApiKey } from "./client.js";
export type { ClientConfig, RequestHook } from "./client.js";
export type {
AssistantBase,
Assistant,
AssistantVersion,
AssistantBase,
AssistantGraph,
AssistantVersion,
Checkpoint,
Config,
Cron,
CronCreateForThreadResponse,
CronCreateResponse,
DefaultValues,
GraphSchema,
Interrupt,
Item,
ListNamespaceResponse,
Metadata,
Run,
Thread,
ThreadTask,
ThreadState,
ThreadStatus,
Cron,
Checkpoint,
Interrupt,
ListNamespaceResponse,
Item,
SearchItem,
SearchItemsResponse,
CronCreateResponse,
CronCreateForThreadResponse,
Thread,
ThreadState,
ThreadStatus,
ThreadTask,
} from "./schema.js";
export { overrideFetchImplementation } from "./singletons/fetch.js";
export type { OnConflictBehavior, Command } from "./types.js";
export type { StreamMode } from "./types.stream.js";
export type {
ValuesStreamEvent,
Command,
OnConflictBehavior,
RunsInvokePayload,
} from "./types.js";
export type {
AIMessage,
FunctionMessage,
HumanMessage,
Message,
RemoveMessage,
SystemMessage,
ToolMessage,
} from "./types.messages.js";
export type {
CustomStreamEvent,
DebugStreamEvent,
ErrorStreamEvent,
EventsStreamEvent,
FeedbackStreamEvent,
MessagesStreamEvent,
MessagesTupleStreamEvent,
MetadataStreamEvent,
StreamMode,
UpdatesStreamEvent,
CustomStreamEvent,
MessagesStreamEvent,
DebugStreamEvent,
EventsStreamEvent,
ErrorStreamEvent,
FeedbackStreamEvent,
ValuesStreamEvent,
} from "./types.stream.js";
export type {
Message,
HumanMessage,
AIMessage,
ToolMessage,
SystemMessage,
FunctionMessage,
RemoveMessage,
} from "./types.messages.js";
+8 -1
View File
@@ -1,3 +1,4 @@
import { LangChainTracer } from "@langchain/core/tracers/tracer_langchain";
import { Checkpoint, Config, Metadata } from "./schema.js";
import { StreamMode } from "./types.stream.js";
@@ -41,7 +42,7 @@ export interface Command {
goto?: Send | Send[] | string | string[];
}
interface RunsInvokePayload {
export interface RunsInvokePayload {
/**
* Input to the run. Pass `null` to resume from the current state of the thread.
*/
@@ -140,6 +141,12 @@ interface RunsInvokePayload {
* Callback when a run is created.
*/
onRunCreated?: (params: { run_id: string; thread_id?: string }) => void;
/**
* @internal
* For LangSmith tracing purposes only. Not part of the public API.
*/
_langsmithTracer?: LangChainTracer;
}
export interface RunsStreamPayload<