@langchain/core
Version:
Core LangChain.js abstractions and schemas
81 lines • 3.2 kB
text/typescript
import { BaseTracer, Run as Run$2 } from "./base.cjs";
import { BaseCallbackHandlerInput } from "../callbacks/base.cjs";
import { TracePolicy, omitPayload } from "./trace_policy.cjs";
import { BaseRun, KVMap, RunCreate, RunUpdate as RunUpdate$1 } from "langsmith/schemas";
import { RunTree, RunTreeConfig } from "langsmith/run_trees";
import { AgentAddress, LangSmithTracingClientInterface } from "langsmith";
export interface Run extends BaseRun {
id: string;
child_runs: this[];
child_execution_order: number;
dotted_order?: string;
trace_id?: string;
}
export interface RunCreate2 extends RunCreate {
trace_id?: string;
dotted_order?: string;
}
export interface RunUpdate extends RunUpdate$1 {
events: BaseRun["events"];
inputs: KVMap;
trace_id?: string;
dotted_order?: string;
}
export interface LangChainTracerFields extends BaseCallbackHandlerInput {
exampleId?: string;
projectName?: string;
address?: AgentAddress;
client?: LangSmithTracingClientInterface;
replicas?: RunTreeConfig["replicas"];
metadata?: Record<string, unknown>;
tags?: string[];
}
/**
* Keys that should be inherited from `tracerInheritableMetadata` even when
* the run already has a value for them. This lets nested contexts
* (e.g. a subagent invoked from inside a parent agent) override a
* LangSmith-only tracing metadata value that was set by an ancestor.
*
* Keep this list very small: every key here loses the default
* "first wins" protection and is always clobbered by the nearest
* enclosing tracer config. Only keys that are strictly for LangSmith
* tracing bookkeeping should be added.
*/
export declare const OVERRIDABLE_LANGSMITH_INHERITABLE_METADATA_KEYS: Set<string>;
export declare class LangChainTracer extends BaseTracer implements LangChainTracerFields {
protected fields: LangChainTracerFields;
name: string;
projectName?: string;
address?: AgentAddress;
exampleId?: string;
client: LangSmithTracingClientInterface;
replicas?: RunTreeConfig["replicas"];
usesRunTreeMap: boolean;
tracingMetadata?: Record<string, unknown>;
tracingTags: string[];
constructor(fields?: LangChainTracerFields);
protected persistRun(_run: Run): Promise<void>;
onRunCreate(run: Run): Promise<void>;
onRunUpdate(run: Run): Promise<void>;
/**
* Applies the run's trace policy to the copy that gets sent to LangSmith, and
* drops the policy from that copy's `extra`. If a processor throws, its
* payload is dropped and the error is set on the copy and returned, so the
* run is still sent (and not left pending) before the error is rethrown.
*/
private _applyTracePolicy;
onLLMEnd(run: Run$2): void;
copyWithTracingConfig({ metadata, tags }: {
metadata?: Record<string, unknown>;
tags?: string[];
}): LangChainTracer;
/** @internal */
_getRunStoreKey(): object;
getRun(id: string): Run | undefined;
updateFromRunTree(runTree: RunTree): void;
getRunTreeWithTracingConfig(id: string): RunTree | undefined;
static getTraceableRunTree(): RunTree | undefined;
static [Symbol.hasInstance](instance: unknown): boolean;
}
export { type TracePolicy, omitPayload };
//# sourceMappingURL=tracer_langchain.d.cts.map