-
Notifications
You must be signed in to change notification settings - Fork 313
/
types.ts
56 lines (48 loc) · 1.49 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
import type { NodeWithScore } from "../Node.js";
import type { PromptMixin } from "../prompts/Mixin.js";
import type { Response } from "../Response.js";
export interface SynthesizeParamsBase {
query: string;
nodesWithScore: NodeWithScore[];
}
export interface SynthesizeParamsStreaming extends SynthesizeParamsBase {
stream: true;
}
export interface SynthesizeParamsNonStreaming extends SynthesizeParamsBase {
stream?: false | null;
}
/**
* A BaseSynthesizer is used to generate a response from a query and a list of nodes.
*/
export interface BaseSynthesizer {
synthesize(
params: SynthesizeParamsStreaming,
): Promise<AsyncIterable<Response>>;
synthesize(params: SynthesizeParamsNonStreaming): Promise<Response>;
}
export interface ResponseBuilderParamsBase {
query: string;
textChunks: string[];
prevResponse?: string;
}
export interface ResponseBuilderParamsStreaming
extends ResponseBuilderParamsBase {
stream: true;
}
export interface ResponseBuilderParamsNonStreaming
extends ResponseBuilderParamsBase {
stream?: false | null;
}
/**
* A ResponseBuilder is used in a response synthesizer to generate a response from multiple response chunks.
*/
export interface ResponseBuilder extends Partial<PromptMixin> {
/**
* Get the response from a query and a list of text chunks.
* @param params
*/
getResponse(
params: ResponseBuilderParamsStreaming,
): Promise<AsyncIterable<string>>;
getResponse(params: ResponseBuilderParamsNonStreaming): Promise<string>;
}