added warnings when no model is selected

This commit is contained in:
saloui 2023-05-14 12:56:13 +02:00
parent 2c53b86d84
commit 8c691b3102
2 changed files with 32 additions and 13 deletions

View File

@ -5,6 +5,16 @@
role="alert">
<div class="flex flex-row">
<slot>
<div v-if="success"
class="inline-flex items-center justify-center flex-shrink-0 w-8 h-8 text-green-500 bg-green-100 rounded-lg dark:bg-green-800 dark:text-green-200">
<i data-feather="check"></i>
<span class="sr-only">Check icon</span>
</div>
<div v-if="!success" class="inline-flex items-center justify-center flex-shrink-0 w-8 h-8 text-red-500 bg-red-100 rounded-lg dark:bg-red-800 dark:text-red-200">
<i data-feather="x"></i>
<span class="sr-only">Cross icon</span>
</div>
<div class="ml-3 text-sm font-normal">{{ message }}</div>
</slot>
</div>
@ -19,6 +29,7 @@
clip-rule="evenodd"></path>
</svg>
</button>
</div>
</div>
</template>
@ -34,12 +45,23 @@ export default {
data() {
return {
show: false,
success: true,
message: ''
};
},
methods: {
close() {
this.$emit('close')
this.show = false
},
showToast(message, duration_s=3, success= true){
this.success = success;
this.message = message;
this.show = true;
setTimeout(() => {
this.$emit('close')
this.show = false
}, duration_s*1000);
}
},
watch: {

View File

@ -131,13 +131,7 @@
</div>
</div>
<Toast :showProp="isCopiedToClipboard" @close="isCopiedToClipboard = false">
<div
class="inline-flex items-center justify-center flex-shrink-0 w-8 h-8 text-green-500 bg-green-100 rounded-lg dark:bg-green-800 dark:text-green-200">
<i data-feather="check"></i>
<span class="sr-only">Check icon</span>
</div>
<div class="ml-3 text-sm font-normal">Message content copied to clipboard!</div>
<Toast ref="toast">
</Toast>
</template>
@ -166,7 +160,7 @@ export default {
isSelectAll: false,
showConfirmation: false,
chime: new Audio("chime_aud.wav"),
isCopiedToClipboard: false,
showToast: false,
isSearch: false,
isDiscussionBottom: false,
}
@ -434,7 +428,8 @@ export default {
// "message":message,#markdown.markdown(message),
// "user_message_id": self.current_user_message_id,
// "ai_message_id": self.current_ai_message_id,
if(msg["status"]=="generation_started"){
console.log(msgObj);
if(msgObj["status"]=="generation_started"){
this.updateLastUserMsg(msgObj)
// Create response message
let responseMessage = {
@ -463,7 +458,10 @@ export default {
console.log("infos", msgObj)
}
else{
alert("It seems that no model has been loaded. Please download and install a model first, then try again.");
this.$refs.toast.showToast("It seems that no model has been loaded. Please download and install a model first, then try again.",4, false)
this.isGenerating = false
this.setDiscussionLoading(this.currentDiscussion.id, this.isGenerating)
this.chime.play()
}
},
sendMsg(msg) {
@ -750,15 +748,14 @@ export default {
this.chime.play()
},
copyToClipBoard(content) {
this.isCopiedToClipboard = true
this.$refs.toast.showToast("Copied to clipboard successfully")
nextTick(() => {
feather.replace()
})
},
closeToast() {
this.isCopiedToClipboard = false
this.showToast = false
},