-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -45,8 +70,9 @@
import { defineComponent } from 'vue';
import AnsweringMark from './AnsweringMark.vue';
import copy from 'copy-to-clipboard';
-import { ElAlert, ElButton, ElImage } from 'element-plus';
+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 {
@@ -64,6 +90,8 @@ import { ROUTE_CONSOLE_APPLICATION_BUY } from '@/router';
interface IData {
copied: boolean;
+ isEditing: boolean;
+ questionValue: string;
messageState: typeof IChatMessageState;
}
@@ -75,7 +103,10 @@ export default defineComponent({
MarkdownRenderer,
ElAlert,
ElButton,
- ElImage
+ ElImage,
+ ElTooltip,
+ FontAwesomeIcon,
+ ElInput
},
props: {
message: {
@@ -87,10 +118,12 @@ export default defineComponent({
required: true
}
},
- emits: ['stop'],
+ emits: ['stop', 'update:messages', 'edit'],
data(): IData {
return {
copied: false,
+ isEditing: false,
+ questionValue: this.message.content as string,
messageState: IChatMessageState
};
},
@@ -123,7 +156,24 @@ export default defineComponent({
return this.message.role === ROLE_ASSISTANT && this.message.error?.code === ERROR_CODE_USED_UP;
}
},
+ watch: {},
methods: {
+ startEditing() {
+ this.isEditing = true;
+ this.questionValue = this.message.content as string;
+ console.debug('start to get answer', this.message);
+ },
+ cancelEdit() {
+ this.isEditing = false;
+ },
+ sendEdit() {
+ // Implement the logic to save the edited content
+ this.isEditing = false;
+ this.onSubmit();
+ },
+ onSubmit() {
+ this.$emit('edit', this.message, this.questionValue);
+ },
onCopy() {
copy(this.message.content!.toString(), {
debug: true
@@ -209,7 +259,48 @@ export default defineComponent({
width: fit-content;
text-align: left;
max-width: 100%;
- padding: 8px 15px;
+ 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;
+ 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;
+ .cancel-button {
+ // background-color: #333;
+ // color: white;
+ background-color: var(--el-bg-color-page);
+ color: var(--el-text-color-primary);
+ border-radius: 20px;
+ // border: none;
+ }
+
+ .send-button {
+ // background-color: white;
+ // color: black;
+ background-color: var(--el-bg-color-page);
+ color: var(--el-text-color-primary);
+ border-radius: 20px;
+ // border: none;
+ }
+ }
+ }
}
}
.content {
@@ -223,6 +314,18 @@ export default defineComponent({
margin: 5px 0;
border-radius: 10px;
}
+ .edit-area {
+ width: 100%;
+ min-height: 100px;
+ border-radius: 10px;
+ padding: 8px;
+ margin-bottom: 10px;
+ }
+ .edit-buttons {
+ display: flex;
+ justify-content: flex-end;
+ gap: 10px;
+ }
}
.operations {
diff --git a/src/i18n/zh-CN/chat.json b/src/i18n/zh-CN/chat.json
index 10923ea6..6e50fb28 100644
--- a/src/i18n/zh-CN/chat.json
+++ b/src/i18n/zh-CN/chat.json
@@ -1,4 +1,8 @@
{
+ "button.edit": {
+ "message": "编辑消息",
+ "description": "编辑发送的消息"
+ },
"model.35Standard": {
"message": "3.5 标准",
"description": "服务的模型名称,即 GPT 3.5 基础"
diff --git a/src/models/chat.ts b/src/models/chat.ts
index 9bacd028..f7e12618 100644
--- a/src/models/chat.ts
+++ b/src/models/chat.ts
@@ -46,13 +46,13 @@ export interface IChatMessage {
}
export interface IChatConversation {
- id: string;
- messages: IChatMessage[];
+ id?: string;
+ messages?: IChatMessage[];
title?: string;
deleting?: boolean;
editing?: boolean;
new?: boolean;
- updated_at: number;
+ updated_at?: number;
}
export interface IChatConversationOptions {
diff --git a/src/pages/chat/Conversation.vue b/src/pages/chat/Conversation.vue
index 0827923b..39568af2 100644
--- a/src/pages/chat/Conversation.vue
+++ b/src/pages/chat/Conversation.vue
@@ -16,8 +16,13 @@
v-for="(message, messageIndex) in messages"
:key="messageIndex"
:message="message"
+ :messages="messages"
+ :question="question"
:application="application"
class="message"
+ @update:question="question = $event"
+ @update:messages="messages = $event"
+ @edit="onEdit"
/>