@christianriedl/utils 1.0.132 → 1.0.134
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/iOpenAI.d.ts
CHANGED
|
@@ -66,8 +66,11 @@ export interface IOpenAIOptions {
|
|
|
66
66
|
export interface IOpenAIService {
|
|
67
67
|
log: ILogger;
|
|
68
68
|
options: IOpenAIOptions;
|
|
69
|
+
modelNames: string[];
|
|
70
|
+
initialize(): Promise<boolean>;
|
|
69
71
|
response(prompt: string | string[], tools?: string[], imageUrl?: string, json?: ISchema): Promise<IResponseResult>;
|
|
70
72
|
clearContext(): void;
|
|
73
|
+
getModels(): Promise<string[]>;
|
|
71
74
|
}
|
|
72
75
|
export type ToolFunction = (input: Dictionary<unknown>) => Promise<Dictionary<any>>;
|
|
73
76
|
export interface IOpenAIServiceWithTools extends IOpenAIService {
|
|
@@ -87,7 +90,7 @@ export interface IOpenAIServiceWithVectorStore extends IOpenAIServiceWithTools {
|
|
|
87
90
|
initializeVectorStore(): Promise<boolean>;
|
|
88
91
|
getVectorStore(vectorStoreId: string): IVectorStore | undefined;
|
|
89
92
|
addVectorStore(vectorStoreName: string): Promise<boolean>;
|
|
90
|
-
addFile(fileUrl: string, vectorStoreName: string, wait?: boolean): Promise<boolean>;
|
|
93
|
+
addFile(fileUrl: string | File, vectorStoreName: string, wait?: boolean): Promise<boolean>;
|
|
91
94
|
deleteFile(fileId: string): Promise<boolean>;
|
|
92
95
|
deleteVectorStore(vectorStoreId: string): Promise<boolean>;
|
|
93
96
|
getFileId(fileUrl: string): string | undefined;
|
package/package.json
CHANGED
|
@@ -200,7 +200,7 @@
|
|
|
200
200
|
<v-row v-else v-for="(line, index) in replyLines" :key=index dense align="center">
|
|
201
201
|
<v-col cols="12">{{line}}</v-col>
|
|
202
202
|
</v-row>
|
|
203
|
-
<v-dialog v-model="showConfig">
|
|
203
|
+
<v-dialog v-model="showConfig" :fullscreen="isMobile">
|
|
204
204
|
<OpenAIConfig :tools="props.tools" :ismobile="isMobile" @use="onUse" @back="showConfig=false"></OpenAIConfig>
|
|
205
205
|
</v-dialog>
|
|
206
206
|
</v-container>
|
|
@@ -24,11 +24,15 @@
|
|
|
24
24
|
const vectorStoreFiles = ref<string[]>([]);
|
|
25
25
|
const selectedVectorStoreName = ref('');
|
|
26
26
|
const selectedVectorStoreFile = ref('');
|
|
27
|
+
let fileHandle: FileSystemFileHandle | null = null;
|
|
27
28
|
|
|
28
29
|
initializeTools();
|
|
29
30
|
|
|
30
31
|
function initializeTools() {
|
|
32
|
+
selectedVectorStoreFile.value = '';
|
|
33
|
+
selectedVectorStoreName.value = '';
|
|
31
34
|
vectorStoreNames.value.splice(0, vectorStoreNames.value.length);
|
|
35
|
+
vectorStoreFiles.value.splice(0, vectorStoreFiles.value.length);
|
|
32
36
|
for (const key in openAI.vectorStore) {
|
|
33
37
|
vectorStoreNames.value.splice(vectorStoreNames.value.length, 0, key);
|
|
34
38
|
}
|
|
@@ -99,12 +103,13 @@
|
|
|
99
103
|
useChanged.value = false;
|
|
100
104
|
}
|
|
101
105
|
function vectorStoreSelected() {
|
|
102
|
-
|
|
103
|
-
|
|
106
|
+
selectedVectorStoreFile.value = '';
|
|
107
|
+
const vs = openAI.vectorStore![selectedVectorStoreName.value];
|
|
108
|
+
vectorStoreFiles.value.splice(0, vectorStoreFiles.value.length);
|
|
104
109
|
if (vs) {
|
|
105
|
-
vectorStoreFiles.value.splice(0, 0, ...vs.files
|
|
106
|
-
if (
|
|
107
|
-
selectedVectorStoreFile.value =
|
|
110
|
+
vectorStoreFiles.value.splice(0, 0, ...Object.values(vs.files) as string[]);
|
|
111
|
+
if (vectorStoreFiles.value.length > 0) {
|
|
112
|
+
selectedVectorStoreFile.value = vectorStoreFiles.value[0];
|
|
108
113
|
}
|
|
109
114
|
}
|
|
110
115
|
}
|
|
@@ -120,8 +125,7 @@
|
|
|
120
125
|
initializeTools();
|
|
121
126
|
}
|
|
122
127
|
async function deleteVectorStore() {
|
|
123
|
-
|
|
124
|
-
if (!openAI.deleteVectorStore(id)) {
|
|
128
|
+
if (!openAI.deleteVectorStore(selectedVectorStoreName.value)) {
|
|
125
129
|
alert('Vector Store not deleted, error ! ');
|
|
126
130
|
return;
|
|
127
131
|
}
|
|
@@ -132,6 +136,13 @@
|
|
|
132
136
|
alert('File already exists, add a new file path or url !');
|
|
133
137
|
return;
|
|
134
138
|
}
|
|
139
|
+
if (fileHandle) {
|
|
140
|
+
const file = await fileHandle.getFile();
|
|
141
|
+
fileHandle = null;
|
|
142
|
+
if (!await openAI.addFile(file, selectedVectorStoreName.value)) {
|
|
143
|
+
alert('File not added, error ! ');
|
|
144
|
+
}
|
|
145
|
+
}
|
|
135
146
|
if (!await openAI.addFile(selectedVectorStoreFile.value, selectedVectorStoreName.value)) {
|
|
136
147
|
alert('File not added, error ! ');
|
|
137
148
|
}
|
|
@@ -145,13 +156,17 @@
|
|
|
145
156
|
if (!await openAI.deleteFile(fileId)) {
|
|
146
157
|
alert('File not deleted, error ! ');
|
|
147
158
|
}
|
|
159
|
+
else {
|
|
160
|
+
vectorStoreSelected();
|
|
161
|
+
}
|
|
148
162
|
}
|
|
149
163
|
async function searchFile() {
|
|
150
164
|
let files: FileSystemFileHandle[] = [];
|
|
151
165
|
try {
|
|
152
166
|
files = await (window as any).showOpenFilePicker();
|
|
153
167
|
if (files.length > 0) {
|
|
154
|
-
|
|
168
|
+
fileHandle = files[0];
|
|
169
|
+
selectedVectorStoreFile.value = fileHandle.name;
|
|
155
170
|
}
|
|
156
171
|
}
|
|
157
172
|
catch (e) {
|
|
@@ -162,91 +177,92 @@
|
|
|
162
177
|
</script>
|
|
163
178
|
|
|
164
179
|
<template>
|
|
165
|
-
<v-container fluid class="bg-office">
|
|
166
|
-
<
|
|
180
|
+
<v-container fluid class="bg-office overflow-y-auto">
|
|
181
|
+
<h4>OpenAI Settings</h4>
|
|
167
182
|
<v-row dense align="center">
|
|
168
183
|
<v-col cols="3">
|
|
169
|
-
<v-
|
|
184
|
+
<v-select v-model="options.model" :items="openAI.modelNames" hide-details density="compact"
|
|
185
|
+
label="Model" @update:modelValue="onOptionChange">
|
|
186
|
+
</v-select>
|
|
170
187
|
</v-col>
|
|
171
188
|
<v-col cols="2">
|
|
172
|
-
<v-select v-model="options.outputFormat" :items="outputFormats"
|
|
189
|
+
<v-select v-model="options.outputFormat" :items="outputFormats" hide-details density="compact"
|
|
173
190
|
label="Format" @update:modelValue="onOptionChange">
|
|
174
191
|
</v-select>
|
|
175
192
|
</v-col>
|
|
176
193
|
<v-col cols="2">
|
|
177
|
-
<v-select v-model="options.reasoning_effort_level" :items="reasoningEffortLevels"
|
|
194
|
+
<v-select v-model="options.reasoning_effort_level" :items="reasoningEffortLevels" hide-details density="compact"
|
|
178
195
|
label="Reasoning" @update:modelValue="onOptionChange">
|
|
179
196
|
</v-select>
|
|
180
197
|
</v-col>
|
|
181
198
|
<v-col cols="2">
|
|
182
|
-
<v-
|
|
199
|
+
<v-number-input v-model="options.max_output_tokens" control-variant="hidden" hide-details clearable label="Max Token" density="compact" @change="onOptionChange"></v-number-input>
|
|
183
200
|
</v-col>
|
|
184
201
|
<v-col cols="1">
|
|
185
|
-
<v-
|
|
202
|
+
<v-number-input v-model="options.temperature" control-variant="hidden" :precision="2" hide-details clearable label="Temperature" density="compact" @change="onOptionChange"></v-number-input>
|
|
186
203
|
</v-col>
|
|
187
204
|
<v-col cols="1">
|
|
188
|
-
<v-
|
|
205
|
+
<v-number-input v-model="options.top_p" control-variant="hidden" :precision="2" hide-details clearable label="Top P" density="compact" @change="onOptionChange"></v-number-input>
|
|
189
206
|
</v-col>
|
|
190
207
|
<v-col cols="1">
|
|
191
|
-
<v-checkbox v-model="options.store" label="Store" density="compact" @change="onOptionChange"></v-checkbox>
|
|
208
|
+
<v-checkbox v-model="options.store" label="Store" hide-details density="compact" @change="onOptionChange"></v-checkbox>
|
|
192
209
|
</v-col>
|
|
193
210
|
</v-row>
|
|
194
211
|
<v-row dense align="center">
|
|
195
212
|
<v-col cols="12">
|
|
196
|
-
<v-text-field v-model="options.instructions" type="string" label="System Message" density="compact" @change="onOptionChange"></v-text-field>
|
|
213
|
+
<v-text-field v-model="options.instructions" type="string" hide-details clearable label="System Message" density="compact" @change="onOptionChange"></v-text-field>
|
|
197
214
|
</v-col>
|
|
198
215
|
</v-row>
|
|
199
216
|
<template v-for="(tool, key) in tools">
|
|
200
217
|
<v-row v-if="tool.type == 'mcp'" dense align="center">
|
|
201
218
|
<v-col cols="2">
|
|
202
|
-
<v-text-field v-model="tool.server_label"
|
|
219
|
+
<v-text-field v-model="tool.server_label" type="string "hide-details disabled label="mcp" density="compact" @change="onToolChange"></v-text-field>
|
|
203
220
|
</v-col>
|
|
204
221
|
<v-col cols="4">
|
|
205
|
-
<v-text-field v-model="tool.server_url" type="string" label="Url" density="compact" @change="onToolChange"></v-text-field>
|
|
222
|
+
<v-text-field v-model="tool.server_url" type="string" hide-details clearable label="Url" density="compact" @change="onToolChange"></v-text-field>
|
|
206
223
|
</v-col>
|
|
207
224
|
<v-col cols="3">
|
|
208
|
-
<v-text-field v-model="tool.server_description" type="string" label="Description" density="compact"
|
|
225
|
+
<v-text-field v-model="tool.server_description" type="string" hide-details clearable label="Description" density="compact" @change="onToolChange"></v-text-field>
|
|
209
226
|
</v-col>
|
|
210
227
|
<v-col cols="2">
|
|
211
|
-
<v-select v-model="tool.require_approval" :items="mcpApprovals"
|
|
228
|
+
<v-select v-model="tool.require_approval" :items="mcpApprovals" hide-details
|
|
212
229
|
density="compact" label="Approval" @update:modelValue="onToolChange">
|
|
213
230
|
</v-select>
|
|
214
231
|
</v-col>
|
|
215
232
|
<v-col cols="1">
|
|
216
|
-
<v-checkbox v-model="use[key]" label="Use" density="compact" @update:modelValue="onUseChange"></v-checkbox>
|
|
233
|
+
<v-checkbox v-model="use[key]" label="Use" hide-details density="compact" @update:modelValue="onUseChange"></v-checkbox>
|
|
217
234
|
</v-col>
|
|
218
235
|
</v-row>
|
|
219
236
|
<v-row v-if="tool.type == 'file_search'" dense align="center">
|
|
220
237
|
<v-col cols="2">
|
|
221
|
-
<v-text-field :model-value="key"
|
|
238
|
+
<v-text-field :model-value="key" type="string" hide-details disabled label="file_search" density="compact" @change="onToolChange"></v-text-field>
|
|
222
239
|
</v-col>
|
|
223
240
|
<v-col cols="7">
|
|
224
|
-
<v-select v-model="fileSearch[key]" :items="vectorStoreNames" density="compact" multiple
|
|
225
|
-
label="Vector Stores" @update:modelValue="onToolChange">
|
|
241
|
+
<v-select v-model="fileSearch[key]" :items="vectorStoreNames" density="compact" multiple hide-details label="Vector Stores" @update:modelValue="onToolChange">
|
|
226
242
|
</v-select>
|
|
227
243
|
</v-col>
|
|
228
244
|
<v-col cols="2">
|
|
229
|
-
<v-
|
|
245
|
+
<v-number-input v-model="tool.max_num_results" control-variant="hidden" hide-details clearable label="Max Results" density="compact" @change="onToolChange"></v-number-input>
|
|
230
246
|
</v-col>
|
|
231
247
|
<v-col cols="1">
|
|
232
|
-
<v-checkbox v-model="use[key]" label="Use" density="compact" @update:modelValue="onUseChange"></v-checkbox>
|
|
248
|
+
<v-checkbox v-model="use[key]" label="Use" hide-details density="compact" @update:modelValue="onUseChange"></v-checkbox>
|
|
233
249
|
</v-col>
|
|
234
250
|
</v-row>
|
|
235
251
|
<v-row v-if="tool.type.startsWith('web_search')" dense align="center">
|
|
236
252
|
<v-col cols="2">
|
|
237
|
-
<v-text-field :model-value="key"
|
|
253
|
+
<v-text-field :model-value="key" type="string" hide-details disabled label="file_search" density="compact" @change="onToolChange"></v-text-field>
|
|
238
254
|
</v-col>
|
|
239
255
|
<v-col cols="2">
|
|
240
|
-
<v-text-field v-model="tool.user_location.country" type="string" label="Country" density="compact" @change="onToolChange"></v-text-field>
|
|
256
|
+
<v-text-field v-model="tool.user_location.country" type="string" hide-details clearable label="Country" density="compact" @change="onToolChange"></v-text-field>
|
|
241
257
|
</v-col>
|
|
242
258
|
<v-col cols="3">
|
|
243
|
-
<v-text-field v-model="tool.user_location.city" type="string" label="City" density="compact" @change="onToolChange"></v-text-field>
|
|
259
|
+
<v-text-field v-model="tool.user_location.city" type="string" hide-details clearable label="City" density="compact" @change="onToolChange"></v-text-field>
|
|
244
260
|
</v-col>
|
|
245
261
|
<v-col cols="4">
|
|
246
|
-
<v-text-field v-model="tool.user_location.region" type="string" label="Region" density="compact" @change="onToolChange"></v-text-field>
|
|
262
|
+
<v-text-field v-model="tool.user_location.region" type="string" hide-details clearable label="Region" density="compact" @change="onToolChange"></v-text-field>
|
|
247
263
|
</v-col>
|
|
248
264
|
<v-col cols="1">
|
|
249
|
-
<v-checkbox v-model="use[key]" label="Use" density="compact" @update:modelValue="onUseChange"></v-checkbox>
|
|
265
|
+
<v-checkbox v-model="use[key]" label="Use" hide-details density="compact" @update:modelValue="onUseChange"></v-checkbox>
|
|
250
266
|
</v-col>
|
|
251
267
|
</v-row>
|
|
252
268
|
</template>
|
|
@@ -270,43 +286,33 @@
|
|
|
270
286
|
</v-btn>
|
|
271
287
|
</v-col>
|
|
272
288
|
</v-row>
|
|
273
|
-
<
|
|
274
|
-
<v-
|
|
275
|
-
|
|
276
|
-
</
|
|
277
|
-
<v-
|
|
278
|
-
<v-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
<v-
|
|
285
|
-
VS
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
<v-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
<v-
|
|
294
|
-
FILE
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
<v-icon icon="$delete"></v-icon>
|
|
302
|
-
</v-btn>
|
|
303
|
-
</v-col>
|
|
304
|
-
<v-col cols="1">
|
|
305
|
-
<v-btn :class="bg-office" @click="addFile">
|
|
306
|
-
FILE
|
|
307
|
-
<v-icon icon="add"></v-icon>
|
|
308
|
-
</v-btn>
|
|
309
|
-
</v-col>
|
|
310
|
-
</v-row>
|
|
289
|
+
<template v-if="!props.ismobile && openAI.vectorStore">
|
|
290
|
+
<v-divider></v-divider>
|
|
291
|
+
<h4> </h4>
|
|
292
|
+
<h4>Vector Store</h4>
|
|
293
|
+
<v-row dense align="center">
|
|
294
|
+
<v-col cols="2">
|
|
295
|
+
<v-combobox v-model="selectedVectorStoreName" :items="vectorStoreNames" hide-details density="compact" @update:modelValue="vectorStoreSelected()"></v-combobox>
|
|
296
|
+
</v-col>
|
|
297
|
+
<v-col cols="1">
|
|
298
|
+
<v-btn variant="text" prepend-icon="$delete" @click="deleteVectorStore">VS</v-btn>
|
|
299
|
+
</v-col>
|
|
300
|
+
<v-col cols="1">
|
|
301
|
+
<v-btn variant="text" prepend-icon="$plus" @click="addVectorStore">VS</v-btn>
|
|
302
|
+
</v-col>
|
|
303
|
+
<v-col cols="5">
|
|
304
|
+
<v-combobox v-model="selectedVectorStoreFile" :items="vectorStoreFiles" hide-details density="compact"></v-combobox>
|
|
305
|
+
</v-col>
|
|
306
|
+
<v-col cols="1">
|
|
307
|
+
<v-btn variant="text" prepend-icon="$search" @click="searchFile">FILE</v-btn>
|
|
308
|
+
</v-col>
|
|
309
|
+
<v-col cols="1">
|
|
310
|
+
<v-btn variant="text" prepend-icon="$delete" @click="deleteFile">FILE</v-btn>
|
|
311
|
+
</v-col>
|
|
312
|
+
<v-col cols="1">
|
|
313
|
+
<v-btn variant="text" prepend-icon="$plus" @click="addFile">FILE</v-btn>
|
|
314
|
+
</v-col>
|
|
315
|
+
</v-row>
|
|
316
|
+
</template>
|
|
311
317
|
</v-container>
|
|
312
318
|
</template>
|