Skip to content

Commit

Permalink
crt
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul committed Dec 5, 2024
1 parent d532c22 commit bca8815
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
5 changes: 2 additions & 3 deletions langchain-core/src/runnables/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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";
Expand All @@ -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 };

Expand Down
18 changes: 18 additions & 0 deletions langchain-core/src/runnables/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,21 @@ export function patchConfig<CallOptions extends RunnableConfig>(
}
return newConfig;
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function pickRunnableConfigKeys<CallOptions extends Record<string, any>>(
config?: CallOptions
): Partial<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;
}
3 changes: 2 additions & 1 deletion langchain-core/src/runnables/iter.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 0 additions & 18 deletions langchain-core/src/runnables/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,3 @@ export interface RunnableConfig<
*/
signal?: AbortSignal;
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function pickRunnableConfigKeys<CallOptions extends Record<string, any>>(
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;
}
2 changes: 1 addition & 1 deletion langchain-core/src/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import {
ensureConfig,
patchConfig,
pickRunnableConfigKeys,
type RunnableConfig,
} from "../runnables/config.js";
import type { RunnableFunc, RunnableInterface } from "../runnables/base.js";
Expand All @@ -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 };

Expand Down
2 changes: 1 addition & 1 deletion langchain-core/src/utils/stream.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down

0 comments on commit bca8815

Please sign in to comment.