-
Notifications
You must be signed in to change notification settings - Fork 39
/
types.ts
83 lines (73 loc) 路 2.24 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
import type {
TextModelConfig,
TextModelInfo,
TextResponse
} from '../ai/types.js';
import { type FunctionJSONSchema } from '../text/functions.js';
export type APIError = {
pathname: string;
statusCode: number;
statusMessage?: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
headers?: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
request: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
response: any;
};
export type ParsingError = { message: string; value: string };
export type TextModelInfoWithProvider = TextModelInfo & { provider: string };
export type AITextRequestIdentity = {
user?: string;
organization?: string;
};
export type AITextBaseRequest = {
identity?: Readonly<AITextRequestIdentity>;
};
export type AITextChatRequest = {
chatPrompt: Readonly<
| { role: 'system'; content: string }
| { role: 'user'; content: string; name?: string }
| {
role: 'assistant';
content: string | null;
name?: string;
functionCalls?: {
id: string;
type: 'function';
// eslint-disable-next-line functional/functional-parameters
function: { name: string; arguments?: string | object };
}[];
}
| { role: 'function'; content: string; functionId: string }
>[];
functions?: Readonly<{
name: string;
description: string;
parameters?: FunctionJSONSchema;
}>[];
functionCall?:
| 'none'
| 'auto'
| { type: 'function'; function: { name: string } };
modelConfig?: Readonly<TextModelConfig>;
modelInfo?: Readonly<TextModelInfoWithProvider>;
} & AITextBaseRequest;
export type AITextEmbedRequest = {
texts?: readonly string[];
embedModelInfo?: Readonly<TextModelInfoWithProvider>;
} & AITextBaseRequest;
export type AITextTraceStepRequest = AITextChatRequest | AITextEmbedRequest;
export type AITextTraceStepResponse = Omit<TextResponse, 'sessionId'> & {
modelResponseTime?: number;
embedModelResponseTime?: number;
parsingError?: Readonly<ParsingError>;
apiError?: Readonly<APIError>;
};
export type AITextTraceStep = {
traceId: string;
sessionId?: string;
request: AITextTraceStepRequest;
response: AITextTraceStepResponse;
createdAt: string;
};