【新增】AI:新建对话时,不使用默认角色
This commit is contained in:
parent
8fb54dbb7c
commit
8764c6c471
@ -12,8 +12,8 @@ export interface ChatConversationVO {
|
|||||||
temperature: number // 温度参数
|
temperature: number // 温度参数
|
||||||
maxTokens: number // 单条回复的最大 Token 数量
|
maxTokens: number // 单条回复的最大 Token 数量
|
||||||
maxContexts: number // 上下文的最大 Message 数量
|
maxContexts: number // 上下文的最大 Message 数量
|
||||||
updateTime: number // 更新时间
|
|
||||||
// 额外字段
|
// 额外字段
|
||||||
|
systemMessage?: string // 角色设定
|
||||||
modelName?: string // 模型名字
|
modelName?: string // 模型名字
|
||||||
roleAvatar?: string // 角色头像
|
roleAvatar?: string // 角色头像
|
||||||
modelMaxTokens?: string // 模型的单条回复的最大 Token 数量
|
modelMaxTokens?: string // 模型的单条回复的最大 Token 数量
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div ref="messageContainer" style="height: 100%;overflow-y: auto;position: relative;">
|
<div ref="messageContainer" style="height: 100%; overflow-y: auto; position: relative">
|
||||||
<div class="chat-list" v-for="(item, index) in list" :key="index" >
|
<div class="chat-list" v-for="(item, index) in messageList" :key="index">
|
||||||
<!-- 靠左 message -->
|
<!-- 靠左 message -->
|
||||||
<!-- TODO 芋艿:类型判断 -->
|
|
||||||
<div class="left-message message-item" v-if="item.type !== 'user'">
|
<div class="left-message message-item" v-if="item.type !== 'user'">
|
||||||
<div class="avatar">
|
<div class="avatar">
|
||||||
<el-avatar :src="item.roleAvatar" />
|
<el-avatar :src="item.roleAvatar" />
|
||||||
@ -19,7 +18,7 @@
|
|||||||
<img class="btn-image" src="@/assets/ai/copy.svg" />
|
<img class="btn-image" src="@/assets/ai/copy.svg" />
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button class="btn-cus" link @click="onDelete(item.id)">
|
<el-button class="btn-cus" link @click="onDelete(item.id)">
|
||||||
<img class="btn-image" src="@/assets/ai/delete.svg" style="height: 17px; "/>
|
<img class="btn-image" src="@/assets/ai/delete.svg" style="height: 17px" />
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -41,7 +40,11 @@
|
|||||||
<img class="btn-image" src="@/assets/ai/copy.svg" />
|
<img class="btn-image" src="@/assets/ai/copy.svg" />
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button class="btn-cus" link @click="onDelete(item.id)">
|
<el-button class="btn-cus" link @click="onDelete(item.id)">
|
||||||
<img class="btn-image" src="@/assets/ai/delete.svg" style="height: 17px;margin-right: 12px;"/>
|
<img
|
||||||
|
class="btn-image"
|
||||||
|
src="@/assets/ai/delete.svg"
|
||||||
|
style="height: 17px; margin-right: 12px"
|
||||||
|
/>
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button class="btn-cus" link @click="onRefresh(item)">
|
<el-button class="btn-cus" link @click="onRefresh(item)">
|
||||||
<el-icon size="17"><RefreshRight /></el-icon>
|
<el-icon size="17"><RefreshRight /></el-icon>
|
||||||
@ -60,12 +63,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {formatDate} from "@/utils/formatTime";
|
import { formatDate } from '@/utils/formatTime'
|
||||||
import MarkdownView from "@/components/MarkdownView/index.vue";
|
import MarkdownView from '@/components/MarkdownView/index.vue'
|
||||||
import {ChatMessageApi, ChatMessageVO} from "@/api/ai/chat/message";
|
import { ChatMessageApi, ChatMessageVO } from '@/api/ai/chat/message'
|
||||||
import {useClipboard} from "@vueuse/core";
|
import { useClipboard } from '@vueuse/core'
|
||||||
import {PropType} from "vue";
|
import { PropType } from 'vue'
|
||||||
import {ArrowDownBold, Edit, RefreshRight} from "@element-plus/icons-vue";
|
import { ArrowDownBold, Edit, RefreshRight } from '@element-plus/icons-vue'
|
||||||
|
import { ChatConversationVO } from '@/api/ai/chat/conversation'
|
||||||
|
|
||||||
const { copy } = useClipboard() // 初始化 copy 到粘贴板
|
const { copy } = useClipboard() // 初始化 copy 到粘贴板
|
||||||
// 判断 消息列表 滚动的位置(用于判断是否需要滚动到消息最下方)
|
// 判断 消息列表 滚动的位置(用于判断是否需要滚动到消息最下方)
|
||||||
@ -74,12 +78,30 @@ const isScrolling = ref(false) //用于判断用户是否在滚动
|
|||||||
|
|
||||||
// 定义 props
|
// 定义 props
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
conversation: {
|
||||||
|
type: Object as PropType<ChatConversationVO>,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
list: {
|
list: {
|
||||||
type: Array as PropType<ChatMessageVO[]>,
|
type: Array as PropType<ChatMessageVO[]>,
|
||||||
required: true
|
required: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const messageList = computed(() => {
|
||||||
|
if (props.list && props.list.length > 0) {
|
||||||
|
return props.list
|
||||||
|
}
|
||||||
|
if (props.conversation && props.conversation.systemMessage) {
|
||||||
|
return [{
|
||||||
|
id: 0,
|
||||||
|
type: 'system',
|
||||||
|
content: props.conversation.systemMessage
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
return []
|
||||||
|
})
|
||||||
|
|
||||||
// ============ 处理对话滚动 ==============
|
// ============ 处理对话滚动 ==============
|
||||||
|
|
||||||
const scrollToBottom = async (isIgnore?: boolean) => {
|
const scrollToBottom = async (isIgnore?: boolean) => {
|
||||||
@ -97,7 +119,7 @@ function handleScroll() {
|
|||||||
const scrollTop = scrollContainer.scrollTop
|
const scrollTop = scrollContainer.scrollTop
|
||||||
const scrollHeight = scrollContainer.scrollHeight
|
const scrollHeight = scrollContainer.scrollHeight
|
||||||
const offsetHeight = scrollContainer.offsetHeight
|
const offsetHeight = scrollContainer.offsetHeight
|
||||||
if ((scrollTop + offsetHeight) < (scrollHeight - 100)) {
|
if (scrollTop + offsetHeight < scrollHeight - 100) {
|
||||||
// 用户开始滚动并在最底部之上,取消保持在最底部的效果
|
// 用户开始滚动并在最底部之上,取消保持在最底部的效果
|
||||||
isScrolling.value = true
|
isScrolling.value = true
|
||||||
} else {
|
} else {
|
||||||
@ -191,7 +213,6 @@ onMounted(async () => {
|
|||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
//padding: 0 15px;
|
//padding: 0 15px;
|
||||||
//z-index: -1;
|
//z-index: -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 中间
|
// 中间
|
||||||
|
@ -36,10 +36,11 @@
|
|||||||
<div class="message-container" >
|
<div class="message-container" >
|
||||||
<MessageLoading v-if="listLoading" />
|
<MessageLoading v-if="listLoading" />
|
||||||
<MessageNewChat v-if="!activeConversation" @on-new-chat="handlerNewChat" />
|
<MessageNewChat v-if="!activeConversation" @on-new-chat="handlerNewChat" />
|
||||||
<ChatEmpty v-if="!listLoading && list.length === 0 && activeConversation" @on-prompt="doSend"/>
|
<ChatEmpty v-if="!listLoading && messageList.length === 0 && activeConversation" @on-prompt="doSend"/>
|
||||||
<Message v-if="!listLoading && list.length > 0"
|
<Message v-if="!listLoading && messageList.length > 0"
|
||||||
ref="messageRef"
|
ref="messageRef"
|
||||||
:list="list"
|
:conversation="activeConversation"
|
||||||
|
:list="messageList"
|
||||||
@on-delete-success="handlerMessageDelete"
|
@on-delete-success="handlerMessageDelete"
|
||||||
@on-edit="handlerMessageEdit"
|
@on-edit="handlerMessageEdit"
|
||||||
@on-refresh="handlerMessageRefresh"/>
|
@on-refresh="handlerMessageRefresh"/>
|
||||||
@ -103,13 +104,11 @@ import MessageNewChat from './MessageNewChat.vue'
|
|||||||
import {ChatMessageApi, ChatMessageVO} from '@/api/ai/chat/message'
|
import {ChatMessageApi, ChatMessageVO} from '@/api/ai/chat/message'
|
||||||
import {ChatConversationApi, ChatConversationVO} from '@/api/ai/chat/conversation'
|
import {ChatConversationApi, ChatConversationVO} from '@/api/ai/chat/conversation'
|
||||||
import { getUserProfile, ProfileVO } from '@/api/system/user/profile'
|
import { getUserProfile, ProfileVO } from '@/api/system/user/profile'
|
||||||
import {useClipboard} from '@vueuse/core'
|
|
||||||
import ChatConversationUpdateForm from "@/views/ai/chat/components/ChatConversationUpdateForm.vue";
|
import ChatConversationUpdateForm from "@/views/ai/chat/components/ChatConversationUpdateForm.vue";
|
||||||
import {Download, Top} from "@element-plus/icons-vue";
|
import {Download, Top} from "@element-plus/icons-vue";
|
||||||
|
|
||||||
const route = useRoute() // 路由
|
const route = useRoute() // 路由
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
const {copy} = useClipboard() // 初始化 copy 到粘贴板
|
|
||||||
|
|
||||||
// ref 属性定义
|
// ref 属性定义
|
||||||
const activeConversationId = ref<string | null>(null) // 选中的对话编号
|
const activeConversationId = ref<string | null>(null) // 选中的对话编号
|
||||||
@ -391,6 +390,23 @@ const stopStream = async () => {
|
|||||||
|
|
||||||
// ============== message 数据 =================
|
// ============== message 数据 =================
|
||||||
|
|
||||||
|
/** 消息列表 */
|
||||||
|
const messageList = computed(() => {
|
||||||
|
if (list.value.length > 0) {
|
||||||
|
return list.value
|
||||||
|
}
|
||||||
|
// 没有消息时,如果有 systemMessage 则展示它
|
||||||
|
// TODO add by 芋艿:这个消息下面,不能有复制、删除按钮
|
||||||
|
if (activeConversation.value?.systemMessage) {
|
||||||
|
return [{
|
||||||
|
id: 0,
|
||||||
|
type: 'system',
|
||||||
|
content: activeConversation.value.systemMessage
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
return []
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取 - message 列表
|
* 获取 - message 列表
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user