fit chat restart (#107)
This commit is contained in:
1 parent
1477fa9879
commit
1acebc5651
7 files changed
+193
-9
No files matched your search
@@ -56,6 +56,14 @@
|
||||
</div>
|
||||
<div class="operations">
|
||||
<copy-to-clipboard v-if="!Array.isArray(message.content)" :content="message.content!" class="btn-copy" />
|
||||
<restart-to-generate
|
||||
v-if="
|
||||
!Array.isArray(message.content) && message.role === 'assistant' && message === messages[messages.length - 1]
|
||||
"
|
||||
class="btn-restart"
|
||||
:messages="messages"
|
||||
@restart="sendRestart"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<el-alert v-else class="error" :title="errorText" type="error" :closable="false" />
|
||||
@@ -73,7 +81,8 @@ import { ElAlert, ElButton, ElImage, ElTooltip, ElInput } from 'element-plus';
|
||||
import MarkdownRenderer from '@/components/common/MarkdownRenderer.vue';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { IApplication, IChatMessage, IChatMessageState } from '@/models';
|
||||
import CopyToClipboard from '../common/CopyToClipboard.vue';
|
||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||
import RestartToGenerate from '@/components/common/RestartToGenerate.vue';
|
||||
import {
|
||||
ERROR_CODE_API_ERROR,
|
||||
ERROR_CODE_BAD_REQUEST,
|
||||
@@ -98,6 +107,7 @@ export default defineComponent({
|
||||
name: 'Message',
|
||||
components: {
|
||||
CopyToClipboard,
|
||||
RestartToGenerate,
|
||||
AnsweringMark,
|
||||
MarkdownRenderer,
|
||||
ElAlert,
|
||||
@@ -108,6 +118,11 @@ export default defineComponent({
|
||||
ElInput
|
||||
},
|
||||
props: {
|
||||
messages: {
|
||||
type: Array,
|
||||
required: false,
|
||||
default: () => []
|
||||
},
|
||||
message: {
|
||||
type: Object as () => IChatMessage,
|
||||
required: true
|
||||
@@ -117,7 +132,7 @@ export default defineComponent({
|
||||
required: true
|
||||
}
|
||||
},
|
||||
emits: ['stop', 'update:messages', 'edit'],
|
||||
emits: ['stop', 'edit', 'restart'],
|
||||
data(): IData {
|
||||
return {
|
||||
copied: false,
|
||||
@@ -165,6 +180,10 @@ export default defineComponent({
|
||||
cancelEdit() {
|
||||
this.isEditing = false;
|
||||
},
|
||||
sendRestart() {
|
||||
// Implement the logic to save the edited content
|
||||
this.$emit('restart', this.message);
|
||||
},
|
||||
sendEdit() {
|
||||
// Implement the logic to save the edited content
|
||||
this.isEditing = false;
|
||||
@@ -312,7 +331,13 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
.operations {
|
||||
display: block;
|
||||
display: flex; // Use flexbox for better alignment
|
||||
gap: 10px; // Adjust the gap value as needed
|
||||
margin-left: 5px; // Adjust the value as needed
|
||||
.btn-restart {
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 14px;
|
||||
}
|
||||
.btn-copy {
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 14px;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<template>
|
||||
<font-awesome-icon v-if="!copied" icon="fa-regular fa-copy" class="icon-copy" @click="onCopy" />
|
||||
<el-tooltip v-if="!copied" effect="dark" :content="$t('common.button.copy')" placement="top-start">
|
||||
<font-awesome-icon icon="fa-regular fa-copy" class="icon-copy" @click="onCopy"
|
||||
/></el-tooltip>
|
||||
|
||||
<el-tooltip v-else :visible="copied" effect="dark" :content="$t('common.message.copied')" placement="top-start">
|
||||
<font-awesome-icon icon="fa-solid fa-check" class="icon-check" />
|
||||
</el-tooltip>
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<template>
|
||||
<el-tooltip effect="dark" :content="$t('common.button.restart')" placement="top-start">
|
||||
<font-awesome-icon icon="fa-solid fa-sync" class="icon-sync" @click="onRestart" />
|
||||
</el-tooltip>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { ElTooltip } from 'element-plus';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CopyToClipboard',
|
||||
components: {
|
||||
FontAwesomeIcon,
|
||||
ElTooltip
|
||||
},
|
||||
props: {
|
||||
messages: {
|
||||
type: Array,
|
||||
required: false,
|
||||
default: () => []
|
||||
}
|
||||
},
|
||||
emits: ['restart'],
|
||||
data() {
|
||||
return {
|
||||
copied: false
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
onRestart() {
|
||||
this.$emit('restart');
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.icon-check,
|
||||
.icon-copy {
|
||||
margin-left: 5px;
|
||||
cursor: pointer;
|
||||
color: inherit;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user