@christianriedl/utils 1.0.141 → 1.0.142
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
|
@@ -81,9 +81,13 @@ export interface IComparisonFilter {
|
|
|
81
81
|
value: ItemType;
|
|
82
82
|
}
|
|
83
83
|
export interface ICompoundFilter {
|
|
84
|
-
filters: IComparisonFilter[]
|
|
84
|
+
filters: IComparisonFilter[];
|
|
85
85
|
type: 'and' | 'or';
|
|
86
86
|
}
|
|
87
|
+
export interface IOpenAIFilter {
|
|
88
|
+
fileFilter: ICompoundFilter;
|
|
89
|
+
vectorStoreFilter: Dictionary<string>;
|
|
90
|
+
}
|
|
87
91
|
export interface IOpenAIOptions {
|
|
88
92
|
model: string;
|
|
89
93
|
instructions?: string | null;
|
|
@@ -98,8 +102,8 @@ export interface IOpenAIService {
|
|
|
98
102
|
log: ILogger;
|
|
99
103
|
options: IOpenAIOptions;
|
|
100
104
|
modelNames: string[];
|
|
101
|
-
|
|
102
|
-
response(prompt: string | string[], tools?: string[], imageUrl?: string, json?: ISchema, fileSearchFilter?:
|
|
105
|
+
initializeModelNames(): Promise<boolean>;
|
|
106
|
+
response(prompt: string | string[], tools?: string[], imageUrl?: string, json?: ISchema, fileSearchFilter?: IOpenAIFilter): Promise<IResponseResult>;
|
|
103
107
|
clearContext(): void;
|
|
104
108
|
getModels(): Promise<string[]>;
|
|
105
109
|
}
|
|
@@ -139,6 +143,7 @@ export interface IOpenAIServiceWithVectorStore extends IOpenAIServiceWithTools {
|
|
|
139
143
|
vsMetadata: IDataItem[];
|
|
140
144
|
fileAttributes: IDataItem[];
|
|
141
145
|
initializeVectorStore(): Promise<boolean>;
|
|
146
|
+
initializeVectorStoreFiles(): Promise<boolean>;
|
|
142
147
|
getVectorStore(vectorStoreId: string): IVectorStore | undefined;
|
|
143
148
|
addVectorStore(vectorStoreName: string, metadata?: Dictionary<string>): Promise<boolean>;
|
|
144
149
|
addFile(fileUrl: string | File, vectorStoreName: string, attributes?: Dictionary<ItemType>, wait?: boolean): Promise<boolean>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { inject, ref, toRef, computed, onUnmounted } from 'vue';
|
|
3
3
|
import { appStateSymbol, appConfigSymbol, ESize, EDevice } from '@christianriedl/utils';
|
|
4
|
-
import { getOpenAISymbol, IOpenAIServiceWithVectorStore, IResponseResult,
|
|
4
|
+
import { getOpenAISymbol, IOpenAIServiceWithVectorStore, IResponseResult, IOpenAIFilter } from '@christianriedl/utils';
|
|
5
5
|
import Microphone from '@christianriedl/utils/src/components/Microphone.vue';
|
|
6
6
|
import Camera from '@christianriedl/utils/src/components/Camera.vue';
|
|
7
7
|
import OpenAIConfig from '@christianriedl/utils/src/components/OpenAIConfig.vue';
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
const camera = ref<InstanceType<typeof Camera>>();
|
|
31
31
|
const htmlText = ref('');
|
|
32
32
|
const tools = ref(props.tools);
|
|
33
|
-
const filter = ref<
|
|
33
|
+
const filter = ref<IOpenAIFilter | undefined>(undefined);
|
|
34
34
|
|
|
35
35
|
onUnmounted(() => {
|
|
36
36
|
openAI.clearContext();
|
|
@@ -153,10 +153,14 @@
|
|
|
153
153
|
return '';
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
-
function setFilter(
|
|
157
|
-
filter.value =
|
|
156
|
+
function setFilter(newFilter: IOpenAIFilter) {
|
|
157
|
+
filter.value = newFilter;
|
|
158
158
|
showFilter.value = false;
|
|
159
159
|
}
|
|
160
|
+
async function showConfigDialog() {
|
|
161
|
+
if (await openAI.initializeModelNames())
|
|
162
|
+
showConfig.value = true;
|
|
163
|
+
}
|
|
160
164
|
</script>
|
|
161
165
|
|
|
162
166
|
<template>
|
|
@@ -175,7 +179,7 @@
|
|
|
175
179
|
<v-btn variant="tonal" class="bg-office aibutton" @click="isUpload=true;replyLines=[]">
|
|
176
180
|
<v-icon size="large" icon="$image" color="primary"></v-icon>
|
|
177
181
|
</v-btn>
|
|
178
|
-
<v-btn variant="tonal" class="bg-office aibutton" @click="
|
|
182
|
+
<v-btn variant="tonal" class="bg-office aibutton" @click="showConfigDialog">
|
|
179
183
|
<v-icon size="large" icon="$settings" color="primary"></v-icon>
|
|
180
184
|
</v-btn>
|
|
181
185
|
</v-col>
|
|
@@ -211,7 +215,7 @@
|
|
|
211
215
|
<OpenAIConfig :tools="tools" :ismobile="isMobile" @use="onUse" @back="showConfig=false"></OpenAIConfig>
|
|
212
216
|
</v-dialog>
|
|
213
217
|
<v-dialog v-model="showFilter" :fullscreen="isMobile">
|
|
214
|
-
<OpenAIFilter :fileattributes="openAI.fileAttributes" :filter="filter" @back="setFilter"></OpenAIFilter>
|
|
218
|
+
<OpenAIFilter :vsmetadata="openAI.vsMetadata" :fileattributes="openAI.fileAttributes" :filter="filter" @back="setFilter"></OpenAIFilter>
|
|
215
219
|
</v-dialog>
|
|
216
220
|
</v-container>
|
|
217
221
|
</template>
|
|
@@ -147,8 +147,11 @@
|
|
|
147
147
|
fileSearch[name] = [];
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
-
function vectorStoreSelected() {
|
|
151
|
-
|
|
150
|
+
async function vectorStoreSelected() {
|
|
151
|
+
|
|
152
|
+
selectedVectorStoreFile.value = 'Get vectorestore files ...';
|
|
153
|
+
if (!await openAI.initializeVectorStoreFiles())
|
|
154
|
+
return;
|
|
152
155
|
const vs = openAI.vectorStore![selectedVectorStoreName.value];
|
|
153
156
|
vectorStoreFiles.value.splice(0, vectorStoreFiles.value.length);
|
|
154
157
|
if (vs) {
|
|
@@ -248,7 +251,7 @@
|
|
|
248
251
|
const mdCopy = Object.assign({}, md);
|
|
249
252
|
if (file.attributes && file.attributes[md.name])
|
|
250
253
|
mdCopy.value = file.attributes[md.name];
|
|
251
|
-
else if (vs && vs.metadata && vs.metadata[md.name])
|
|
254
|
+
else if (vs && vs.metadata && vs.metadata[md.name])
|
|
252
255
|
mdCopy.value = vs.metadata[md.name];
|
|
253
256
|
metadata.value.push(mdCopy);
|
|
254
257
|
}
|
|
@@ -1,24 +1,41 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { inject, computed, ref, StyleValue } from 'vue';
|
|
3
|
-
import { IDataItem, Dictionary, IComparisonFilter, ICompoundFilter } from '@christianriedl/utils'
|
|
3
|
+
import { IDataItem, Dictionary, IComparisonFilter, ICompoundFilter, IOpenAIFilter } from '@christianriedl/utils'
|
|
4
4
|
import SettingsLine from '../components/SettingsLine.vue';
|
|
5
5
|
|
|
6
|
-
const props = defineProps<{ fileattributes: IDataItem[], filter?:
|
|
7
|
-
const emits = defineEmits<{ (e: 'back', filter:
|
|
6
|
+
const props = defineProps<{ vsmetadata: IDataItem[], fileattributes: IDataItem[], filter?: IOpenAIFilter }>();
|
|
7
|
+
const emits = defineEmits<{ (e: 'back', filter: IOpenAIFilter): void }>();
|
|
8
8
|
const items: IDataItem[] = [];
|
|
9
|
-
const
|
|
9
|
+
const opsvs = ['', 'eq'];
|
|
10
|
+
const opsfile = ['', 'eq', 'ne', 'gt', 'gte', 'lt', 'lte'];
|
|
10
11
|
const operators: Dictionary<string> = {};;
|
|
12
|
+
const numvs = props.vsmetadata.length;
|
|
11
13
|
|
|
14
|
+
for (const it of props.vsmetadata) {
|
|
15
|
+
items.push(Object.assign({}, it));
|
|
16
|
+
operators[it.name] = '';
|
|
17
|
+
}
|
|
12
18
|
for (const it of props.fileattributes) {
|
|
13
19
|
items.push(Object.assign({}, it));
|
|
14
20
|
operators[it.name] = '';
|
|
15
21
|
}
|
|
16
22
|
if (props.filter) {
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
it
|
|
21
|
-
|
|
23
|
+
if (props.filter.fileFilter) {
|
|
24
|
+
for (const f of props.filter.fileFilter.filters) {
|
|
25
|
+
const it = items.find(i => i.name === f.key);
|
|
26
|
+
if (it) {
|
|
27
|
+
it.value = f.value;
|
|
28
|
+
operators[it.name] = f.type;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (props.filter.vectorStoreFilter) {
|
|
33
|
+
for (const name in props.filter.vectorStoreFilter) {
|
|
34
|
+
const it = items.find(i => i.name === name);
|
|
35
|
+
if (it) {
|
|
36
|
+
it.value = props.filter.vectorStoreFilter[name];
|
|
37
|
+
operators[it.name] = 'eq';
|
|
38
|
+
}
|
|
22
39
|
}
|
|
23
40
|
}
|
|
24
41
|
}
|
|
@@ -27,11 +44,20 @@
|
|
|
27
44
|
operators[item.name] = '';
|
|
28
45
|
}
|
|
29
46
|
function onBack() {
|
|
30
|
-
const filter:
|
|
31
|
-
|
|
47
|
+
const filter: IOpenAIFilter = {
|
|
48
|
+
fileFilter: { type: 'and', filters: [] },
|
|
49
|
+
vectorStoreFilter: {}
|
|
50
|
+
};
|
|
51
|
+
for (let i = 0; i < items.length; i++) {
|
|
52
|
+
const item = items[i];
|
|
32
53
|
if (operators[item.name]) {
|
|
33
|
-
|
|
34
|
-
|
|
54
|
+
if (i < numvs) {
|
|
55
|
+
filter.vectorStoreFilter[item.name] = item.value;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
const f: IComparisonFilter = { key: item.name, type: operators[item.name] as 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte', value: item.value };
|
|
59
|
+
filter.fileFilter.filters.push(f);
|
|
60
|
+
}
|
|
35
61
|
}
|
|
36
62
|
}
|
|
37
63
|
emits('back', filter);
|
|
@@ -53,7 +79,8 @@
|
|
|
53
79
|
</tr>
|
|
54
80
|
</thead>
|
|
55
81
|
<tbody>
|
|
56
|
-
<settings-line v-for="item in items" :key="item.name" :item="item" :op="operators[item.name]"
|
|
82
|
+
<settings-line v-for="(item, index) in items" :key="item.name" :item="item" :op="operators[item.name]"
|
|
83
|
+
:operations="index < numvs ? opsvs : opsfile" clearable @change="onChange(item, true)"
|
|
57
84
|
@clear="onChange(item, false)" @operation="(op) => onOperation(item, op)">
|
|
58
85
|
</settings-line>
|
|
59
86
|
<tr>
|