-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
types.ts
63 lines (53 loc) 路 1.86 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import type { z } from "zod";
import type { RunnableConfig } from "./config.js";
import type { IterableReadableStreamInterface } from "../utils/stream.js";
import type { SerializableInterface } from "../load/serializable.js";
export type RunnableBatchOptions = {
/** @deprecated Pass in via the standard runnable config object instead */
maxConcurrency?: number;
returnExceptions?: boolean;
};
export type RunnableIOSchema = {
name?: string;
schema: z.ZodType;
};
/**
* Base interface implemented by all runnables.
* Used for cross-compatibility between different versions of LangChain core.
*
* Should not change on patch releases.
*/
export interface RunnableInterface<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
RunInput = any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
RunOutput = any,
CallOptions extends RunnableConfig = RunnableConfig
> extends SerializableInterface {
lc_serializable: boolean;
invoke(input: RunInput, options?: Partial<CallOptions>): Promise<RunOutput>;
batch(
inputs: RunInput[],
options?: Partial<CallOptions> | Partial<CallOptions>[],
batchOptions?: RunnableBatchOptions & { returnExceptions?: false }
): Promise<RunOutput[]>;
batch(
inputs: RunInput[],
options?: Partial<CallOptions> | Partial<CallOptions>[],
batchOptions?: RunnableBatchOptions & { returnExceptions: true }
): Promise<(RunOutput | Error)[]>;
batch(
inputs: RunInput[],
options?: Partial<CallOptions> | Partial<CallOptions>[],
batchOptions?: RunnableBatchOptions
): Promise<(RunOutput | Error)[]>;
stream(
input: RunInput,
options?: Partial<CallOptions>
): Promise<IterableReadableStreamInterface<RunOutput>>;
transform(
generator: AsyncGenerator<RunInput>,
options: Partial<CallOptions>
): AsyncGenerator<RunOutput>;
getName(suffix?: string): string;
}