adjust frontend to new backend

This commit is contained in:
wea_ondara
2024-05-27 19:05:54 +02:00
parent 8b60d023e8
commit 265a5f3063
67 changed files with 5506 additions and 703 deletions

View File

@@ -1,34 +1,34 @@
<script lang="ts">
import {Options, Vue} from 'vue-class-component';
import {Prop} from "vue-property-decorator";
import AiInstanceApi from "@/data/api/AiInstanceApi";
import type {AiInstance} from "@/data/models/AiInstance";
import {toast} from "vue3-toastify";
import type {ChatMessage} from "@/data/models/chat/ChatMessage";
import {BSpinner} from "bootstrap-vue-next";
import {Prop} from 'vue-property-decorator';
import {toast} from 'vue3-toastify';
import {BSpinner} from 'bootstrap-vue-next';
import {AiInstanceVmV1, ChatMessageVmV1} from 'ai-oas';
import {ApiStore} from '@/stores/ApiStore';
import Spinner from '@/components/Spinner.vue';
@Options({
name: 'Chat',
components: {BSpinner},
components: {
Spinner,
},
})
export default class Chat extends Vue {
@Prop({required: true})
readonly aiInstance!: AiInstance;
readonly aiInstanceApi = new AiInstanceApi();
readonly aiInstance!: AiInstanceVmV1;
readonly apiStore = new ApiStore();
user: string = 'alice';
text: string = '';
waiting: boolean = false;
message: ChatMessage | null = null;
message: ChatMessageVmV1 | null = null;
async send(): Promise<void> {
this.waiting = true;
try {
this.message = {'role': 'user', 'name': this.user, 'content': this.text};
this.message = ChatMessageVmV1.fromJson({'role': 'user', 'name': this.user, 'content': this.text});
this.text = '';
const response = await this.aiInstanceApi.chatText(this.aiInstance.configuration.name, this.message);
debugger;
await this.apiStore.aiApi.chatText(this.aiInstance.configuration.id, this.message);
this.aiInstance.messages.push(this.message);
this.aiInstance.messages.push(response);
} catch (e) {
toast.error('Error while chatting: ' + JSON.stringify(e));
} finally {
@@ -65,7 +65,7 @@ export default class Chat extends Vue {
</div>
<div v-if="waiting">
<b>{{ message!.name }}</b>{{ ': ' + message!.content }}
<Spinner/>
<Spinner style="text-secondary" :size="1"/>
</div>
</div>
<div class="input-group">