@christianriedl/utils 1.0.96 → 1.0.97
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 +1 -1
- package/dist/iOpenAI.js +1 -1
- package/dist/iOpenAI.js.map +1 -1
- package/package.json +1 -1
- package/src/components/OpenAI.vue +48 -0
package/dist/iOpenAI.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InjectionKey } from 'vue';
|
|
2
2
|
import { ISpeechService } from './iAudio';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const getOpenAISymbol: InjectionKey<IOpenAIService>;
|
|
4
4
|
export interface ICompleteData {
|
|
5
5
|
choices: string[];
|
|
6
6
|
}
|
package/dist/iOpenAI.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const getOpenAISymbol = Symbol('get-openai');
|
|
2
2
|
//# sourceMappingURL=iOpenAI.js.map
|
package/dist/iOpenAI.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iOpenAI.js","sourceRoot":"","sources":["../src/iOpenAI.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"iOpenAI.js","sourceRoot":"","sources":["../src/iOpenAI.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,eAAe,GAAiC,MAAM,CAAC,YAAY,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { inject, ref, toRef, computed } from 'vue';
|
|
3
|
+
import { appStateSymbol, appConfigSymbol, getOpenAISymbol, IOpenAIService, ICompleteData, ESize } from '@christianriedl/utils';
|
|
4
|
+
import Microphone from '@christianriedl/utils/src/components/Microphone.vue';
|
|
5
|
+
|
|
6
|
+
const props = defineProps<{ prompt: string }>();
|
|
7
|
+
|
|
8
|
+
const getOpenAI = inject(getOpenAISymbol)!;
|
|
9
|
+
const openAI = getOpenAI();
|
|
10
|
+
const appState = inject(appStateSymbol)!;
|
|
11
|
+
const appConfig = inject(appConfigSymbol)!;
|
|
12
|
+
const question = toRef(props, "prompt");
|
|
13
|
+
const replyLines = ref<string[]>([]);
|
|
14
|
+
const qcols = computed(() => appState.size.value >= ESize.md ? 11 : 10);
|
|
15
|
+
|
|
16
|
+
async function onComplete() {
|
|
17
|
+
replyLines.value = [ "WAITING ..." ];
|
|
18
|
+
const answer = await openAI.complete(question.value);
|
|
19
|
+
if (answer && answer.choices && answer.choices.length > 0) {
|
|
20
|
+
replyLines.value = answer.choices[0].split('\n');
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
replyLines.value = [ "NO CORRECT ANSWER" ];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function onResult(result: SpeechRecognitionResult) {
|
|
27
|
+
question.value = result.item(0).transcript;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<template>
|
|
33
|
+
<v-container fluid class="bg-office">
|
|
34
|
+
<v-row dense align="center" class="font-weight-bold">
|
|
35
|
+
<v-col :cols="qcols">
|
|
36
|
+
<v-text-field name="subject" type="text" v-model="question" density="compact" hide-details></v-text-field>
|
|
37
|
+
</v-col>
|
|
38
|
+
<v-col :cols="12 - qcols">
|
|
39
|
+
<v-btn @click="onComplete">AI</v-btn>
|
|
40
|
+
<microphone lang="de" @result="onResult"></microphone>
|
|
41
|
+
</v-col>
|
|
42
|
+
</v-row>
|
|
43
|
+
<v-row v-for="(line, index) in replyLines" :key=index dense align="center">
|
|
44
|
+
<v-col cols="12">{{line}}</v-col>
|
|
45
|
+
</v-row>
|
|
46
|
+
</v-container>
|
|
47
|
+
</template>
|
|
48
|
+
|