Fix chat experience (#171)
Co-authored-by: AceDataCloud <office@acedata.cloud>
This commit is contained in:
1 parent
56d2571a5c
commit
93f6aac165
3 files changed
+44
-36
No files matched your search
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"type": "patch",
|
||||||
|
"comment": "fix chat experience",
|
||||||
|
"packageName": "@acedatacloud/nexior",
|
||||||
|
"email": "office@acedata.cloud",
|
||||||
|
"dependentChangeType": "patch"
|
||||||
|
}
|
||||||
@@ -27,9 +27,13 @@
|
|||||||
<span v-else-if="conversation?.editing">
|
<span v-else-if="conversation?.editing">
|
||||||
<el-input v-model="conversation.title" @keydown.enter="onConfirm(conversation)" />
|
<el-input v-model="conversation.title" @keydown.enter="onConfirm(conversation)" />
|
||||||
</span>
|
</span>
|
||||||
<span v-else-if="conversation?.title || conversation?.messages">{{
|
<span v-else-if="conversation?.title || conversation?.messages">
|
||||||
conversation?.title || conversation?.messages[conversation?.messages.length - 1]?.content
|
{{
|
||||||
}}</span>
|
conversation?.title ||
|
||||||
|
conversation?.messages?.[conversation?.messages.length - 1]?.content ||
|
||||||
|
conversation?.messages?.[0]?.content
|
||||||
|
}}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="operations">
|
<div class="operations">
|
||||||
<font-awesome-icon
|
<font-awesome-icon
|
||||||
@@ -152,7 +156,7 @@ export default defineComponent({
|
|||||||
console.error('Token is not found');
|
console.error('Token is not found');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (conversation?.deleting) {
|
if (conversation?.deleting && conversation.id) {
|
||||||
await chatOperator.deleteConversation(conversation.id, {
|
await chatOperator.deleteConversation(conversation.id, {
|
||||||
token
|
token
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,25 +9,8 @@
|
|||||||
:service="service"
|
:service="service"
|
||||||
@refresh="$store.dispatch('chat/getApplications')"
|
@refresh="$store.dispatch('chat/getApplications')"
|
||||||
/>
|
/>
|
||||||
<div v-if="messages.length === 0" class="dialogue empty">
|
<div :class="{ dialogue: true, empty: messages.length === 0 }">
|
||||||
<div class="composer">
|
<div v-if="messages.length > 0" class="messages">
|
||||||
<input-box
|
|
||||||
:disabled="answering"
|
|
||||||
:question="question"
|
|
||||||
:references="references"
|
|
||||||
@update:question="question = $event"
|
|
||||||
@update:reason="reason = $event"
|
|
||||||
@update:search="search = $event"
|
|
||||||
@update:references="references = $event"
|
|
||||||
@submit="onSubmit"
|
|
||||||
@stop="onStop"
|
|
||||||
/>
|
|
||||||
<suggestion @draft="onDraft" />
|
|
||||||
</div>
|
|
||||||
<disclaimer class="disclaimer" />
|
|
||||||
</div>
|
|
||||||
<div v-else class="dialogue">
|
|
||||||
<div class="messages">
|
|
||||||
<message
|
<message
|
||||||
v-for="(message, messageIndex) in messages"
|
v-for="(message, messageIndex) in messages"
|
||||||
:key="messageIndex"
|
:key="messageIndex"
|
||||||
@@ -46,13 +29,15 @@
|
|||||||
:disabled="answering"
|
:disabled="answering"
|
||||||
:question="question"
|
:question="question"
|
||||||
:references="references"
|
:references="references"
|
||||||
|
@update:question="question = $event"
|
||||||
@update:reason="reason = $event"
|
@update:reason="reason = $event"
|
||||||
@update:search="search = $event"
|
@update:search="search = $event"
|
||||||
@update:question="question = $event"
|
|
||||||
@update:references="references = $event"
|
@update:references="references = $event"
|
||||||
@submit="onSubmit"
|
@submit="onSubmit"
|
||||||
@stop="onStop"
|
@stop="onStop"
|
||||||
/>
|
/>
|
||||||
|
<disclaimer class="disclaimer" />
|
||||||
|
<suggestion v-if="messages.length === 0" @draft="onDraft" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -71,6 +56,7 @@ import {
|
|||||||
CHAT_MODEL_GROUP_CHATGPT,
|
CHAT_MODEL_GROUP_CHATGPT,
|
||||||
CHAT_MODEL_GROUP_DEEPSEEK,
|
CHAT_MODEL_GROUP_DEEPSEEK,
|
||||||
CHAT_MODEL_O1,
|
CHAT_MODEL_O1,
|
||||||
|
CHAT_MODEL_O1_MINI,
|
||||||
CHAT_MODELS,
|
CHAT_MODELS,
|
||||||
ROLE_ASSISTANT,
|
ROLE_ASSISTANT,
|
||||||
ROLE_USER
|
ROLE_USER
|
||||||
@@ -175,6 +161,13 @@ export default defineComponent({
|
|||||||
await this.$store.dispatch('chat/setModel', model);
|
await this.$store.dispatch('chat/setModel', model);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// async references(val) {
|
||||||
|
// console.log('references changed', val);
|
||||||
|
// const model = await this.getModelByAction();
|
||||||
|
// if (model) {
|
||||||
|
// await this.$store.dispatch('chat/setModel', model);
|
||||||
|
// }
|
||||||
|
// },
|
||||||
async reason() {
|
async reason() {
|
||||||
console.log('reason changed', this.reason);
|
console.log('reason changed', this.reason);
|
||||||
const model = await this.getModelByAction();
|
const model = await this.getModelByAction();
|
||||||
@@ -196,7 +189,7 @@ export default defineComponent({
|
|||||||
this.$store.dispatch('chat/setModel', val);
|
this.$store.dispatch('chat/setModel', val);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
conversationId(val: string) {
|
async conversationId(val: string) {
|
||||||
if (!val) {
|
if (!val) {
|
||||||
this.messages = [];
|
this.messages = [];
|
||||||
} else {
|
} else {
|
||||||
@@ -204,6 +197,16 @@ export default defineComponent({
|
|||||||
this.conversations?.find((conversation: IChatConversation) => conversation.id === val)?.messages || [];
|
this.conversations?.find((conversation: IChatConversation) => conversation.id === val)?.messages || [];
|
||||||
this.onScrollDown();
|
this.onScrollDown();
|
||||||
}
|
}
|
||||||
|
console.log('reason changed', this.reason);
|
||||||
|
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 mounted() {
|
async mounted() {
|
||||||
@@ -238,7 +241,7 @@ export default defineComponent({
|
|||||||
async getModelByAction() {
|
async getModelByAction() {
|
||||||
if (this.modelGroup.name === CHAT_MODEL_GROUP_CHATGPT.name) {
|
if (this.modelGroup.name === CHAT_MODEL_GROUP_CHATGPT.name) {
|
||||||
if (this.reason) {
|
if (this.reason) {
|
||||||
return CHAT_MODEL_O1;
|
return CHAT_MODEL_O1_MINI;
|
||||||
} else if (this.search) {
|
} else if (this.search) {
|
||||||
return CHAT_MODEL_GPT_4_BROWSING;
|
return CHAT_MODEL_GPT_4_BROWSING;
|
||||||
} else if (this.references.length > 0) {
|
} else if (this.references.length > 0) {
|
||||||
@@ -473,11 +476,6 @@ export default defineComponent({
|
|||||||
name: ROUTE_CHAT_CONVERSATION_NEW
|
name: ROUTE_CHAT_CONVERSATION_NEW
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// async onModelChanged() {
|
|
||||||
// await this.onCreateNewConversation();
|
|
||||||
// await this.$store.dispatch('chat/getApplications');
|
|
||||||
// },
|
|
||||||
// Send a message
|
|
||||||
async onSubmit() {
|
async onSubmit() {
|
||||||
if (this.references.length > 0) {
|
if (this.references.length > 0) {
|
||||||
let content = [];
|
let content = [];
|
||||||
@@ -589,7 +587,7 @@ export default defineComponent({
|
|||||||
messages: this.messages
|
messages: this.messages
|
||||||
});
|
});
|
||||||
this.answering = false;
|
this.answering = false;
|
||||||
if (!this.conversationId) {
|
if (conversationId) {
|
||||||
await this.$router.push({
|
await this.$router.push({
|
||||||
name: ROUTE_CHAT_CONVERSATION,
|
name: ROUTE_CHAT_CONVERSATION,
|
||||||
params: {
|
params: {
|
||||||
@@ -662,10 +660,8 @@ export default defineComponent({
|
|||||||
position: relative;
|
position: relative;
|
||||||
padding: 0 calc(50% - 400px);
|
padding: 0 calc(50% - 400px);
|
||||||
.disclaimer {
|
.disclaimer {
|
||||||
position: absolute;
|
width: 100%;
|
||||||
bottom: 0;
|
text-align: center;
|
||||||
left: 50%;
|
|
||||||
transform: translateX(-50%);
|
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
&.empty {
|
&.empty {
|
||||||
@@ -681,6 +677,7 @@ export default defineComponent({
|
|||||||
.messages {
|
.messages {
|
||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
// overflow-y: scroll;
|
||||||
.message {
|
.message {
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user