-
Notifications
You must be signed in to change notification settings - Fork 331
/
types.ts
104 lines (87 loc) · 2.38 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/**
* Top level types to avoid circular dependencies
*/
import type { Response } from "./Response.js";
/**
* @link https://docs.llamaindex.ai/en/stable/api_reference/schema/?h=querybundle#llama_index.core.schema.QueryBundle
*
* We don't have `image_path` here, because it is included in the `query` field.
*/
export type QueryBundle = {
query: MessageContent;
embedding?: number[];
};
export type MessageContentTextDetail = {
type: "text";
text: string;
};
export type MessageContentImageDetail = {
type: "image_url";
image_url: {
url: string;
};
};
export type MessageContentDetail =
| MessageContentTextDetail
| MessageContentImageDetail;
/**
* Extended type for the content of a message that allows for multi-modal messages.
*/
export type MessageContent = string | MessageContentDetail[];
/**
* Parameters for sending a query.
*/
export type QueryEngineParamsBase = {
query: MessageContent | QueryBundle;
};
export type QueryEngineParamsStreaming = QueryEngineParamsBase & {
stream: true;
};
export type QueryEngineParamsNonStreaming = QueryEngineParamsBase & {
stream?: false;
};
/**
* 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 type UUID = `${string}-${string}-${string}-${string}-${string}`;