@langchain/core
Version:
Core LangChain.js abstractions and schemas
1 lines • 2.9 kB
Source Map (JSON)
{"version":3,"file":"async_caller.d.ts","names":["FailedAttemptHandler","AsyncCallerParams","AsyncCallerCallOptions","AbortSignal","AsyncCaller","A","T","Promise","Parameters","ReturnType","Awaited","fetch"],"sources":["../../src/utils/async_caller.d.ts"],"sourcesContent":["export type FailedAttemptHandler = (error: any) => any;\nexport interface AsyncCallerParams {\n /**\n * The maximum number of concurrent calls that can be made.\n * Defaults to `Infinity`, which means no limit.\n */\n maxConcurrency?: number;\n /**\n * The maximum number of retries that can be made for a single call,\n * with an exponential backoff between each attempt. Defaults to 6.\n */\n maxRetries?: number;\n /**\n * Custom handler to handle failed attempts. Takes the originally thrown\n * error object as input, and should itself throw an error if the input\n * error is not retryable.\n */\n onFailedAttempt?: FailedAttemptHandler;\n}\nexport interface AsyncCallerCallOptions {\n signal?: AbortSignal;\n}\n/**\n * A class that can be used to make async calls with concurrency and retry logic.\n *\n * This is useful for making calls to any kind of \"expensive\" external resource,\n * be it because it's rate-limited, subject to network issues, etc.\n *\n * Concurrent calls are limited by the `maxConcurrency` parameter, which defaults\n * to `Infinity`. This means that by default, all calls will be made in parallel.\n *\n * Retries are limited by the `maxRetries` parameter, which defaults to 6. This\n * means that by default, each call will be retried up to 6 times, with an\n * exponential backoff between each attempt.\n */\nexport declare class AsyncCaller {\n protected maxConcurrency: AsyncCallerParams[\"maxConcurrency\"];\n protected maxRetries: AsyncCallerParams[\"maxRetries\"];\n protected onFailedAttempt: AsyncCallerParams[\"onFailedAttempt\"];\n private queue;\n constructor(params: AsyncCallerParams);\n call<A extends any[], T extends (...args: A) => Promise<any>>(callable: T, ...args: Parameters<T>): Promise<Awaited<ReturnType<T>>>;\n callWithOptions<A extends any[], T extends (...args: A) => Promise<any>>(options: AsyncCallerCallOptions, callable: T, ...args: Parameters<T>): Promise<Awaited<ReturnType<T>>>;\n fetch(...args: Parameters<typeof fetch>): ReturnType<typeof fetch>;\n}\n//# sourceMappingURL=async_caller.d.ts.map"],"mappings":";KAAYA,oBAAAA;AAAAA,UACKC,iBAAAA,CADe;EACfA;AAkBjB;AAgBA;;EAE0BA,cAAAA,CAAAA,EAAAA,MAAAA;EACKA;;;;EAG6CK,UAAAA,CAAAA,EAAAA,MAAAA;EAAuBA;;;;;EAAKC,eAAAA,CAAAA,EAxBlFP,oBAwBkFO;;AACzCA,UAvB9CL,sBAAAA,CAuB8CK;EAAuBL,MAAAA,CAAAA,EAtBzEC,WAsByED;;;;;;;;;;;;AAC9B;;;cARnCE,WAAAA;4BACSH;wBACJA;6BACKA;;sBAEPA;4CACsBI,MAAME,wBAAwBD,YAAYE,WAAWF,KAAKC,QAAQG,QAAQD,WAAWH;uDAC1ED,MAAME,uBAAuBL,kCAAkCI,YAAYE,WAAWF,KAAKC,QAAQG,QAAQD,WAAWH;iBAC5JE,kBAAkBG,SAASF,kBAAkBE"}