Refine Chat experience (#210)
Co-authored-by: AceDataCloud <office@acedata.cloud>
This commit is contained in:
1 parent
cb64d79755
commit
0fbdc3ac12
18 files changed
+1229
-780
No files matched your search
@@ -1,63 +1,44 @@
|
||||
<template>
|
||||
<div class="input-box">
|
||||
<div class="composer">
|
||||
<div class="tools">
|
||||
<el-upload
|
||||
v-model:file-list="fileList"
|
||||
:class="{
|
||||
upload: true,
|
||||
disabled: !_isUploadEnabled
|
||||
disabled: !model.isFileSupported || disabled
|
||||
}"
|
||||
:disabled="!_isUploadEnabled"
|
||||
:disabled="!model.isFileSupported || disabled"
|
||||
name="file"
|
||||
:show-file-list="true"
|
||||
:limit="10"
|
||||
:multiple="false"
|
||||
:multiple="true"
|
||||
:action="uploadUrl"
|
||||
list-type="picture"
|
||||
:on-exceed="onExceed"
|
||||
:on-error="onError"
|
||||
:on-progress="onProgress"
|
||||
:headers="headers"
|
||||
>
|
||||
<template #file="{ file }">
|
||||
<image-preview
|
||||
v-if="isImageUrl(file.name)"
|
||||
:url="file.url || file.response?.file_url"
|
||||
:name="file.name"
|
||||
:percentage="file.percentage"
|
||||
@remove="fileList.splice(fileList.indexOf(file), 1)"
|
||||
/>
|
||||
<file-preview
|
||||
v-else
|
||||
:name="file.name"
|
||||
:percentage="file.percentage"
|
||||
@remove="fileList.splice(fileList.indexOf(file), 1)"
|
||||
/>
|
||||
</template>
|
||||
<el-tooltip class="box-item" effect="dark" :content="$t('chat.message.uploadFile')" placement="bottom">
|
||||
<span :class="{ btn: true, 'btn-upload': true, disabled: !_isUploadEnabled }">
|
||||
<span :class="{ btn: true, 'btn-upload': true, disabled: !model.isFileSupported || disabled }">
|
||||
<font-awesome-icon icon="fa-solid fa-plus" class="icon icon-attachment" />
|
||||
</span>
|
||||
</el-tooltip>
|
||||
</el-upload>
|
||||
<span
|
||||
v-if="['chatgpt'].includes(modelGroup.name)"
|
||||
:class="{ btn: true, 'btn-search': true, active: _isSearchActive, disabled: !isSearchEnabled }"
|
||||
@click="
|
||||
_isSearchActive = !_isSearchActive;
|
||||
_isReasonActive = false;
|
||||
_isDeepsearchActive = false;
|
||||
"
|
||||
>
|
||||
<font-awesome-icon icon="fa-solid fa-globe" class="icon icon-search" />
|
||||
{{ $t('chat.button.search') }}
|
||||
</span>
|
||||
<span
|
||||
v-if="['grok'].includes(modelGroup.name)"
|
||||
:class="{ btn: true, 'btn-deepsearch': true, active: _isDeepsearchActive, disabled: !isDeepsearchEnabled }"
|
||||
@click="
|
||||
_isDeepsearchActive = !_isDeepsearchActive;
|
||||
_isReasonActive = false;
|
||||
_isSearchActive = false;
|
||||
"
|
||||
>
|
||||
<font-awesome-icon icon="fa-solid fa-globe" class="icon icon-deepsearch" />
|
||||
{{ $t('chat.button.deepsearch') }}
|
||||
</span>
|
||||
<span
|
||||
v-if="['chatgpt', 'grok', 'deepseek'].includes(modelGroup.name)"
|
||||
:class="{ btn: true, 'btn-reason': true, active: _isReasonActive, disabled: !isReasonEnabled }"
|
||||
@click="
|
||||
_isReasonActive = !_isReasonActive;
|
||||
_isDeepsearchActive = false;
|
||||
"
|
||||
>
|
||||
<font-awesome-icon icon="fa-regular fa-lightbulb" class="icon icon-reason" />
|
||||
{{ $t('chat.button.thinkDeeper') }}
|
||||
</span>
|
||||
</div>
|
||||
<span
|
||||
v-show="!disabled"
|
||||
@@ -81,7 +62,6 @@
|
||||
>
|
||||
<font-awesome-icon icon="fa-solid fa-stop" class="icon icon-stop" />
|
||||
</span>
|
||||
<!-- add this textarea -->
|
||||
<textarea
|
||||
ref="textarea"
|
||||
v-model="questionValue"
|
||||
@@ -97,15 +77,18 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElMessage, ElTooltip, ElUpload } from 'element-plus';
|
||||
import { ElMessage, ElTooltip, ElUpload, UploadFile, UploadFiles, UploadProgressEvent } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { IChatModel } from '@/models';
|
||||
import { getBaseUrlPlatform } from '@/utils';
|
||||
import { CHAT_MODEL_GROUP_DEEPSEEK, CHAT_MODEL_GROUP_GROK } from '@/constants';
|
||||
import { getBaseUrlPlatform, isImageUrl } from '@/utils';
|
||||
import FilePreview from './FilePreview.vue';
|
||||
import ImagePreview from './ImagePreview.vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'InputBox',
|
||||
name: 'Composer',
|
||||
components: {
|
||||
FilePreview,
|
||||
ImagePreview,
|
||||
ElTooltip,
|
||||
FontAwesomeIcon,
|
||||
ElUpload
|
||||
@@ -124,71 +107,21 @@ export default defineComponent({
|
||||
question: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
isSearchEnabled: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: true
|
||||
},
|
||||
isDeepsearchEnabled: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: true
|
||||
},
|
||||
isReasonEnabled: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: true
|
||||
},
|
||||
isUploadEnabled: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: true
|
||||
},
|
||||
isSearchActive: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: false
|
||||
},
|
||||
isDeepsearchActive: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: false
|
||||
},
|
||||
isReasonActive: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
emits: [
|
||||
'update:question',
|
||||
'update:references',
|
||||
'submit',
|
||||
'stop',
|
||||
'update:isSearchActive',
|
||||
'update:isReasonActive',
|
||||
'update:isUploadEnabled',
|
||||
'update:isSearchEnabled',
|
||||
'update:isReasonEnabled',
|
||||
'update:isDeepsearchEnabled',
|
||||
'update:isDeepsearchActive'
|
||||
],
|
||||
emits: ['update:question', 'update:references', 'submit', 'stop'],
|
||||
data() {
|
||||
return {
|
||||
inputHeight: '35px', //add inputHeight
|
||||
inputHeight: '35px',
|
||||
questionValue: this.question,
|
||||
fileList: [],
|
||||
// eslint-disable-next-line vue/no-reserved-keys
|
||||
_isSearchActive: this.isSearchActive,
|
||||
// eslint-disable-next-line vue/no-reserved-keys
|
||||
_isReasonActive: this.isReasonActive,
|
||||
// eslint-disable-next-line vue/no-reserved-keys
|
||||
_isDeepsearchActive: this.isDeepsearchActive,
|
||||
fileList: [] as UploadFile[],
|
||||
uploadUrl: getBaseUrlPlatform() + '/api/v1/files/'
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
model(): IChatModel {
|
||||
return this.$store.state.chat.model;
|
||||
},
|
||||
modelGroup() {
|
||||
return this.$store.state.chat.modelGroup;
|
||||
},
|
||||
@@ -200,58 +133,14 @@ export default defineComponent({
|
||||
urls(): string[] {
|
||||
// @ts-ignore
|
||||
return this.fileList.map((file: UploadFile) => file?.response?.file_url);
|
||||
},
|
||||
_isUploadEnabled() {
|
||||
return (
|
||||
!this._isSearchActive &&
|
||||
!this._isReasonActive &&
|
||||
this.modelGroup.name !== CHAT_MODEL_GROUP_DEEPSEEK.name &&
|
||||
this.modelGroup.name !== CHAT_MODEL_GROUP_GROK.name
|
||||
);
|
||||
},
|
||||
_isSearchEnabled() {
|
||||
return !this._isReasonActive && !this.isDeepsearchActive && !this.urls.length;
|
||||
},
|
||||
_isDeepsearchEnabled() {
|
||||
return !this._isReasonActive && !this._isSearchActive && !this.urls.length;
|
||||
},
|
||||
_isReasonEnabled() {
|
||||
return !this._isSearchActive && !this.isDeepsearchActive && !this.urls.length;
|
||||
},
|
||||
model(): IChatModel {
|
||||
return this.$store.state.chat.model;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
modelGroup() {
|
||||
this._isReasonActive = false;
|
||||
this._isSearchActive = false;
|
||||
this._isDeepsearchActive = false;
|
||||
},
|
||||
urls(val) {
|
||||
this.$emit('update:references', val);
|
||||
},
|
||||
_isUploadEnabled(val: boolean) {
|
||||
this.$emit('update:isUploadEnabled', val);
|
||||
},
|
||||
_isSearchEnabled(val: boolean) {
|
||||
this.$emit('update:isSearchEnabled', val);
|
||||
},
|
||||
_isDeepsearchEnabled(val: boolean) {
|
||||
this.$emit('update:isDeepsearchEnabled', val);
|
||||
},
|
||||
_isReasonEnabled(val: boolean) {
|
||||
this.$emit('update:isReasonEnabled', val);
|
||||
},
|
||||
_isSearchActive(val: boolean) {
|
||||
this.$emit('update:isSearchActive', val);
|
||||
},
|
||||
_isDeepsearchActive(val: boolean) {
|
||||
console.log('deepsearch', val);
|
||||
this.$emit('update:isDeepsearchActive', val);
|
||||
},
|
||||
_isReasonActive(val: boolean) {
|
||||
this.$emit('update:isReasonActive', val);
|
||||
console.debug('File URLs:', val);
|
||||
if (val.length > 0) {
|
||||
this.$emit('update:references', val);
|
||||
}
|
||||
},
|
||||
questionValue(val: string) {
|
||||
this.$emit('update:question', val);
|
||||
@@ -261,28 +150,15 @@ export default defineComponent({
|
||||
this.questionValue = val;
|
||||
}
|
||||
},
|
||||
isReasonActive(val: boolean) {
|
||||
if (val !== this._isReasonActive) {
|
||||
this._isReasonActive = val;
|
||||
}
|
||||
},
|
||||
isSearchActive(val: boolean) {
|
||||
if (val !== this._isSearchActive) {
|
||||
this._isSearchActive = val;
|
||||
}
|
||||
},
|
||||
isDeepsearchActive(val: boolean) {
|
||||
if (val !== this._isDeepsearchActive) {
|
||||
this._isDeepsearchActive = val;
|
||||
}
|
||||
},
|
||||
references(val: string[]) {
|
||||
console.debug('References updated:', val);
|
||||
if (val.length === 0) {
|
||||
this.fileList = [];
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
isImageUrl,
|
||||
// add textarea method
|
||||
adjustTextareaHeight() {
|
||||
this.$nextTick(() => {
|
||||
@@ -304,6 +180,9 @@ export default defineComponent({
|
||||
onStop() {
|
||||
this.$emit('stop');
|
||||
},
|
||||
onProgress(evt: UploadProgressEvent, uploadFile: UploadFile, uploadFiles: UploadFiles) {
|
||||
console.debug('File upload progress:', uploadFile.name, evt.loaded, evt.total);
|
||||
},
|
||||
onExceed() {
|
||||
ElMessage.warning(this.$t('chat.message.uploadReferencesExceed'));
|
||||
},
|
||||
@@ -331,7 +210,7 @@ textarea.input {
|
||||
textarea.input:focus {
|
||||
outline: none;
|
||||
}
|
||||
.input-box {
|
||||
.composer {
|
||||
position: relative;
|
||||
.input {
|
||||
textarea {
|
||||
@@ -345,8 +224,28 @@ textarea.input:focus {
|
||||
}
|
||||
.el-upload-list {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
bottom: 135px;
|
||||
bottom: -5px;
|
||||
left: 50px;
|
||||
height: 50px;
|
||||
width: 700px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
overflow-x: auto;
|
||||
gap: 5px;
|
||||
overflow-y: scroll;
|
||||
flex-wrap: wrap;
|
||||
.el-upload-list__item {
|
||||
margin: 0;
|
||||
width: fit-content;
|
||||
height: 50px;
|
||||
padding: 0;
|
||||
border-radius: 10px;
|
||||
position: relative;
|
||||
}
|
||||
}
|
||||
|
||||
.el-textarea.is-disabled .el-textarea__inner {
|
||||
@@ -356,7 +255,7 @@ textarea.input:focus {
|
||||
</style>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.input-box {
|
||||
.composer {
|
||||
width: 100%;
|
||||
max-width: 800px;
|
||||
margin: auto;
|
||||
@@ -417,45 +316,6 @@ textarea.input:focus {
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
}
|
||||
&.btn-search {
|
||||
color: var(--el-text-color-primary);
|
||||
border-radius: 20px;
|
||||
padding: 0 10px;
|
||||
font-size: 16px;
|
||||
&.active {
|
||||
border: 1px solid var(--el-color-primary);
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
.icon-search {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
&.btn-reason {
|
||||
color: var(--el-text-color-primary);
|
||||
border-radius: 20px;
|
||||
padding: 0 10px;
|
||||
font-size: 16px;
|
||||
&.active {
|
||||
border: 1px solid var(--el-color-primary);
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
.icon-reason {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
&.btn-deepsearch {
|
||||
color: var(--el-text-color-primary);
|
||||
border-radius: 20px;
|
||||
padding: 0 10px;
|
||||
font-size: 16px;
|
||||
&.active {
|
||||
border: 1px solid var(--el-color-primary);
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
.icon-deepsearch {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.btn-send,
|
||||
@@ -0,0 +1,46 @@
|
||||
<template>
|
||||
<span>
|
||||
<el-tooltip effect="dark" :content="$t('common.button.restart')" placement="bottom">
|
||||
<font-awesome-icon icon="fa-solid fa-edit" class="icon icon-edit" @click="onEdit" />
|
||||
</el-tooltip>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { ElTooltip } from 'element-plus';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'EditMessage',
|
||||
components: {
|
||||
FontAwesomeIcon,
|
||||
ElTooltip
|
||||
},
|
||||
props: {
|
||||
messages: {
|
||||
type: Array,
|
||||
required: false,
|
||||
default: () => []
|
||||
}
|
||||
},
|
||||
emits: ['click'],
|
||||
data() {
|
||||
return {
|
||||
copied: false
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
onEdit() {
|
||||
this.$emit('click');
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.icon-edit {
|
||||
cursor: pointer;
|
||||
color: inherit;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,127 @@
|
||||
<template>
|
||||
<div class="file">
|
||||
<div class="left">
|
||||
<div class="wrapper">
|
||||
<font-awesome-icon icon="fa-regular fa-file-alt" />
|
||||
<el-progress
|
||||
v-show="percentage && percentage < 100"
|
||||
type="circle"
|
||||
:stroke-width="3"
|
||||
:percentage="percentage"
|
||||
:width="25"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right">
|
||||
<span class="text-xs font-bold truncate">{{ name }}</span>
|
||||
</div>
|
||||
<div v-if="closable" class="close">
|
||||
<font-awesome-icon icon="fa-solid fa-xmark" class="icon icon-close" @click="$emit('remove')" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { ElProgress } from 'element-plus';
|
||||
import { isImageUrl } from '@/utils/is';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'FilePreview',
|
||||
components: {
|
||||
FontAwesomeIcon,
|
||||
ElProgress
|
||||
},
|
||||
props: {
|
||||
name: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
percentage: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
closable: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: true
|
||||
}
|
||||
},
|
||||
emits: ['remove'],
|
||||
methods: {
|
||||
isImageUrl
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.file {
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
border-radius: 10px;
|
||||
height: 50px;
|
||||
width: 250px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
background-color: var(--el-bg-color);
|
||||
.el-progress {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
z-index: 10;
|
||||
margin: auto;
|
||||
}
|
||||
.left {
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
.wrapper {
|
||||
position: relative;
|
||||
width: 35px;
|
||||
height: 35px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 10px;
|
||||
color: white;
|
||||
background-color: #10a37f;
|
||||
margin: auto;
|
||||
}
|
||||
}
|
||||
.right {
|
||||
width: calc(100% - 60px);
|
||||
height: 50px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
padding-left: 2px;
|
||||
font-size: 14px;
|
||||
color: var(--el-text-color-primary);
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.close {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 5px;
|
||||
right: 5px;
|
||||
background-color: rgba(0, 0, 0, 0.7);
|
||||
color: white;
|
||||
width: 15px;
|
||||
border-radius: 50%;
|
||||
height: 15px;
|
||||
display: flex;
|
||||
font-size: 10px;
|
||||
text-align: center;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,86 @@
|
||||
<template>
|
||||
<div class="image">
|
||||
<img class="size-10" :src="url" :alt="name" />
|
||||
<el-progress
|
||||
v-show="percentage && percentage < 100"
|
||||
type="circle"
|
||||
:stroke-width="3"
|
||||
:percentage="percentage"
|
||||
:width="30"
|
||||
/>
|
||||
<div v-if="closable" class="close">
|
||||
<font-awesome-icon icon="fa-solid fa-xmark" class="icon icon-close" @click.stop="$emit('remove')" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { ElProgress } from 'element-plus';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ImagePreview',
|
||||
components: {
|
||||
FontAwesomeIcon,
|
||||
ElProgress
|
||||
},
|
||||
props: {
|
||||
url: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
percentage: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
closable: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: true
|
||||
}
|
||||
},
|
||||
emits: ['remove']
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.image {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
position: relative;
|
||||
.close {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 5px;
|
||||
right: 5px;
|
||||
background-color: rgba(0, 0, 0, 0.7);
|
||||
color: white;
|
||||
width: 15px;
|
||||
border-radius: 50%;
|
||||
height: 15px;
|
||||
display: flex;
|
||||
font-size: 10px;
|
||||
text-align: center;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.el-progress {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
z-index: 10;
|
||||
margin: auto;
|
||||
}
|
||||
img {
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -10,17 +10,19 @@
|
||||
<el-image v-if="message.role === 'assistant'" :src="modelGroup.icon" fit="cover" class="avatar" />
|
||||
</div>
|
||||
<div v-if="!errorText" class="main">
|
||||
<div class="content">
|
||||
<div class="edit-left">
|
||||
<el-tooltip
|
||||
v-if="message.role === 'user' && !isEditing && !Array.isArray(message.content)"
|
||||
effect="dark"
|
||||
:content="$t('chat.button.edit')"
|
||||
placement="bottom"
|
||||
>
|
||||
<font-awesome-icon icon="fa-solid fa-edit" class="icon icon-edit" @click="startEditing" />
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<div
|
||||
v-motion
|
||||
:initial="{ opacity: 0, y: 5 }"
|
||||
:enter="{ opacity: 1, y: 0, scale: 1 }"
|
||||
:delay="200"
|
||||
:duration="300"
|
||||
:layout="true"
|
||||
:transition="{
|
||||
enter: { delay: 0.2, duration: 0.5 },
|
||||
layout: { duration: 0.3, easing: 'ease-in-out' }
|
||||
}"
|
||||
class="content"
|
||||
>
|
||||
<div v-if="!isEditing" class="message-content">
|
||||
<markdown-renderer v-if="!Array.isArray(message.content)" :content="message?.content" />
|
||||
<div v-else>
|
||||
@@ -31,33 +33,39 @@
|
||||
fit="cover"
|
||||
class="image"
|
||||
/>
|
||||
<span v-if="item.type === 'file_url'" class="file">
|
||||
<font-awesome-icon icon="fa-regular fa-file" class="icon icon-file" />
|
||||
{{
|
||||
typeof item?.file_url === 'string'
|
||||
? item.file_url?.split('/')?.slice(-1)?.[0]
|
||||
: item.file_url?.url?.split('/')?.slice(-1)?.[0]
|
||||
}}
|
||||
</span>
|
||||
<file-preview
|
||||
v-if="item.file_url"
|
||||
:name="typeof item?.file_url === 'string' ? item.file_url : item.file_url?.url"
|
||||
:percentage="0"
|
||||
:closable="false"
|
||||
class="mt-2"
|
||||
/>
|
||||
<markdown-renderer v-if="item.type === 'text'" :key="index" :content="item.text" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="chat-container">
|
||||
<div v-else class="edits">
|
||||
<el-input
|
||||
v-model="questionValue"
|
||||
type="textarea"
|
||||
class="chat-input"
|
||||
class="mb-2"
|
||||
@keydown.enter.exact.prevent="onEdit"
|
||||
></el-input>
|
||||
<div class="button-group">
|
||||
<el-button size="small" round @click="cancelEdit">{{ $t('common.button.cancel') }}</el-button>
|
||||
<el-button type="primary" size="small" round @click="onEdit">{{ $t('common.button.confirm') }}</el-button>
|
||||
<div class="flex justify-end">
|
||||
<el-button round @click="cancelEdit">{{ $t('common.button.cancel') }}</el-button>
|
||||
<el-button type="primary" class="btn-confirm" round @click="onEdit">{{
|
||||
$t('common.button.confirm')
|
||||
}}</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<answering-mark v-if="message.state === messageState.PENDING" />
|
||||
</div>
|
||||
<div class="operations">
|
||||
<edit-message
|
||||
v-if="message.role === 'user' && !isEditing && !Array.isArray(message.content)"
|
||||
class="btn-edit"
|
||||
@click="startEditing"
|
||||
/>
|
||||
<copy-to-clipboard
|
||||
v-if="
|
||||
!Array.isArray(message.content) &&
|
||||
@@ -96,6 +104,9 @@ import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { IApplication, IChatMessage, IChatMessageState } from '@/models';
|
||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||
import RestartToGenerate from './RestartToGenerate.vue';
|
||||
import EditMessage from './EditMessage.vue';
|
||||
import FilePreview from './FilePreview.vue';
|
||||
import ImagePreview from './ImagePreview.vue';
|
||||
import {
|
||||
ERROR_CODE_API_ERROR,
|
||||
ERROR_CODE_BAD_REQUEST,
|
||||
@@ -120,15 +131,15 @@ interface IData {
|
||||
export default defineComponent({
|
||||
name: 'Message',
|
||||
components: {
|
||||
EditMessage,
|
||||
CopyToClipboard,
|
||||
RestartToGenerate,
|
||||
AnsweringMark,
|
||||
MarkdownRenderer,
|
||||
ElAlert,
|
||||
FilePreview,
|
||||
ElButton,
|
||||
ElImage,
|
||||
ElTooltip,
|
||||
FontAwesomeIcon,
|
||||
ElInput
|
||||
},
|
||||
props: {
|
||||
@@ -179,7 +190,7 @@ export default defineComponent({
|
||||
case ERROR_CODE_NOT_APPLIED:
|
||||
return this.$t('chat.message.errorNotApplied');
|
||||
case ERROR_CODE_CANCELED:
|
||||
return undefined; // 不显示错误框
|
||||
return undefined;
|
||||
case ERROR_CODE_UNKNOWN:
|
||||
default:
|
||||
return this.$t('chat.message.errorUnknown');
|
||||
@@ -200,11 +211,9 @@ export default defineComponent({
|
||||
this.isEditing = false;
|
||||
},
|
||||
onRestart() {
|
||||
// Implement the logic to save the edited content
|
||||
this.$emit('restart', this.message);
|
||||
},
|
||||
onEdit() {
|
||||
// Implement the logic to save the edited content
|
||||
this.isEditing = false;
|
||||
this.onSubmit();
|
||||
},
|
||||
@@ -297,55 +306,32 @@ export default defineComponent({
|
||||
text-align: left;
|
||||
max-width: 100%;
|
||||
position: relative;
|
||||
.edit-left {
|
||||
position: absolute;
|
||||
left: -25px; /* Adjust as needed */
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
.chat-container {
|
||||
// background-color: var(--el-bg-color-page);
|
||||
// color: var(--el-text-color-primary);
|
||||
padding: 10px;
|
||||
min-width: 400px;
|
||||
.edits {
|
||||
background-color: var(--el-bg-color-page);
|
||||
padding: 0;
|
||||
min-width: 500px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
.chat-input {
|
||||
// background-color: var(--el-bg-color-page);
|
||||
// color: var(--el-text-color-primary);
|
||||
padding-bottom: 30px; /* 为按钮预留空间 */
|
||||
}
|
||||
|
||||
.button-group {
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
right: 10px;
|
||||
font-size: 16px;
|
||||
.btn-confirm {
|
||||
background-color: var(--el-color-black);
|
||||
border-color: var(--el-color-black);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.content {
|
||||
border-radius: 20px;
|
||||
padding: 8px 12px;
|
||||
border-radius: 10px;
|
||||
padding: 8px 15px;
|
||||
width: 100%;
|
||||
max-width: 800px;
|
||||
margin-bottom: 10px;
|
||||
margin-bottom: 5px;
|
||||
.image {
|
||||
max-width: 100%;
|
||||
max-height: 300px;
|
||||
margin: 5px 0;
|
||||
border-radius: 10px;
|
||||
}
|
||||
.file {
|
||||
display: block;
|
||||
margin: 5px 0;
|
||||
border-radius: 10px;
|
||||
padding: 5px 10px;
|
||||
background-color: var(--el-bg-color);
|
||||
color: var(--el-text-color-regular);
|
||||
border: 1px solid var(--el-border-color);
|
||||
font-size: 14px;
|
||||
}
|
||||
.edit-area {
|
||||
width: 100%;
|
||||
min-height: 100px;
|
||||
@@ -358,23 +344,51 @@ export default defineComponent({
|
||||
justify-content: flex-end;
|
||||
gap: 10px;
|
||||
}
|
||||
.icon-edit {
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
color: var(--el-text-color-regular);
|
||||
}
|
||||
}
|
||||
|
||||
.operations {
|
||||
display: flex; // Use flexbox for better alignment
|
||||
gap: 10px; // Adjust the gap value as needed
|
||||
margin-left: 5px; // Adjust the value as needed
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-left: 5px;
|
||||
color: var(--el-text-color-regular);
|
||||
.btn-edit {
|
||||
visibility: hidden;
|
||||
}
|
||||
.btn-restart {
|
||||
font-size: 14px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.btn-copy {
|
||||
font-size: 14px;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
&:hover {
|
||||
.operations {
|
||||
.btn-edit {
|
||||
visibility: visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss">
|
||||
.message {
|
||||
&.user {
|
||||
.content {
|
||||
.edits {
|
||||
textarea {
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
border-radius: 0;
|
||||
resize: none;
|
||||
font-size: 16px;
|
||||
border-color: var(--el-bg-color-page);
|
||||
resize: none;
|
||||
background-color: var(--el-bg-color-page);
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="selector">
|
||||
<el-dropdown trigger="click" popper-class="popper">
|
||||
<div class="flex align-center justify-center">
|
||||
<div class="flex justify-center mr-1">
|
||||
<span class="icon">
|
||||
<img :src="modelGroup.icon" />
|
||||
</span>
|
||||
@@ -12,7 +12,7 @@
|
||||
</div>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item v-for="(option, optionKey) in options" :key="optionKey" @click="onCommandChange(option)">
|
||||
<el-dropdown-item v-for="(option, optionKey) in options" :key="optionKey" @click="onModelGroupChange(option)">
|
||||
<div class="item">
|
||||
<div class="icon">
|
||||
<img :src="option.icon" />
|
||||
@@ -26,6 +26,30 @@
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
<el-dropdown trigger="click" popper-class="popper">
|
||||
<div class="flex justify-center">
|
||||
<span class="name">{{ model?.getDisplayName() }}</span>
|
||||
<span class="angle">
|
||||
<font-awesome-icon icon="fa-solid fa-angle-down" />
|
||||
</span>
|
||||
</div>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu v-if="modelGroup && modelGroup.models">
|
||||
<el-dropdown-item
|
||||
v-for="(option, optionKey) in modelGroup.models"
|
||||
:key="optionKey"
|
||||
@click="onModelChange(option)"
|
||||
>
|
||||
<div class="item">
|
||||
<div class="info">
|
||||
<p v-if="option.getDisplayName" class="name">{{ option.getDisplayName() }}</p>
|
||||
<p v-if="option.getDescription" class="description">{{ option.getDescription() }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -48,7 +72,7 @@ export default defineComponent({
|
||||
ElDropdownItem,
|
||||
FontAwesomeIcon
|
||||
},
|
||||
emits: ['update:modelValue', 'select'],
|
||||
emits: ['update:modelValue', 'select', 'model-group-changed', 'model-changed'],
|
||||
data(): IData {
|
||||
return {
|
||||
options: [CHAT_MODEL_GROUP_CHATGPT, CHAT_MODEL_GROUP_DEEPSEEK, CHAT_MODEL_GROUP_GROK]
|
||||
@@ -56,13 +80,43 @@ export default defineComponent({
|
||||
},
|
||||
computed: {
|
||||
modelGroup() {
|
||||
console.log('modelGroup', this.$store.state.chat.modelGroup);
|
||||
return this.$store.state.chat.modelGroup;
|
||||
},
|
||||
model() {
|
||||
console.log('model', this.$store.state.chat.model);
|
||||
return this.$store.state.chat.model;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
// set first model when modelGroup changes
|
||||
modelGroup(newValue: IChatModelGroup) {
|
||||
console.debug('ModelSelector modelGroup changed', newValue);
|
||||
this.$store.dispatch('chat/setModel', newValue.models[0]);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.modelGroup) {
|
||||
console.debug('ModelSelector mounted, setting default model group');
|
||||
this.$store.dispatch('chat/setModelGroup', CHAT_MODEL_GROUP_CHATGPT);
|
||||
} else {
|
||||
// renew models if modelGroup is already set
|
||||
console.debug('ModelSelector mounted, checking model group');
|
||||
const modelGroups = [CHAT_MODEL_GROUP_CHATGPT, CHAT_MODEL_GROUP_DEEPSEEK, CHAT_MODEL_GROUP_GROK];
|
||||
const foundGroup = modelGroups.find((group) => group.name === this.modelGroup.name);
|
||||
if (foundGroup) {
|
||||
this.$store.dispatch('chat/setModelGroup', foundGroup);
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onCommandChange(modelGroup: IChatModelGroup) {
|
||||
this.$emit('select', modelGroup);
|
||||
onModelGroupChange(modelGroup: IChatModelGroup) {
|
||||
this.$store.dispatch('chat/setModelGroup', modelGroup);
|
||||
this.$emit('model-group-changed', modelGroup);
|
||||
},
|
||||
onModelChange(model: IChatModelGroup['models'][number]) {
|
||||
this.$store.dispatch('chat/setModel', model);
|
||||
this.$emit('model-changed', model);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -89,7 +143,7 @@ export default defineComponent({
|
||||
}
|
||||
.angle {
|
||||
display: inline-block;
|
||||
max-width: 5px;
|
||||
width: 15px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
v-for="(conversation, conversationIndex) in conversations"
|
||||
:key="conversationIndex"
|
||||
:class="{ conversation: true, active: conversation.id === conversationId }"
|
||||
@click="onClick(conversation.id)"
|
||||
@click="onClickConversation(conversation.id)"
|
||||
>
|
||||
<div class="title">
|
||||
<span v-if="conversation?.deleting">
|
||||
@@ -87,9 +87,10 @@ export default defineComponent({
|
||||
ElSkeleton
|
||||
},
|
||||
props: {},
|
||||
emits: ['click'],
|
||||
emits: ['change-conversation'],
|
||||
computed: {
|
||||
conversationId() {
|
||||
console.debug('conversationId in side', this.$route.params?.id);
|
||||
return this.$route.params?.id?.toString();
|
||||
},
|
||||
conversationGroups() {
|
||||
@@ -146,9 +147,8 @@ export default defineComponent({
|
||||
},
|
||||
methods: {
|
||||
async onNewConversation() {
|
||||
this.$router.push({
|
||||
name: ROUTE_CHAT_CONVERSATION_NEW
|
||||
});
|
||||
console.debug('onNewConversation from side panel');
|
||||
this.$emit('change-conversation', undefined);
|
||||
},
|
||||
async onConfirm(conversation: IChatConversation) {
|
||||
const token = this.token;
|
||||
@@ -170,17 +170,9 @@ export default defineComponent({
|
||||
conversation.editing = true;
|
||||
}
|
||||
},
|
||||
onClick(id: string) {
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
this.$router.push({
|
||||
name: ROUTE_CHAT_CONVERSATION,
|
||||
params: {
|
||||
id
|
||||
}
|
||||
});
|
||||
this.$emit('click', id);
|
||||
onClickConversation(id?: string) {
|
||||
console.debug('onClickConversation in side panel', id);
|
||||
this.$emit('change-conversation', id);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user