-
Notifications
You must be signed in to change notification settings - Fork 39
/
types.ts
88 lines (78 loc) 路 1.8 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
import type { AITextTraceStep } from '../tracing/types.js';
export type TextModelInfo = {
name: string;
currency?: string;
characterIsToken?: boolean;
promptTokenCostPer1M?: number;
completionTokenCostPer1M?: number;
aliases?: string[];
};
export type TokenUsage = {
promptTokens: number;
completionTokens: number;
totalTokens: number;
};
export type TextModelConfig = {
maxTokens?: number;
temperature: number;
topP?: number;
topK?: number;
n?: number;
stream?: boolean;
logprobs?: number;
echo?: boolean;
presencePenalty?: number;
frequencyPenalty?: number;
bestOf?: number;
logitBias?: Map<string, number>;
suffix?: string | null;
stop?: string[];
};
export type TextResponseFunctionCall = {
id?: string;
name: string;
args: string;
};
export type TextResponseResult = {
content: string | null;
role?: string;
name?: string;
id?: string;
functionCalls?: {
id: string;
type: 'function';
// eslint-disable-next-line functional/functional-parameters
function: { name: string; arguments?: string | object };
}[];
finishReason?:
| 'stop'
| 'length'
| 'function_call'
| 'content_filter'
| 'error';
};
export type TextResponse = {
sessionId?: string;
remoteId?: string;
results: readonly TextResponseResult[];
modelUsage?: TokenUsage;
embedModelUsage?: TokenUsage;
};
export type EmbedResponse = {
remoteId?: string;
sessionId?: string;
embeddings: readonly (readonly number[])[];
modelUsage?: TokenUsage;
};
export type TranscriptResponse = {
sessionId?: string;
duration: number;
segments: {
id: number;
start: number;
end: number;
text: string;
}[];
};
export type LoggerFunction = (traceStep: Readonly<AITextTraceStep>) => void;
export type RateLimiterFunction = <T>(func: unknown) => T;