-
Notifications
You must be signed in to change notification settings - Fork 323
/
types.ts
85 lines (71 loc) · 1.85 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
* Top level types to avoid circular dependencies
*/
import type { Event } from "./callbacks/CallbackManager.js";
import type { Response } from "./Response.js";
/**
* Parameters for sending a query.
*/
export interface QueryEngineParamsBase {
query: string;
parentEvent?: Event;
}
export interface QueryEngineParamsStreaming extends QueryEngineParamsBase {
stream: true;
}
export interface QueryEngineParamsNonStreaming extends QueryEngineParamsBase {
stream?: false | null;
}
/**
* A query engine is a question answerer that can use one or more steps.
*/
export interface BaseQueryEngine {
/**
* Query the query engine and get a response.
* @param params
*/
query(params: QueryEngineParamsStreaming): Promise<AsyncIterable<Response>>;
query(params: QueryEngineParamsNonStreaming): Promise<Response>;
}
/**
* Simple Tool interface. Likely to change.
*/
export interface BaseTool {
call?: (...args: any[]) => any;
metadata: ToolMetadata;
}
/**
* An OutputParser is used to extract structured data from the raw output of the LLM.
*/
export interface BaseOutputParser<T> {
parse(output: string): T;
format(output: string): string;
}
/**
* StructuredOutput is just a combo of the raw output and the parsed output.
*/
export interface StructuredOutput<T> {
rawOutput: string;
parsedOutput: T;
}
export type ToolParameters = {
type: string | "object";
properties: Record<string, { type: string; description?: string }>;
required?: string[];
};
export interface ToolMetadata {
description: string;
name: string;
parameters?: ToolParameters;
argsKwargs?: Record<string, any>;
}
export type ToolMetadataOnlyDescription = Pick<ToolMetadata, "description">;
export class QueryBundle {
queryStr: string;
constructor(queryStr: string) {
this.queryStr = queryStr;
}
toString(): string {
return this.queryStr;
}
}