This commit is contained in:
Mike Liao 2024-07-04 11:31:20 -07:00
parent 57f5bffac6
commit 565113ff41
6 changed files with 72 additions and 64 deletions

View File

@ -1,6 +1,11 @@
<template> <template>
<div class="input_containter"> <div class="input_containter">
<input class="input_text" type="text" v-model="input_text" @keyup.enter="image_generation($event)" /> <input
class="input_text"
type="text"
v-model="input_text"
@keyup.enter="image_generation($event)"
/>
<img class="responded_image" :src="responded_image" /> <img class="responded_image" :src="responded_image" />
</div> </div>
</template> </template>
@ -45,4 +50,3 @@
@extend .w-100; @extend .w-100;
} }
</style> </style>

View File

@ -14,15 +14,15 @@ export default {
methods: { methods: {
lets_chat($event) { lets_chat($event) {
this.messages.push({ this.messages.push({
"role": "user", role: 'user',
"content": this.input_text content: this.input_text
}) })
LabApi.multiturn_chat(this.messages) LabApi.multiturn_chat(this.messages)
.then((response) => { .then((response) => {
this.responded_text = response.data this.responded_text = response.data
this.messages.push({ this.messages.push({
"role": "assistant", role: 'assistant',
"content": this.responded_text content: this.responded_text
}) })
}) })
.catch((error) => { .catch((error) => {
@ -33,9 +33,7 @@ export default {
data() { data() {
return { return {
input_text: null, input_text: null,
messages: [ messages: [{ role: 'system', content: 'You are a helpful assistant.' }],
{ "role": "system", "content": "You are a helpful assistant." }
],
responded_text: null responded_text: null
} }
} }
@ -56,4 +54,3 @@ export default {
@extend .w-100; @extend .w-100;
} }
</style> </style>

View File

@ -1,6 +1,11 @@
<template> <template>
<div class="input_containter"> <div class="input_containter">
<input class="input_text" type="text" v-model="input_text" @keyup.enter="task_completion($event)" /> <input
class="input_text"
type="text"
v-model="input_text"
@keyup.enter="task_completion($event)"
/>
<p class="responded_text">{{ responded_text }}</p> <p class="responded_text">{{ responded_text }}</p>
</div> </div>
</template> </template>
@ -45,4 +50,3 @@ export default {
@extend .w-100; @extend .w-100;
} }
</style> </style>

View File

@ -109,7 +109,7 @@ export default {
computed: { computed: {
conversations() { conversations() {
return this.$store.getters['basic/conversations'] return this.$store.getters['basic/conversations']
}, }
}, },
watch: { watch: {
conversations(n_val) { conversations(n_val) {

View File

@ -72,7 +72,11 @@ const basicStore = {
} }
const conversation = conversations[0] const conversation = conversations[0]
if (conversation?.id) { if (conversation?.id) {
MessageHubApi.fetchMessages(conversation.id, conversation.message_update_time ? conversation.message_update_time : GWT, token).then((response) => { MessageHubApi.fetchMessages(
conversation.id,
conversation.message_update_time ? conversation.message_update_time : GWT,
token
).then((response) => {
conversations[0].messages = response?.data || [] conversations[0].messages = response?.data || []
conversations[0].message_update_time = new Date().toISOString() conversations[0].message_update_time = new Date().toISOString()
state.conversations = conversations state.conversations = conversations

View File

@ -53,7 +53,6 @@ class LabApi {
} }
) )
return request return request
} }
} }
export { LabApi } export { LabApi }