@langchain/core
Version:
Core LangChain.js abstractions and schemas
1 lines • 3.1 kB
Source Map (JSON)
{"version":3,"file":"async_caller.d.cts","names":["FailedAttemptHandler","AsyncCallerParams","AsyncCallerCallOptions","AbortSignal","AsyncCaller","A","Promise","T","Parameters","ReturnType","Awaited","fetch"],"sources":["../../src/utils/async_caller.d.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport 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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n call<A extends any[], T extends (...args: A) => Promise<any>>(callable: T, ...args: Parameters<T>): Promise<Awaited<ReturnType<T>>>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\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"],"mappings":";;AACYA,KAAAA,oBAAAA,GAAoB,CAAA,KAAA,EAAA,GAAA,EAAA,GAAA,GAAA;AACfC,UAAAA,iBAAAA,CAAiB;EAkBjBC;AAgBjB;;;EAC+C,cACrBD,CAAAA,EAAAA,MAAAA;EAAiB;;;;EAKgB,UAAiBM,CAAAA,EAAAA,MAAAA;EAAC;;;;;EAA0C,eAAfD,CAAAA,EAzBlFN,oBAyBkFM;;AAEzCA,UAzB9CJ,sBAAAA,CAyB8CI;EAAO,MAAgBJ,CAAAA,EAxBzEC,WAwByED;;;;;;;;;;;;AAC9B;;;cAVnCE,WAAAA;4BACSH;wBACJA;6BACKA;;sBAEPA;;4CAEsBI,MAAMC,wBAAwBC,YAAYC,WAAWD,KAAKD,QAAQI,QAAQD,WAAWF;;uDAE1EF,MAAMC,uBAAuBJ,kCAAkCK,YAAYC,WAAWD,KAAKD,QAAQI,QAAQD,WAAWF;iBAC5JC,kBAAkBG,SAASF,kBAAkBE"}