langchain.d.ts 1.6 KB

123456789101112131415161718192021222324252627282930
  1. import { CallbackManager } from "@langchain/core/callbacks/manager";
  2. import { Runnable, RunnableConfig } from "@langchain/core/runnables";
  3. import { RunTree } from "./run_trees.js";
  4. import { TraceableFunction } from "./traceable.js";
  5. /**
  6. * Converts the current run tree active within a traceable-wrapped function
  7. * into a LangChain compatible callback manager. This is useful to handoff tracing
  8. * from LangSmith to LangChain Runnables and LLMs.
  9. *
  10. * @param {RunTree | undefined} currentRunTree Current RunTree from within a traceable-wrapped function. If not provided, the current run tree will be inferred from AsyncLocalStorage.
  11. * @returns {CallbackManager | undefined} Callback manager used by LangChain Runnable objects.
  12. */
  13. export declare function getLangchainCallbacks(currentRunTree?: RunTree | undefined): Promise<CallbackManager | undefined>;
  14. type AnyTraceableFunction = TraceableFunction<(...any: any[]) => any>;
  15. /**
  16. * RunnableTraceable is a Runnable that wraps a traceable function.
  17. * This allows adding Langsmith traced functions into LangChain sequences.
  18. */
  19. export declare class RunnableTraceable<RunInput, RunOutput> extends Runnable<RunInput, RunOutput> {
  20. lc_serializable: boolean;
  21. lc_namespace: string[];
  22. protected func: AnyTraceableFunction;
  23. constructor(fields: {
  24. func: AnyTraceableFunction;
  25. });
  26. invoke(input: RunInput, options?: Partial<RunnableConfig>): Promise<RunOutput>;
  27. _streamIterator(input: RunInput, options?: Partial<RunnableConfig>): AsyncGenerator<RunOutput>;
  28. static from(func: AnyTraceableFunction): RunnableTraceable<unknown, unknown>;
  29. }
  30. export {};