Skip to main content

Module: traceable

Type Aliases

RunTreeLike

Ƭ RunTreeLike: RunTree

Defined in

traceable.ts:24


TraceableFunction

Ƭ TraceableFunction<Func>: Func extends (...args: A1) => R1(...args: A2) => R2(...args: A3) => R3(...args: A4) => R4(...args: A5) => R5 ? UnionToIntersection<WrapArgReturnPair<[A1, R1] | [A2, R2] | [A3, R3] | [A4, R4] | [A5, R5]>> : Func extends (...args: A1) => R1(...args: A2) => R2(...args: A3) => R3(...args: A4) => R4 ? UnionToIntersection<WrapArgReturnPair<[A1, R1] | [A2, R2] | [A3, R3] | [A4, R4]>> : Func extends (...args: A1) => R1(...args: A2) => R2(...args: A3) => R3 ? UnionToIntersection<WrapArgReturnPair<[A1, R1] | [A2, R2] | [A3, R3]>> : Func extends (...args: A1) => R1(...args: A2) => R2 ? UnionToIntersection<WrapArgReturnPair<[A1, R1] | [A2, R2]>> : Func extends (...args: A1) => R1 ? UnionToIntersection<WrapArgReturnPair<[A1, R1]>> : never

Type parameters

NameType
Funcextends (...args: any[]) => any

Defined in

traceable.ts:54

Functions

getCurrentRunTree

getCurrentRunTree(): RunTree

Return the current run tree from within a traceable-wrapped function. Will throw an error if called outside of a traceable function.

Returns

RunTree

The run tree for the given context.

Defined in

traceable.ts:440


isTraceableFunction

isTraceableFunction(x): x is Function

Parameters

NameType
xunknown

Returns

x is Function

Defined in

traceable.ts:454


traceable

traceable<Func>(wrappedFunc, config?): TraceableFunction<Func>

Higher-order function that takes function as input and returns a "TraceableFunction" - a wrapped version of the input that automatically handles tracing. If the returned traceable function calls any traceable functions, those are automatically traced as well.

The returned TraceableFunction can accept a run tree or run tree config as its first argument. If omitted, it will default to the caller's run tree, or will be treated as a root run.

Type parameters

NameType
Funcextends (...args: any[]) => any

Parameters

NameTypeDescription
wrappedFuncFuncTargeted function to be traced
config?Partial<RunTreeConfig> & { aggregator?: (args: any[]) => any ; argsConfigPath?: [number] | [number, string] ; tracingEnabled?: boolean }Additional metadata such as name, tags or providing a custom LangSmith client instance

Returns

TraceableFunction<Func>

Defined in

traceable.ts:140


wrapFunctionAndEnsureTraceable

wrapFunctionAndEnsureTraceable<Func>(target, options, name?): TraceableFunction<Func>

Type parameters

NameType
Funcextends (...args: any[]) => any

Parameters

NameTypeDefault value
targetFuncundefined
optionsPartial<RunTreeConfig>undefined
namestring"target"

Returns

TraceableFunction<Func>

Defined in

traceable.ts:471


Was this page helpful?