-
Notifications
You must be signed in to change notification settings - Fork 39
/
types.ts
208 lines (194 loc) 路 4.77 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/**
* apiURLGoogleGemini: Base URL for Google Gemini API calls
* @export
*/
export const apiURLGoogleGemini =
'https://{REGION}-aiplatform.googleapis.com/v1/projects/{PROJECT_ID}/locations/{REGION}/publishers/google/models/gemini-1.0-pro:streamGenerateContent';
/**
* GoogleGeminiModel: Enum for specifying the model version
* @export
*/
export enum GoogleGeminiModel {
Gemini_1_0_Pro = 'gemini-1.0-pro'
}
/**
* GoogleGeminiEmbedModels: Enum for specifying embedding models
* @export
*/
export enum GoogleGeminiEmbedModels {}
// Assuming embedding models would be specified here, similar to GooglePalm2EmbedModels
/*
function_call {
name: "get_exchange_rate"
args {
fields {
key: "currency_to"
value {
string_value: "SEK"
}
}
fields {
key: "currency_from"
value {
string_value: "AUD"
}
}
fields {
key: "currency_date"
value {
string_value: "latest"
}
}
}
}*/
export type GoogleGeminiPart = {
text?: string;
function_call?: {
name: string;
args: object;
};
inlineData?: {
mimeType: string;
data: string;
};
fileData?: {
mimeType: string;
fileUri: string;
};
videoMetadata?: {
startOffset: {
seconds: number;
nanos: number;
};
endOffset: {
seconds: number;
nanos: number;
};
};
};
export type GoogleGeminiContent = {
role: 'USER' | 'MODEL';
parts: GoogleGeminiPart[];
};
export type GoogleGeminiToolFunctionDeclaration = {
name: string;
description?: string;
parameters?: object;
};
export type GoogleGeminiTool = {
functionDeclarations: GoogleGeminiToolFunctionDeclaration[];
};
export type GoogleGeminiSafetySetting = {
category: 'HARM_CATEGORY_SEXUALLY_EXPLICIT' | string; // Assuming other categories can be added here
threshold:
| 'BLOCK_NONE'
| 'BLOCK_LOW_AND_ABOVE'
| 'BLOCK_MED_AND_ABOVE'
| 'BLOCK_ONLY_HIGH';
};
export type GoogleGeminiGenerationConfig = {
temperature: number;
topP: number;
topK: number;
candidateCount: number;
maxOutputTokens: number;
stopSequences: readonly string[];
};
export type GoogleGeminiChatRequest = {
contents: GoogleGeminiContent[];
tools?: GoogleGeminiTool[];
safetySettings?: GoogleGeminiSafetySetting[];
generationConfig: GoogleGeminiGenerationConfig;
};
export type GoogleGeminiChatResponse = {
candidates: {
content: {
parts: GoogleGeminiPart[];
};
finishReason:
| 'FINISH_REASON_UNSPECIFIED'
| 'FINISH_REASON_STOP'
| 'FINISH_REASON_MAX_TOKENS'
| 'FINISH_REASON_SAFETY'
| 'FINISH_REASON_RECITATION'
| 'FINISH_REASON_OTHER';
safetyRatings: {
category: string;
probability:
| 'HARM_PROBABILITY_UNSPECIFIED'
| 'NEGLIGIBLE'
| 'LOW'
| 'MEDIUM'
| 'HIGH';
blocked: boolean;
}[];
citationMetadata: {
citations: {
startIndex: number;
endIndex: number;
uri: string;
title: string;
license: string;
publicationDate: {
year: number;
month: number;
day: number;
};
}[];
};
}[];
usageMetadata: {
promptTokenCount: number;
candidatesTokenCount: number;
totalTokenCount: number;
};
};
/**
* GoogleGeminiConfig: Configuration options for Google Gemini API
* @export
*/
export type GoogleGeminiConfig = {
model: GoogleGeminiModel;
embedModel: GoogleGeminiModel;
maxTokens: number;
temperature: number;
topP: number;
topK: number;
stopSequences: string[];
};
/**
* GoogleGeminiEmbedRequest: Structure for making an embedding request to the Google Gemini API.
* @export
*/
export type GoogleGeminiEmbedRequest = {
contents: {
role: 'USER' | 'MODEL'; // Assuming embedding might also consider the role for context
parts: {
// Assuming text is the primary content for embeddings as per documentation
text: string; // The text for which embeddings are requested
// For embedding, typically, the focus is on text, but including provisions for multimedia embedding if supported
inlineData?: {
mimeType: string; // MIME type of the inline data
data: string; // Base64 encoded data
};
fileData?: {
mimeType: string; // MIME type of the file data
fileUri: string; // URI for the file data
};
}[];
}[];
};
/**
* GoogleGeminiEmbedResponse: Structure for handling responses from the Google Gemini API embedding requests.
* @export
*/
export type GoogleGeminiEmbedResponse = {
model: string; // Model used for generating embeddings, providing context for interpreting the embeddings
predictions: [
{
embeddings: {
values: number[]; // The embedding vector
};
}
];
};