MCPcopy
hub / github.com/langchain-ai/langchainjs / patchConfig

Function patchConfig

libs/langchain-core/src/runnables/config.ts:245–281  ·  view source on GitHub ↗
(
  config: Partial<CallOptions> = {},
  {
    callbacks,
    maxConcurrency,
    recursionLimit,
    runName,
    configurable,
    runId,
  }: RunnableConfig = {}
)

Source from the content-addressed store, hash-verified

243 * Helper function that patches runnable configs with updated properties.
244 */
245export function patchConfig<CallOptions extends RunnableConfig>(
246 config: Partial<CallOptions> = {},
247 {
248 callbacks,
249 maxConcurrency,
250 recursionLimit,
251 runName,
252 configurable,
253 runId,
254 }: RunnableConfig = {}
255): Partial<CallOptions> {
256 const newConfig = ensureConfig(config);
257 if (callbacks !== undefined) {
258 /**
259 * If we're replacing callbacks we need to unset runName
260 * since that should apply only to the same run as the original callbacks
261 */
262 delete newConfig.runName;
263 newConfig.callbacks = callbacks;
264 }
265 if (recursionLimit !== undefined) {
266 newConfig.recursionLimit = recursionLimit;
267 }
268 if (maxConcurrency !== undefined) {
269 newConfig.maxConcurrency = maxConcurrency;
270 }
271 if (runName !== undefined) {
272 newConfig.runName = runName;
273 }
274 if (configurable !== undefined) {
275 newConfig.configurable = { ...newConfig.configurable, ...configurable };
276 }
277 if (runId !== undefined) {
278 delete newConfig.runId;
279 }
280 return newConfig;
281}
282
283// oxlint-disable-next-line @typescript-eslint/no-explicit-any
284export function pickRunnableConfigKeys<CallOptions extends Record<string, any>>(

Callers 15

customToolFunction · 0.90
_callMethod · 0.90
planMethod · 0.90
planMethod · 0.90
toolFunction · 0.85
_invokeMethod · 0.85
_patchConfigForRetryMethod · 0.85
invokeMethod · 0.85
batchMethod · 0.85
_streamIteratorMethod · 0.85
invokeMethod · 0.85
_transformMethod · 0.85

Calls 1

ensureConfigFunction · 0.85

Tested by

no test coverage detected