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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+23
-61
@@ -5,20 +5,15 @@ export const ROLE_SYSTEM = 'system';
|
||||
export const ROLE_ASSISTANT = 'assistant';
|
||||
export const ROLE_USER = 'user';
|
||||
|
||||
export const CHAT_MODEL_NAME_GPT_3_5 = 'gpt-3.5';
|
||||
export const CHAT_MODEL_NAME_GPT_3_5_BROWSING = 'gpt-3.5-browsing';
|
||||
export const CHAT_MODEL_NAME_GPT_4 = 'gpt-4';
|
||||
export const CHAT_MODEL_NAME_GPT_4_BROWSING = 'gpt-4-browsing';
|
||||
export const CHAT_MODEL_NAME_GPT_4_VISION = 'gpt-4-vision';
|
||||
export const CHAT_MODEL_NAME_GPT_4_ALL = 'gpt-4-all';
|
||||
export const CHAT_MODEL_NAME_GPT_4O = 'gpt-4o';
|
||||
export const CHAT_MODEL_NAME_O1 = 'o1';
|
||||
export const CHAT_MODEL_NAME_O1_MINI = 'o1-mini';
|
||||
export const CHAT_MODEL_NAME_O3_MINI = 'o3-mini';
|
||||
export const CHAT_MODEL_NAME_DEEPSEEK_CHAT = 'deepseek-chat';
|
||||
export const CHAT_MODEL_NAME_DEEPSEEK_REASONER = 'deepseek-reasoner';
|
||||
export const CHAT_MODEL_NAME_DEEPSEEK_CHAT = 'deepseek-v3';
|
||||
export const CHAT_MODEL_NAME_DEEPSEEK_REASONER = 'deepseek-r1';
|
||||
export const CHAT_MODEL_NAME_GROK_3 = 'grok-3';
|
||||
export const CHAT_MODEL_NAME_GROK_3_REASONER = 'grok-3-reasoner';
|
||||
export const CHAT_MODEL_NAME_GROK_3_REASONER = 'grok-3-reasoning';
|
||||
export const CHAT_MODEL_NAME_GROK_3_DEEPSEARCH = 'grok-3-deepsearch';
|
||||
|
||||
export const CHAT_MODEL_ICON_OPENAI = 'https://cdn.acedata.cloud/7dljuv.png';
|
||||
@@ -27,44 +22,11 @@ export const CHAT_MODEL_ICON_DEEPSEEK = 'https://cdn.acedata.cloud/bc71ae.png';
|
||||
|
||||
export const CHAT_SERVICE_ID = 'b1fbcc32-e218-4253-9dc3-4fe600a1bfb9';
|
||||
|
||||
export const CHAT_MODEL_GPT_3_5: IChatModel = {
|
||||
name: CHAT_MODEL_NAME_GPT_3_5,
|
||||
icon: CHAT_MODEL_ICON_OPENAI,
|
||||
getDisplayName: () => i18n.global.t('chat.model.35Standard'),
|
||||
getDescription: () => i18n.global.t('chat.model.35StandardDescription')
|
||||
};
|
||||
|
||||
export const CHAT_MODEL_GPT_3_5_BROWSING: IChatModel = {
|
||||
name: CHAT_MODEL_NAME_GPT_3_5_BROWSING,
|
||||
icon: CHAT_MODEL_ICON_OPENAI,
|
||||
getDisplayName: () => i18n.global.t('chat.model.35Browsing'),
|
||||
getDescription: () => i18n.global.t('chat.model.35BrowsingDescription')
|
||||
};
|
||||
|
||||
export const CHAT_MODEL_GPT_4: IChatModel = {
|
||||
name: CHAT_MODEL_NAME_GPT_4,
|
||||
icon: CHAT_MODEL_ICON_OPENAI,
|
||||
getDisplayName: () => i18n.global.t('chat.model.4Standard'),
|
||||
getDescription: () => i18n.global.t('chat.model.4StandardDescription')
|
||||
};
|
||||
|
||||
export const CHAT_MODEL_GPT_4_BROWSING: IChatModel = {
|
||||
name: CHAT_MODEL_NAME_GPT_4_BROWSING,
|
||||
icon: CHAT_MODEL_ICON_OPENAI,
|
||||
getDisplayName: () => i18n.global.t('chat.model.4Browsing'),
|
||||
getDescription: () => i18n.global.t('chat.model.4BrowsingDescription')
|
||||
};
|
||||
|
||||
export const CHAT_MODEL_GPT_4_VISION: IChatModel = {
|
||||
name: CHAT_MODEL_NAME_GPT_4_VISION,
|
||||
icon: CHAT_MODEL_ICON_OPENAI,
|
||||
getDisplayName: () => i18n.global.t('chat.model.4Vision'),
|
||||
getDescription: () => i18n.global.t('chat.model.4VisionDescription')
|
||||
};
|
||||
|
||||
export const CHAT_MODEL_GPT_4_ALL: IChatModel = {
|
||||
name: CHAT_MODEL_NAME_GPT_4_ALL,
|
||||
icon: CHAT_MODEL_ICON_OPENAI,
|
||||
modelGroup: 'chatgpt',
|
||||
isFileSupported: true,
|
||||
getDisplayName: () => i18n.global.t('chat.model.4All'),
|
||||
getDescription: () => i18n.global.t('chat.model.4AllDescription')
|
||||
};
|
||||
@@ -72,6 +34,8 @@ export const CHAT_MODEL_GPT_4_ALL: IChatModel = {
|
||||
export const CHAT_MODEL_GPT_4O: IChatModel = {
|
||||
name: CHAT_MODEL_NAME_GPT_4O,
|
||||
icon: CHAT_MODEL_ICON_OPENAI,
|
||||
modelGroup: 'chatgpt',
|
||||
isFileSupported: true,
|
||||
getDisplayName: () => i18n.global.t('chat.model.4O'),
|
||||
getDescription: () => i18n.global.t('chat.model.4ODescription')
|
||||
};
|
||||
@@ -79,6 +43,7 @@ export const CHAT_MODEL_GPT_4O: IChatModel = {
|
||||
export const CHAT_MODEL_DEEPSEEK_CHAT: IChatModel = {
|
||||
name: CHAT_MODEL_NAME_DEEPSEEK_CHAT,
|
||||
icon: CHAT_MODEL_ICON_DEEPSEEK,
|
||||
modelGroup: 'deepseek',
|
||||
getDisplayName: () => i18n.global.t('chat.model.deepseekChat'),
|
||||
getDescription: () => i18n.global.t('chat.model.deepseekChatDescription')
|
||||
};
|
||||
@@ -86,6 +51,7 @@ export const CHAT_MODEL_DEEPSEEK_CHAT: IChatModel = {
|
||||
export const CHAT_MODEL_DEEPSEEK_REASONER: IChatModel = {
|
||||
name: CHAT_MODEL_NAME_DEEPSEEK_REASONER,
|
||||
icon: CHAT_MODEL_ICON_DEEPSEEK,
|
||||
modelGroup: 'deepseek',
|
||||
getDisplayName: () => i18n.global.t('chat.model.deepseekReasoner'),
|
||||
getDescription: () => i18n.global.t('chat.model.deepseekReasonerDescription')
|
||||
};
|
||||
@@ -93,6 +59,7 @@ export const CHAT_MODEL_DEEPSEEK_REASONER: IChatModel = {
|
||||
export const CHAT_MODEL_O1: IChatModel = {
|
||||
name: CHAT_MODEL_NAME_O1,
|
||||
icon: CHAT_MODEL_ICON_OPENAI,
|
||||
modelGroup: 'chatgpt',
|
||||
getDisplayName: () => i18n.global.t('chat.model.o1'),
|
||||
getDescription: () => i18n.global.t('chat.model.o1Description')
|
||||
};
|
||||
@@ -100,6 +67,7 @@ export const CHAT_MODEL_O1: IChatModel = {
|
||||
export const CHAT_MODEL_O1_MINI: IChatModel = {
|
||||
name: CHAT_MODEL_NAME_O1_MINI,
|
||||
icon: CHAT_MODEL_ICON_OPENAI,
|
||||
modelGroup: 'chatgpt',
|
||||
getDisplayName: () => i18n.global.t('chat.model.o1Mini'),
|
||||
getDescription: () => i18n.global.t('chat.model.o1MiniDescription')
|
||||
};
|
||||
@@ -107,6 +75,7 @@ export const CHAT_MODEL_O1_MINI: IChatModel = {
|
||||
export const CHAT_MODEL_O3_MINI: IChatModel = {
|
||||
name: CHAT_MODEL_NAME_O3_MINI,
|
||||
icon: CHAT_MODEL_ICON_OPENAI,
|
||||
modelGroup: 'chatgpt',
|
||||
getDisplayName: () => i18n.global.t('chat.model.o3Mini'),
|
||||
getDescription: () => i18n.global.t('chat.model.o3MiniDescription')
|
||||
};
|
||||
@@ -114,6 +83,7 @@ export const CHAT_MODEL_O3_MINI: IChatModel = {
|
||||
export const CHAT_MODEL_GROK_3: IChatModel = {
|
||||
name: CHAT_MODEL_NAME_GROK_3,
|
||||
icon: CHAT_MODEL_ICON_GROK,
|
||||
modelGroup: 'grok',
|
||||
getDisplayName: () => i18n.global.t('chat.model.grok3'),
|
||||
getDescription: () => i18n.global.t('chat.model.grok3Description')
|
||||
};
|
||||
@@ -121,6 +91,7 @@ export const CHAT_MODEL_GROK_3: IChatModel = {
|
||||
export const CHAT_MODEL_GROK_3_REASONER: IChatModel = {
|
||||
name: CHAT_MODEL_NAME_GROK_3_REASONER,
|
||||
icon: CHAT_MODEL_ICON_GROK,
|
||||
modelGroup: 'grok',
|
||||
getDisplayName: () => i18n.global.t('chat.model.grok3Reasoner'),
|
||||
getDescription: () => i18n.global.t('chat.model.grok3ReasonerDescription')
|
||||
};
|
||||
@@ -128,6 +99,7 @@ export const CHAT_MODEL_GROK_3_REASONER: IChatModel = {
|
||||
export const CHAT_MODEL_GROK_3_DEEPSEARCH: IChatModel = {
|
||||
name: CHAT_MODEL_NAME_GROK_3_DEEPSEARCH,
|
||||
icon: CHAT_MODEL_ICON_GROK,
|
||||
modelGroup: 'grok',
|
||||
getDisplayName: () => i18n.global.t('chat.model.grok3Deepsearch'),
|
||||
getDescription: () => i18n.global.t('chat.model.grok3DeepsearchDescription')
|
||||
};
|
||||
@@ -137,18 +109,7 @@ export const CHAT_MODEL_GROUP_CHATGPT: IChatModelGroup = {
|
||||
name: 'chatgpt',
|
||||
getDisplayName: () => i18n.global.t('chat.modelGroup.chatgpt'),
|
||||
getDescription: () => i18n.global.t('chat.modelGroup.chatgptDescription'),
|
||||
models: [
|
||||
CHAT_MODEL_GPT_3_5,
|
||||
CHAT_MODEL_GPT_3_5_BROWSING,
|
||||
CHAT_MODEL_GPT_4,
|
||||
CHAT_MODEL_GPT_4_BROWSING,
|
||||
CHAT_MODEL_GPT_4_VISION,
|
||||
CHAT_MODEL_GPT_4_ALL,
|
||||
CHAT_MODEL_GPT_4O,
|
||||
CHAT_MODEL_O1,
|
||||
CHAT_MODEL_O1_MINI,
|
||||
CHAT_MODEL_O3_MINI
|
||||
]
|
||||
models: [CHAT_MODEL_GPT_4O, CHAT_MODEL_GPT_4_ALL, CHAT_MODEL_O1, CHAT_MODEL_O3_MINI]
|
||||
};
|
||||
|
||||
export const CHAT_MODEL_GROUP_DEEPSEEK: IChatModelGroup = {
|
||||
@@ -168,13 +129,8 @@ export const CHAT_MODEL_GROUP_GROK: IChatModelGroup = {
|
||||
};
|
||||
|
||||
export const CHAT_MODELS: IChatModel[] = [
|
||||
CHAT_MODEL_GPT_3_5,
|
||||
CHAT_MODEL_GPT_3_5_BROWSING,
|
||||
CHAT_MODEL_GPT_4,
|
||||
CHAT_MODEL_GPT_4_BROWSING,
|
||||
CHAT_MODEL_GPT_4_VISION,
|
||||
CHAT_MODEL_GPT_4_ALL,
|
||||
CHAT_MODEL_GPT_4O,
|
||||
CHAT_MODEL_GPT_4_ALL,
|
||||
CHAT_MODEL_O1,
|
||||
CHAT_MODEL_O1_MINI,
|
||||
CHAT_MODEL_O3_MINI,
|
||||
@@ -184,3 +140,9 @@ export const CHAT_MODELS: IChatModel[] = [
|
||||
CHAT_MODEL_GROK_3_REASONER,
|
||||
CHAT_MODEL_GROK_3_DEEPSEARCH
|
||||
];
|
||||
|
||||
export const CHAT_MODEL_GROUPS: IChatModelGroup[] = [
|
||||
CHAT_MODEL_GROUP_CHATGPT,
|
||||
CHAT_MODEL_GROUP_DEEPSEEK,
|
||||
CHAT_MODEL_GROUP_GROK
|
||||
];
|
||||
+21
-57
@@ -39,56 +39,20 @@
|
||||
"message": "xAI 公司开发的 AI 模型",
|
||||
"description": "Grok3 模型的描述"
|
||||
},
|
||||
"model.35Standard": {
|
||||
"message": "ChatGPT - 3.5 标准",
|
||||
"description": "服务的模型名称,即 GPT 3.5 基础"
|
||||
},
|
||||
"model.35StandardDescription": {
|
||||
"message": "适用于日常任务。",
|
||||
"description": "3.5 标准模型的描述"
|
||||
},
|
||||
"model.35Browsing": {
|
||||
"message": "ChatGPT - 3.5 联网",
|
||||
"description": "服务的模型名称,即 GPT 3.5 联网"
|
||||
},
|
||||
"model.35BrowsingDescription": {
|
||||
"message": "可以实时检索信息。",
|
||||
"description": "3.5 浏览模型的描述"
|
||||
},
|
||||
"model.4Standard": {
|
||||
"message": "ChatGPT - 4.0 标准",
|
||||
"description": "服务的模型名称,即 GPT 4.0 标准"
|
||||
},
|
||||
"model.4StandardDescription": {
|
||||
"message": "更强大的模型,适用于复杂任务。",
|
||||
"description": "4.0 标准模型的描述"
|
||||
},
|
||||
"model.4Browsing": {
|
||||
"message": "ChatGPT - 4.0 联网",
|
||||
"description": "服务的模型名称,即 GPT 4.0 联网"
|
||||
},
|
||||
"model.4BrowsingDescription": {
|
||||
"message": "强大且实时检索信息。",
|
||||
"description": "4.0 浏览模型的描述"
|
||||
},
|
||||
"model.4Vision": {
|
||||
"message": "ChatGPT - 4.0 视觉",
|
||||
"description": "服务的模型名称,即 GPT 4.0 视觉"
|
||||
},
|
||||
"model.4O": {
|
||||
"message": "ChatGPT - 4.0 视觉",
|
||||
"message": "gpt-4o",
|
||||
"description": "服务的模型名称,即 GPT 4.0 视觉"
|
||||
},
|
||||
"model.4ODescription": {
|
||||
"message": "可以分析图像。",
|
||||
"message": "适用于绝大多数任务",
|
||||
"description": "4.0 视觉模型的描述"
|
||||
},
|
||||
"model.4All": {
|
||||
"message": "ChatGPT - 4.0 全能",
|
||||
"message": "gpt-4-all",
|
||||
"description": "服务的模型名称,即 GPT 4.0 All"
|
||||
},
|
||||
"model.4VisionDescription": {
|
||||
"message": "可以分析图像。",
|
||||
"message": "全能模型,可联网,可处理图片",
|
||||
"description": "4.0 视觉模型的描述"
|
||||
},
|
||||
"model.4AllDescription": {
|
||||
@@ -96,51 +60,51 @@
|
||||
"description": "4.0 全能模型的描述"
|
||||
},
|
||||
"model.deepseekChat": {
|
||||
"message": "DeepSeek - 3.0 标准",
|
||||
"message": "3.0 标准",
|
||||
"description": "服务的模型名称,即 DeepSeek 聊天"
|
||||
},
|
||||
"model.deepseekChatDescription": {
|
||||
"message": "适用于日常任务。",
|
||||
"message": "适用于日常任务",
|
||||
"description": "DeepSeek 聊天模型的描述"
|
||||
},
|
||||
"model.deepseekReasoner": {
|
||||
"message": "DeepSeek - R1 推理",
|
||||
"message": "R1 推理",
|
||||
"description": "服务的模型名称,即 DeepSeek 推理"
|
||||
},
|
||||
"model.deepseekReasonerDescription": {
|
||||
"message": "适用于推理和解决问题。",
|
||||
"message": "适用于推理和深度思考问题",
|
||||
"description": "DeepSeek 推理模型的描述"
|
||||
},
|
||||
"model.grok3": {
|
||||
"message": "Grok3",
|
||||
"message": "grok-3",
|
||||
"description": "服务的模型名称"
|
||||
},
|
||||
"model.grok3Description": {
|
||||
"message": "Grok3 公司开发的 AI 模型",
|
||||
"message": "适用于大多数任务",
|
||||
"description": "Grok3 模型的描述"
|
||||
},
|
||||
"model.grok3Reasoner": {
|
||||
"message": "Grok3 - R1 推理",
|
||||
"message": "grok-3 推理",
|
||||
"description": "服务的模型名称,即 Grok3 推理"
|
||||
},
|
||||
"model.grok3ReasonerDescription": {
|
||||
"message": "适用于推理和解决问题。",
|
||||
"message": "适用于推理和深度思考问题",
|
||||
"description": "Grok3 推理模型的描述"
|
||||
},
|
||||
"model.grok3Deepsearch": {
|
||||
"message": "Grok3 - 3.0 深度搜索",
|
||||
"description": "服务的模型名称,即 Grok3 深度搜索"
|
||||
"message": "grok-3 深度研究",
|
||||
"description": "服务的模型名称,即 Grok3 深度研究"
|
||||
},
|
||||
"model.grok3DeepsearchDescription": {
|
||||
"message": "可以实时检索信息。",
|
||||
"description": "Grok3 深度搜索模型的描述"
|
||||
"message": "适用于深度研究和复杂问题",
|
||||
"description": "Grok3 深度研究模型的描述"
|
||||
},
|
||||
"model.o1": {
|
||||
"message": "ChatGPT - o1 推理",
|
||||
"message": "o1",
|
||||
"description": "服务的模型名称,即 O1"
|
||||
},
|
||||
"model.o1Description": {
|
||||
"message": "适用于日常任务。",
|
||||
"message": "适用于更高级推理任务",
|
||||
"description": "O1 模型的描述"
|
||||
},
|
||||
"model.o1Mini": {
|
||||
@@ -148,15 +112,15 @@
|
||||
"description": "服务的模型名称,即 O1-Mini"
|
||||
},
|
||||
"model.o1MiniDescription": {
|
||||
"message": "适用于日常任务。",
|
||||
"message": "更快速进行推理任务。",
|
||||
"description": "O1-Mini 模型的描述"
|
||||
},
|
||||
"model.o3Mini": {
|
||||
"message": "ChatGPT - o3-mini 推理",
|
||||
"message": "o3-mini",
|
||||
"description": "服务的模型名称,即 O3-Mini"
|
||||
},
|
||||
"model.o3MiniDescription": {
|
||||
"message": "适用于日常任务。",
|
||||
"message": "适用于更高级推理任务",
|
||||
"description": "O3-Mini 模型的描述"
|
||||
},
|
||||
"message.startNewChat": {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="main">
|
||||
<div class="side">
|
||||
<slot name="side">
|
||||
<side-panel />
|
||||
<side-panel @change-conversation="onChangeConversation" />
|
||||
</slot>
|
||||
</div>
|
||||
<div class="chat">
|
||||
@@ -24,6 +24,7 @@ import UserCenter from '@/components/user/Center.vue';
|
||||
import SidePanel from '@/components/chat/SidePanel.vue';
|
||||
import { ElDrawer, ElButton } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { on } from 'events';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'LayoutChat',
|
||||
@@ -34,10 +35,17 @@ export default defineComponent({
|
||||
ElButton,
|
||||
FontAwesomeIcon
|
||||
},
|
||||
emits: ['change-conversation'],
|
||||
data() {
|
||||
return {
|
||||
drawer: false
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
onChangeConversation(id?: string) {
|
||||
console.debug('onChangeConversation in layout', id);
|
||||
this.$emit('change-conversation', id);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -8,6 +8,7 @@ import './assets/css/tailwind.css';
|
||||
import 'mac-scrollbar/dist/mac-scrollbar.css';
|
||||
import dayjs from './plugins/dayjs';
|
||||
import './plugins/font-awesome';
|
||||
import { MotionPlugin } from '@vueuse/motion';
|
||||
import { vLoading } from 'element-plus';
|
||||
import {
|
||||
initializeCookies,
|
||||
@@ -46,10 +47,12 @@ const main = async () => {
|
||||
app.use(router);
|
||||
app.use(store);
|
||||
app.use(i18n);
|
||||
app.use(MotionPlugin);
|
||||
app.use(dayjs, {
|
||||
formatString: 'YYYY-MM-DD HH:mm:ss'
|
||||
});
|
||||
app.directive('loading', vLoading);
|
||||
// app.use(createMotionPlugin());
|
||||
app.mount('#app');
|
||||
console.debug('app mounted');
|
||||
|
||||
|
||||
+6
-10
@@ -2,11 +2,6 @@ import {
|
||||
ROLE_ASSISTANT,
|
||||
ROLE_SYSTEM,
|
||||
ROLE_USER,
|
||||
CHAT_MODEL_NAME_GPT_3_5,
|
||||
CHAT_MODEL_NAME_GPT_3_5_BROWSING,
|
||||
CHAT_MODEL_NAME_GPT_4,
|
||||
CHAT_MODEL_NAME_GPT_4_BROWSING,
|
||||
CHAT_MODEL_NAME_GPT_4_VISION,
|
||||
CHAT_MODEL_NAME_GPT_4_ALL,
|
||||
CHAT_MODEL_NAME_GPT_4O,
|
||||
CHAT_MODEL_NAME_O1,
|
||||
@@ -20,11 +15,6 @@ import {
|
||||
} from '@/constants';
|
||||
|
||||
export type IChatModelName =
|
||||
| typeof CHAT_MODEL_NAME_GPT_3_5
|
||||
| typeof CHAT_MODEL_NAME_GPT_3_5_BROWSING
|
||||
| typeof CHAT_MODEL_NAME_GPT_4
|
||||
| typeof CHAT_MODEL_NAME_GPT_4_BROWSING
|
||||
| typeof CHAT_MODEL_NAME_GPT_4_VISION
|
||||
| typeof CHAT_MODEL_NAME_GPT_4_ALL
|
||||
| typeof CHAT_MODEL_NAME_GPT_4O
|
||||
| typeof CHAT_MODEL_NAME_DEEPSEEK_CHAT
|
||||
@@ -39,8 +29,14 @@ export type IChatModelName =
|
||||
export interface IChatModel {
|
||||
name: IChatModelName;
|
||||
icon: string;
|
||||
modelGroup?: 'chatgpt' | 'deepseek' | 'grok';
|
||||
getDisplayName: () => string;
|
||||
getDescription: () => string;
|
||||
isSearchSupported?: boolean;
|
||||
isImageSupported?: boolean;
|
||||
isFileSupported?: boolean;
|
||||
isReasoningSupported?: boolean;
|
||||
isDeepSearchSupported?: boolean;
|
||||
}
|
||||
|
||||
export interface IChatModelGroup {
|
||||
|
||||
+97
-290
@@ -1,16 +1,7 @@
|
||||
<template>
|
||||
<layout>
|
||||
<layout @change-conversation="onChangeConversation($event)">
|
||||
<template #chat>
|
||||
<model-selector class="selector" @select="onCreateNewConversation" />
|
||||
<application-status
|
||||
:initializing="initializing"
|
||||
:application="application"
|
||||
:applications="applications"
|
||||
:need-apply="needApply"
|
||||
:service="service"
|
||||
@select="$store.dispatch('chat/setApplication', $event)"
|
||||
@refresh="$store.dispatch('chat/getApplications')"
|
||||
/>
|
||||
<model-selector class="selector" @model-group-changed="onChangeConversation(undefined)" />
|
||||
<div :class="{ dialogue: true, empty: messages.length === 0 }">
|
||||
<div v-if="messages.length > 0" class="messages">
|
||||
<message
|
||||
@@ -27,26 +18,15 @@
|
||||
/>
|
||||
</div>
|
||||
<div class="composer">
|
||||
<input-box
|
||||
v-model:is-search-active="isSearchActive"
|
||||
v-model:is-reason-active="isReasonActive"
|
||||
v-model:is-deepsearch-active="isDeepsearchActive"
|
||||
v-model:is-search-enabled="isSearchEnabled"
|
||||
v-model:is-deepsearch-enabled="isDeepsearchEnabled"
|
||||
v-model:is-reason-enabled="isReasonEnabled"
|
||||
v-model:is-upload-enabled="isUploadEnabled"
|
||||
<composer
|
||||
v-model:question="question"
|
||||
:disabled="answering"
|
||||
:question="question"
|
||||
:references="references"
|
||||
:upload="upload"
|
||||
@update:question="question = $event"
|
||||
@update:upload="upload = $event"
|
||||
@update:references="references = $event"
|
||||
@submit="onSubmit"
|
||||
@stop="onStop"
|
||||
/>
|
||||
<disclaimer class="disclaimer" />
|
||||
<suggestion v-if="messages.length === 0" @draft="onDraft" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -57,54 +37,22 @@
|
||||
import axios from 'axios';
|
||||
import { defineComponent, ref } from 'vue';
|
||||
import Message from '@/components/chat/Message.vue';
|
||||
import {
|
||||
CHAT_MODEL_DEEPSEEK_CHAT,
|
||||
CHAT_MODEL_DEEPSEEK_REASONER,
|
||||
CHAT_MODEL_GPT_4_BROWSING,
|
||||
CHAT_MODEL_GPT_4O,
|
||||
CHAT_MODEL_GROK_3,
|
||||
CHAT_MODEL_GROK_3_DEEPSEARCH,
|
||||
CHAT_MODEL_GROK_3_REASONER,
|
||||
CHAT_MODEL_GROUP_CHATGPT,
|
||||
CHAT_MODEL_GROUP_DEEPSEEK,
|
||||
CHAT_MODEL_GROUP_GROK,
|
||||
CHAT_MODEL_O1_MINI,
|
||||
CHAT_MODELS,
|
||||
ROLE_ASSISTANT,
|
||||
ROLE_USER
|
||||
} from '@/constants';
|
||||
import {
|
||||
IChatModel,
|
||||
IChatMessageState,
|
||||
IChatConversationResponse,
|
||||
IChatConversation,
|
||||
IChatMessage,
|
||||
IChatModelGroup
|
||||
} from '@/models';
|
||||
import InputBox from '@/components/chat/InputBox.vue';
|
||||
import { CHAT_MODEL_GROUPS, CHAT_MODELS, ROLE_ASSISTANT, ROLE_USER } from '@/constants';
|
||||
import { IChatMessageState, IChatConversationResponse, IChatConversation, IChatMessage } from '@/models';
|
||||
import Composer from '@/components/chat/Composer.vue';
|
||||
import ModelSelector from '@/components/chat/ModelSelector.vue';
|
||||
import { ERROR_CODE_CANCELED, ERROR_CODE_NOT_APPLIED, ERROR_CODE_UNKNOWN } from '@/constants/errorCode';
|
||||
import { ROUTE_CHAT_CONVERSATION, ROUTE_CHAT_CONVERSATION_NEW } from '@/router';
|
||||
import { Status } from '@/models';
|
||||
import Suggestion from '@/components/chat/Suggestion.vue';
|
||||
import Disclaimer from '@/components/chat/Disclaimer.vue';
|
||||
import Layout from '@/layouts/Chat.vue';
|
||||
import { isImageUrl, isJSONString } from '@/utils/is';
|
||||
import { chatOperator } from '@/operators';
|
||||
import ApplicationStatus from '@/components/application/Status.vue';
|
||||
import { CHAT_MODEL_GPT_4_ALL } from '@/constants';
|
||||
|
||||
export interface IData {
|
||||
drawer: boolean;
|
||||
question: string;
|
||||
upload: boolean;
|
||||
isSearchActive: boolean;
|
||||
isDeepsearchActive: boolean;
|
||||
isReasonActive: boolean;
|
||||
isSearchEnabled: boolean;
|
||||
isDeepsearchEnabled: boolean;
|
||||
isReasonEnabled: boolean;
|
||||
isUploadEnabled: boolean;
|
||||
references: string[];
|
||||
answering: boolean;
|
||||
messages: IChatMessage[];
|
||||
@@ -114,12 +62,10 @@ export interface IData {
|
||||
export default defineComponent({
|
||||
name: 'ChatConversation',
|
||||
components: {
|
||||
InputBox,
|
||||
Composer,
|
||||
Disclaimer,
|
||||
Suggestion,
|
||||
ModelSelector,
|
||||
Message,
|
||||
ApplicationStatus,
|
||||
Layout
|
||||
},
|
||||
data(): IData {
|
||||
@@ -128,13 +74,6 @@ export default defineComponent({
|
||||
question: '',
|
||||
references: [],
|
||||
upload: false,
|
||||
isSearchActive: false,
|
||||
isReasonActive: false,
|
||||
isDeepsearchActive: false,
|
||||
isSearchEnabled: true,
|
||||
isReasonEnabled: true,
|
||||
isUploadEnabled: true,
|
||||
isDeepsearchEnabled: true,
|
||||
answering: false,
|
||||
canceler: undefined,
|
||||
messages:
|
||||
@@ -183,131 +122,20 @@ export default defineComponent({
|
||||
watch: {
|
||||
async references(val) {
|
||||
console.log('references changed', val);
|
||||
const model = await this.getModelByAction();
|
||||
if (model) {
|
||||
await this.$store.dispatch('chat/setModel', model);
|
||||
}
|
||||
},
|
||||
async isSearchActive(val) {
|
||||
console.log('search changed', val);
|
||||
const model = await this.getModelByAction();
|
||||
if (model) {
|
||||
await this.$store.dispatch('chat/setModel', model);
|
||||
}
|
||||
async modelGroup(val) {
|
||||
console.debug('modelGroup changed', val);
|
||||
},
|
||||
async isReasonActive(val) {
|
||||
console.log('reason changed', val);
|
||||
const model = await this.getModelByAction();
|
||||
if (model) {
|
||||
await this.$store.dispatch('chat/setModel', model);
|
||||
}
|
||||
},
|
||||
async isDeepsearchActive(val) {
|
||||
console.log('deepsearch changed', val);
|
||||
const model = await this.getModelByAction();
|
||||
if (model) {
|
||||
await this.$store.dispatch('chat/setModel', model);
|
||||
}
|
||||
},
|
||||
async modelGroup(val: IChatModelGroup) {
|
||||
console.log('modelGroup changed', val);
|
||||
const model = await this.getModelByAction();
|
||||
if (model) {
|
||||
console.log('set model', model);
|
||||
await this.$store.dispatch('chat/setModel', model);
|
||||
}
|
||||
if (val.name === CHAT_MODEL_GROUP_DEEPSEEK.name) {
|
||||
this.upload = false;
|
||||
}
|
||||
},
|
||||
model(val: IChatModel) {
|
||||
console.log('model changed', val);
|
||||
if (val) {
|
||||
this.$store.dispatch('chat/setModel', val);
|
||||
}
|
||||
},
|
||||
async conversationId(val: string) {
|
||||
if (!val) {
|
||||
this.messages = [];
|
||||
} else {
|
||||
this.messages =
|
||||
this.conversations?.find((conversation: IChatConversation) => conversation.id === val)?.messages || [];
|
||||
this.onScrollDown();
|
||||
}
|
||||
const model = await this.getModelByConversation();
|
||||
if (model) {
|
||||
await this.$store.dispatch('chat/setModel', model);
|
||||
}
|
||||
const modelGroup = await this.getModelGroup();
|
||||
if (modelGroup) {
|
||||
console.log('set model group', modelGroup);
|
||||
await this.$store.dispatch('chat/setModelGroup', modelGroup);
|
||||
}
|
||||
async conversationId(val) {
|
||||
console.debug('conversationId changed', val);
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
await this.onGetService();
|
||||
await this.onGetApplication();
|
||||
await this.onGetConversations();
|
||||
await this.onScrollDown();
|
||||
|
||||
// initialize model
|
||||
const model = await this.getModel();
|
||||
if (model) {
|
||||
console.log('set model', model);
|
||||
await this.$store.dispatch('chat/setModel', model);
|
||||
}
|
||||
// initialize model group
|
||||
const modelGroup = await this.getModelGroup();
|
||||
if (modelGroup) {
|
||||
console.log('set model group', modelGroup);
|
||||
await this.$store.dispatch('chat/setModelGroup', modelGroup);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async getModel() {
|
||||
return (await this.getModelByConversation()) || (await this.getModelByAction());
|
||||
},
|
||||
async getModelByConversation() {
|
||||
if (this.conversationId && this.conversation?.model) {
|
||||
const modelName = this.conversation.model;
|
||||
return CHAT_MODELS.find((model: IChatModel) => model.name === modelName);
|
||||
}
|
||||
},
|
||||
async getModelByAction() {
|
||||
if (this.modelGroup.name === CHAT_MODEL_GROUP_CHATGPT.name) {
|
||||
if (this.isReasonActive) {
|
||||
return CHAT_MODEL_O1_MINI;
|
||||
} else if (this.isSearchActive) {
|
||||
return CHAT_MODEL_GPT_4_BROWSING;
|
||||
} else if (this.references.length > 0) {
|
||||
return CHAT_MODEL_GPT_4_ALL;
|
||||
}
|
||||
return CHAT_MODEL_GPT_4O;
|
||||
} else if (this.modelGroup.name === CHAT_MODEL_GROUP_DEEPSEEK.name) {
|
||||
if (this.isReasonActive) {
|
||||
return CHAT_MODEL_DEEPSEEK_REASONER;
|
||||
}
|
||||
return CHAT_MODEL_DEEPSEEK_CHAT;
|
||||
} else if (this.modelGroup.name === CHAT_MODEL_GROUP_GROK.name) {
|
||||
if (this.isReasonActive) {
|
||||
return CHAT_MODEL_GROK_3_REASONER;
|
||||
} else if (this.isDeepsearchActive) {
|
||||
return CHAT_MODEL_GROK_3_DEEPSEARCH;
|
||||
}
|
||||
return CHAT_MODEL_GROK_3;
|
||||
}
|
||||
},
|
||||
async getModelGroup() {
|
||||
const currentModel = this.model;
|
||||
if (CHAT_MODEL_GROUP_CHATGPT.models.map((item) => item.name).includes(currentModel.name)) {
|
||||
return CHAT_MODEL_GROUP_CHATGPT;
|
||||
} else if (CHAT_MODEL_GROUP_DEEPSEEK.models.map((item) => item.name).includes(currentModel.name)) {
|
||||
return CHAT_MODEL_GROUP_DEEPSEEK;
|
||||
} else if (CHAT_MODEL_GROUP_GROK.models.map((item) => item.name).includes(currentModel.name)) {
|
||||
return CHAT_MODEL_GROUP_GROK;
|
||||
}
|
||||
},
|
||||
async onGetService() {
|
||||
console.debug('start onGetService');
|
||||
await this.$store.dispatch('chat/getService');
|
||||
@@ -410,37 +238,10 @@ export default defineComponent({
|
||||
console.debug('finished update conversation', this.messages);
|
||||
// 3. Send restart questions
|
||||
console.debug('onRestart', this.question);
|
||||
await this.onFetchAnswer();
|
||||
await this.onRequest();
|
||||
})
|
||||
.catch((error) => {
|
||||
if (this.messages && this.messages.length > 0) {
|
||||
this.messages[this.messages.length - 1].state = IChatMessageState.FAILED;
|
||||
}
|
||||
if (error.name === 'AbortError') {
|
||||
console.error('aborted');
|
||||
return;
|
||||
}
|
||||
if (axios.isCancel(error)) {
|
||||
this.messages[this.messages.length - 1].error = {
|
||||
code: ERROR_CODE_CANCELED
|
||||
};
|
||||
} else if (error?.response?.data) {
|
||||
let data = error?.response?.data;
|
||||
if (isJSONString(data)) {
|
||||
data = JSON.parse(data);
|
||||
}
|
||||
console.debug('error', data);
|
||||
if (this.messages && this.messages.length > 0) {
|
||||
this.messages[this.messages.length - 1].error = data.error;
|
||||
}
|
||||
} else {
|
||||
if (this.messages && this.messages.length > 0) {
|
||||
this.messages[this.messages.length - 1].error = {
|
||||
code: ERROR_CODE_UNKNOWN
|
||||
};
|
||||
}
|
||||
}
|
||||
this.answering = false;
|
||||
this.handleRequestError(error);
|
||||
});
|
||||
},
|
||||
async onEdit(targetMessage: IChatMessage, questionValue: string) {
|
||||
@@ -482,49 +283,52 @@ export default defineComponent({
|
||||
});
|
||||
console.debug('finished update conversation', this.messages);
|
||||
// 3. Send edited questions
|
||||
|
||||
this.messages.push({
|
||||
content: this.question,
|
||||
role: ROLE_USER
|
||||
});
|
||||
console.debug('onEdit', this.question);
|
||||
await this.onFetchAnswer();
|
||||
await this.onRequest();
|
||||
})
|
||||
.catch((error) => {
|
||||
if (this.messages && this.messages.length > 0) {
|
||||
this.messages[this.messages.length - 1].state = IChatMessageState.FAILED;
|
||||
}
|
||||
if (error.name === 'AbortError') {
|
||||
console.error('aborted');
|
||||
return;
|
||||
}
|
||||
if (axios.isCancel(error)) {
|
||||
this.messages[this.messages.length - 1].error = {
|
||||
code: ERROR_CODE_CANCELED
|
||||
};
|
||||
} else if (error?.response?.data) {
|
||||
let data = error?.response?.data;
|
||||
if (isJSONString(data)) {
|
||||
data = JSON.parse(data);
|
||||
}
|
||||
if (this.messages && this.messages.length > 0) {
|
||||
this.messages[this.messages.length - 1].error = data.error;
|
||||
}
|
||||
} else {
|
||||
if (this.messages && this.messages.length > 0) {
|
||||
this.messages[this.messages.length - 1].error = {
|
||||
code: ERROR_CODE_UNKNOWN
|
||||
};
|
||||
}
|
||||
}
|
||||
this.answering = false;
|
||||
this.handleRequestError(error);
|
||||
});
|
||||
},
|
||||
async onCreateNewConversation() {
|
||||
console.log('onCreateNewConversation');
|
||||
await this.$router.push({
|
||||
async onNewConversation() {
|
||||
this.$router.push({
|
||||
name: ROUTE_CHAT_CONVERSATION_NEW
|
||||
});
|
||||
this.messages = [];
|
||||
this.question = '';
|
||||
this.references = [];
|
||||
},
|
||||
async onRestoreConversation(id: string) {
|
||||
this.$router.push({
|
||||
name: ROUTE_CHAT_CONVERSATION,
|
||||
params: {
|
||||
id
|
||||
}
|
||||
});
|
||||
const conversation = this.conversations?.find((conversation: IChatConversation) => conversation.id === id);
|
||||
// change the model and model group
|
||||
const model = conversation?.model;
|
||||
console.debug('conversation model', model);
|
||||
const targetModel = CHAT_MODELS.find((m) => m.name === model);
|
||||
console.debug('target model', targetModel);
|
||||
const targetModelGroup = CHAT_MODEL_GROUPS.find((g) => g.name === targetModel?.modelGroup);
|
||||
console.debug('target model group', targetModelGroup);
|
||||
this.$store.dispatch('chat/setModelGroup', targetModelGroup);
|
||||
this.$store.dispatch('chat/setModel', targetModel);
|
||||
this.messages = conversation?.messages || [];
|
||||
this.onScrollDown();
|
||||
},
|
||||
async onChangeConversation(id?: string) {
|
||||
console.log('onChangeConversation in conversation', id);
|
||||
if (!id) {
|
||||
this.onNewConversation();
|
||||
} else {
|
||||
this.onRestoreConversation(id);
|
||||
}
|
||||
},
|
||||
async onSubmit() {
|
||||
if (this.references.length > 0) {
|
||||
@@ -558,20 +362,10 @@ export default defineComponent({
|
||||
});
|
||||
}
|
||||
console.debug('onSubmit', this.question, this.references);
|
||||
await this.onFetchAnswer();
|
||||
},
|
||||
// Swipe the message to the bottom
|
||||
async onScrollDown() {
|
||||
setTimeout(() => {
|
||||
const container = document.querySelector('.dialogue') as HTMLDivElement;
|
||||
if (!container || !this.messages || this.messages.length === 0) {
|
||||
return;
|
||||
}
|
||||
container.scrollTop = container?.scrollHeight;
|
||||
}, 0);
|
||||
await this.onRequest();
|
||||
},
|
||||
// Get answers to questions
|
||||
async onFetchAnswer() {
|
||||
async onRequest() {
|
||||
console.debug('start to get answer', this.messages);
|
||||
const token = this.credential?.token;
|
||||
const question = this.question;
|
||||
@@ -623,7 +417,6 @@ export default defineComponent({
|
||||
lastMessage?.state !== IChatMessageState.FINISHED ? IChatMessageState.ANSWERING : lastMessage?.state
|
||||
};
|
||||
conversationId = response?.id;
|
||||
//this.onScrollDown();
|
||||
},
|
||||
signal: this.canceler.signal
|
||||
}
|
||||
@@ -650,36 +443,49 @@ export default defineComponent({
|
||||
await this.$store.dispatch('chat/getApplications');
|
||||
})
|
||||
.catch((error) => {
|
||||
if (this.messages && this.messages.length > 0) {
|
||||
this.messages[this.messages.length - 1].state = IChatMessageState.FAILED;
|
||||
}
|
||||
if (error.name === 'AbortError') {
|
||||
console.error('aborted');
|
||||
return;
|
||||
}
|
||||
console.error(error);
|
||||
if (axios.isCancel(error)) {
|
||||
this.messages[this.messages.length - 1].error = {
|
||||
code: ERROR_CODE_CANCELED
|
||||
};
|
||||
} else if (error?.response?.data) {
|
||||
let data = error?.response?.data;
|
||||
if (isJSONString(data)) {
|
||||
data = JSON.parse(data);
|
||||
}
|
||||
console.debug('error', data);
|
||||
if (this.messages && this.messages.length > 0) {
|
||||
this.messages[this.messages.length - 1].error = data.error;
|
||||
}
|
||||
} else {
|
||||
if (this.messages && this.messages.length > 0) {
|
||||
this.messages[this.messages.length - 1].error = {
|
||||
code: ERROR_CODE_UNKNOWN
|
||||
};
|
||||
}
|
||||
}
|
||||
this.answering = false;
|
||||
this.handleRequestError(error);
|
||||
});
|
||||
},
|
||||
async handleRequestError(error: any) {
|
||||
if (this.messages && this.messages.length > 0) {
|
||||
this.messages[this.messages.length - 1].state = IChatMessageState.FAILED;
|
||||
}
|
||||
if (error.name === 'AbortError') {
|
||||
console.error('aborted');
|
||||
return;
|
||||
}
|
||||
console.error(error);
|
||||
if (axios.isCancel(error)) {
|
||||
this.messages[this.messages.length - 1].error = {
|
||||
code: ERROR_CODE_CANCELED
|
||||
};
|
||||
} else if (error?.response?.data) {
|
||||
let data = error?.response?.data;
|
||||
if (isJSONString(data)) {
|
||||
data = JSON.parse(data);
|
||||
}
|
||||
console.debug('error', data);
|
||||
if (this.messages && this.messages.length > 0) {
|
||||
this.messages[this.messages.length - 1].error = data.error;
|
||||
}
|
||||
} else {
|
||||
if (this.messages && this.messages.length > 0) {
|
||||
this.messages[this.messages.length - 1].error = {
|
||||
code: ERROR_CODE_UNKNOWN
|
||||
};
|
||||
}
|
||||
}
|
||||
this.answering = false;
|
||||
},
|
||||
// Swipe the message to the bottom
|
||||
async onScrollDown() {
|
||||
setTimeout(() => {
|
||||
const container = document.querySelector('.messages') as HTMLDivElement;
|
||||
if (!container || !this.messages || this.messages.length === 0) {
|
||||
return;
|
||||
}
|
||||
container.scrollTop = container?.scrollHeight;
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -692,6 +498,7 @@ export default defineComponent({
|
||||
position: absolute;
|
||||
left: 10px;
|
||||
top: 10px;
|
||||
z-index: 100;
|
||||
}
|
||||
.setting {
|
||||
position: absolute;
|
||||
@@ -708,11 +515,10 @@ export default defineComponent({
|
||||
.dialogue {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
position: relative;
|
||||
padding: 0 calc(50% - 400px);
|
||||
.disclaimer {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
@@ -730,8 +536,9 @@ export default defineComponent({
|
||||
}
|
||||
.messages {
|
||||
padding-top: 10px;
|
||||
padding: 0 calc(50% - 400px);
|
||||
flex: 1;
|
||||
// overflow-y: scroll;
|
||||
overflow-y: scroll;
|
||||
.message {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
faSun as faRegularSun,
|
||||
faLightbulb as faRegularLightbulb,
|
||||
faMessage as faRegularMessage,
|
||||
faFileAlt as faRegularFileAlt,
|
||||
faClock as faRegularClock,
|
||||
faFile as faRegularFile
|
||||
} from '@fortawesome/free-regular-svg-icons';
|
||||
@@ -89,6 +90,7 @@ library.add(faSolidIdCard);
|
||||
library.add(faSolidStopCircle);
|
||||
library.add(faRegularFile);
|
||||
library.add(faSolidPlayCircle);
|
||||
library.add(faRegularFileAlt);
|
||||
library.add(faSolidFilm);
|
||||
library.add(faSolidMusic);
|
||||
library.add(faRegularCopy);
|
||||
|
||||
+1
-1
@@ -39,5 +39,5 @@ export const isSubOfficial = (): boolean => {
|
||||
* is image url
|
||||
*/
|
||||
export function isImageUrl(url: string): boolean {
|
||||
return /\.(jpg|jpeg|png|gif|bmp|webp|svg|tiff?)$/i.test(url);
|
||||
return /\.(jpg|jpeg|png|gif|bmp|webp|svg|tiff|ico|heic?)$/i.test(url.toLowerCase());
|
||||
}
|
||||
Reference in new issue
Block a user