From bca8815f764697e377e1018690daedc49111cbd7 Mon Sep 17 00:00:00 2001 From: bracesproul Date: Thu, 5 Dec 2024 13:04:13 -0800 Subject: [PATCH] crt --- langchain-core/src/runnables/base.ts | 5 ++--- langchain-core/src/runnables/config.ts | 18 ++++++++++++++++++ langchain-core/src/runnables/iter.ts | 3 ++- langchain-core/src/runnables/types.ts | 18 ------------------ langchain-core/src/tools/index.ts | 2 +- langchain-core/src/utils/stream.ts | 2 +- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/langchain-core/src/runnables/base.ts b/langchain-core/src/runnables/base.ts index 4a8c9dd65d09..5c545455ea14 100644 --- a/langchain-core/src/runnables/base.ts +++ b/langchain-core/src/runnables/base.ts @@ -6,7 +6,7 @@ import { type TraceableFunction, isTraceableFunction, } from "langsmith/singletons/traceable"; -import type { RunnableInterface, RunnableBatchOptions } from "./types.js"; +import type { RunnableInterface, RunnableBatchOptions, RunnableConfig } from "./types.js"; import { CallbackManagerForChainRun } from "../callbacks/manager.js"; import { LogStreamCallbackHandler, @@ -33,11 +33,11 @@ import { import { raceWithSignal } from "../utils/signal.js"; import { DEFAULT_RECURSION_LIMIT, - RunnableConfig, ensureConfig, getCallbackManagerForConfig, mergeConfigs, patchConfig, + pickRunnableConfigKeys, } from "./config.js"; import { AsyncCaller } from "../utils/async_caller.js"; import { Run } from "../tracers/base.js"; @@ -55,7 +55,6 @@ import { } from "./iter.js"; import { _isToolCall, ToolInputParsingException } from "../tools/utils.js"; import { ToolCall } from "../messages/tool.js"; -import { pickRunnableConfigKeys } from "./types.js"; export { type RunnableInterface, RunnableBatchOptions }; diff --git a/langchain-core/src/runnables/config.ts b/langchain-core/src/runnables/config.ts index 8fa9a244ee3d..aae7164b5721 100644 --- a/langchain-core/src/runnables/config.ts +++ b/langchain-core/src/runnables/config.ts @@ -233,3 +233,21 @@ export function patchConfig( } return newConfig; } + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export function pickRunnableConfigKeys>( + config?: CallOptions +): Partial | undefined { + return config + ? { + configurable: config.configurable, + recursionLimit: config.recursionLimit, + callbacks: config.callbacks, + tags: config.tags, + metadata: config.metadata, + maxConcurrency: config.maxConcurrency, + timeout: config.timeout, + signal: config.signal, + } + : undefined; +} diff --git a/langchain-core/src/runnables/iter.ts b/langchain-core/src/runnables/iter.ts index 2571cd490372..ae6b9a47aa78 100644 --- a/langchain-core/src/runnables/iter.ts +++ b/langchain-core/src/runnables/iter.ts @@ -1,5 +1,6 @@ +import type { RunnableConfig } from "../../dist/runnables/types.js"; import { AsyncLocalStorageProviderSingleton } from "../singletons/index.js"; -import { pickRunnableConfigKeys, type RunnableConfig } from "./types.js"; +import { pickRunnableConfigKeys } from "./config.js"; export function isIterableIterator( thing: unknown diff --git a/langchain-core/src/runnables/types.ts b/langchain-core/src/runnables/types.ts index 3d699c990135..f06e94fa1254 100644 --- a/langchain-core/src/runnables/types.ts +++ b/langchain-core/src/runnables/types.ts @@ -108,21 +108,3 @@ export interface RunnableConfig< */ signal?: AbortSignal; } - -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export function pickRunnableConfigKeys>( - config?: CallOptions -): RunnableConfig | undefined { - return config - ? { - configurable: config.configurable, - recursionLimit: config.recursionLimit, - callbacks: config.callbacks, - tags: config.tags, - metadata: config.metadata, - maxConcurrency: config.maxConcurrency, - timeout: config.timeout, - signal: config.signal, - } - : undefined; -} diff --git a/langchain-core/src/tools/index.ts b/langchain-core/src/tools/index.ts index 7e311fb1dc24..8ce02d28c935 100644 --- a/langchain-core/src/tools/index.ts +++ b/langchain-core/src/tools/index.ts @@ -12,6 +12,7 @@ import { import { ensureConfig, patchConfig, + pickRunnableConfigKeys, type RunnableConfig, } from "../runnables/config.js"; import type { RunnableFunc, RunnableInterface } from "../runnables/base.js"; @@ -20,7 +21,6 @@ import { MessageContent } from "../messages/base.js"; import { AsyncLocalStorageProviderSingleton } from "../singletons/index.js"; import { _isToolCall, ToolInputParsingException } from "./utils.js"; import { isZodSchema } from "../utils/types/is_zod_schema.js"; -import { pickRunnableConfigKeys } from "../runnables/types.js"; export { ToolInputParsingException }; diff --git a/langchain-core/src/utils/stream.ts b/langchain-core/src/utils/stream.ts index 123a6b64ca8e..b2c7ba21bb27 100644 --- a/langchain-core/src/utils/stream.ts +++ b/langchain-core/src/utils/stream.ts @@ -1,4 +1,4 @@ -import { pickRunnableConfigKeys } from "../runnables/types.js"; +import { pickRunnableConfigKeys } from "../runnables/config.js"; import { AsyncLocalStorageProviderSingleton } from "../singletons/index.js"; import { IterableReadableStreamInterface } from "../types/stream.js"; import { raceWithSignal } from "./signal.js";