Browse Source

fix:1.会话、角色增加模型选择;2.会话、角色、文生图调整优化;

dxj
李朋徽 1 year ago
parent
commit
0722f13cf7
  1. 1
      src/api/base/message.ts
  2. 2
      src/components/AppConversationDefault/index.vue
  3. 6
      src/components/AppMessage/index.vue
  4. 4
      src/components/AppModelSelect/index.d.ts
  5. 29
      src/components/AppModelSelect/index.vue
  6. 4
      src/components/AppSubMenuList/index.vue
  7. 1
      src/store/moules/messageStore/index.d.ts
  8. 68
      src/views/conversation/index.vue
  9. 69
      src/views/role/index.vue
  10. 19
      src/views/textToImage/index.vue

1
src/api/base/message.ts

@ -10,6 +10,7 @@ export async function addMessage(data: {
title: string
sort: number
roleId?: string
modelType: ModelTypeEnum
}) {
return defHttp.post({
url: `/open-chat/chat/conversation/save`,

2
src/components/AppConversationDefault/index.vue

@ -5,7 +5,6 @@ import DefaultImage from '@/assets/images/conversation/default_img.png'
import { SvgIcon } from '@/components/SvgIcon'
import { AppContentDefaultBox } from '@/components/AppContentDefaultBox'
import { AppDefaultLead } from '@/components/AppDefaultLead'
import { AppModelSelect } from '@/components/AppModelSelect'
import { AppTopPicks } from '@/components/AppTopPicks'
import type { TopPickItem } from '@/components/AppTopPicks/index.d'
import { AppPicture } from '@/components/AppPicture'
@ -55,7 +54,6 @@ function handlePick(index: number, item: TopPickItem) {
<template>
<AppContentDefaultBox class="content-default-style">
<AppModelSelect></AppModelSelect>
<AppDefaultLead
class="mt-20"
:title="leadData.title"

6
src/components/AppMessage/index.vue

@ -142,8 +142,8 @@ onMounted(async () => {
/>
<div v-if="conversationData?.type === MenuTypeEnum.TEXT_TO_IMAGE">
<Image
:width="200"
:height="200"
:src="item.content"
fallback="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6UAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAwSDCIMogwMCcmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsis7PPOq3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HJ3HNvGCBBhY6jtaMoEiJB0Z29vL6ls58vxPcO8/zfrdo5qvKO+d3Fx8Wu8zf1dW4p/cPzLly/dtv9Ts/EbcvGAHhHyfBIhZ6NSiIBTo0LNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiEC/wGgKKC4YMA4TAAAAABJRU5ErkJggg=="
></Image>
@ -199,7 +199,7 @@ onMounted(async () => {
justify-content: flex-end;
.content {
max-width: calc(100% - 110px);
padding: 10px 10px;
padding: 10px 15px;
background: #edf3ff;
border-radius: 10px;
}
@ -223,7 +223,7 @@ onMounted(async () => {
margin-right: 5px;
}
.content {
padding: 10px 10px;
padding: 10px 15px;
background: #ffffff;
box-shadow: 0px 2px 10px 0px rgba(128, 135, 152, 0.4);
border-radius: 10px;

4
src/components/AppModelSelect/index.d.ts vendored

@ -1,6 +1,8 @@
import type { ModelTypeEnum } from '@/enums/messageEnum'
export interface ModelSelect {
label: string
value: string
value: ModelTypeEnum
}
export interface Props {

29
src/components/AppModelSelect/index.vue

@ -1,22 +1,25 @@
<!-- 3.5和4.0模型切换组件 -->
<script setup lang="ts">
import { ref } from 'vue'
import { computed } from 'vue'
import { Dropdown, Menu, MenuItem } from 'ant-design-vue'
import type { ModelSelect } from './index.d'
import { SvgIcon } from '@/components/SvgIcon'
const emit = defineEmits(['change'])
const optionActive = ref(0)
const options: ModelSelect[] = [
{
label: '同聪3.5',
value: '1',
},
{
label: '同聪4.0',
value: '2',
},
]
interface Props {
activeIndex: number
options: ModelSelect[]
}
const props = withDefaults(defineProps<Props>(), {
activeIndex: 0,
options: () => [],
})
const emit = defineEmits(['change', 'update:activeIndex'])
const optionActive = computed({
get: () => props.activeIndex,
set: value => emit('update:activeIndex', value),
})
function handelChange(index: number, item: ModelSelect) {
optionActive.value = index

4
src/components/AppSubMenuList/index.vue

@ -5,6 +5,7 @@ import { Input } from 'ant-design-vue'
import { CheckOutlined, CloseOutlined } from '@ant-design/icons-vue'
import type { SubMenuItem } from './index.d'
import { SubMenuActionEnum } from './index.d'
import { MenuTypeEnum } from '@/enums/menuEnum'
import { SvgIcon } from '@/components/SvgIcon'
const props = defineProps<{
@ -85,7 +86,10 @@ function handleBlur(index: number, item: SubMenuItem, inputValue?: string) {
@click.stop="$emit('handleAction', SubMenuActionEnum.TO_TOP, item, index)"
>
</SvgIcon>
<!-- 角色会话列表不能编辑 -->
<SvgIcon
v-if="item.type !== MenuTypeEnum.ROLE"
class-name="icon"
name="edit"
@click.stop="$emit('handleAction', SubMenuActionEnum.EDIT, item, index)"

1
src/store/moules/messageStore/index.d.ts vendored

@ -19,6 +19,7 @@ export interface ConversationData {
userId: string
content: string
actionType: SubMenuActionEnum
modelType: string
}
export interface MessageStoreType {

68
src/views/conversation/index.vue

@ -15,9 +15,11 @@ import { AppTextarea } from '@/components/AppTextarea'
import { AppMessage } from '@/components/AppMessage'
import type { MessageItem } from '@/components/AppMessage/index.d'
import type { TopPickItem } from '@/components/AppTopPicks/index.d'
import { AppModelSelect } from '@/components/AppModelSelect'
import type { ModelSelect } from '@/components/AppModelSelect/index.d'
import { useMessageStore } from '@/store/moules/messageStore/index'
import { MenuTypeEnum } from '@/enums/menuEnum'
import { MessageStatusEnum, MessageTypeEnum } from '@/enums/messageEnum'
import { MessageStatusEnum, MessageTypeEnum, ModelTypeEnum } from '@/enums/messageEnum'
import { addMessage, conversationList, conversationToTop, historyMessage, removeMessage, sendTextToText, stopMessage, updateMessage } from '@/api/base/message'
import { getAppList, getRole } from '@/api/base/role'
import { useMqtt } from '@/hooks/useMqtt'
@ -28,11 +30,24 @@ const { createConfirm } = useMessage()
const messageStore = useMessageStore()
const sendBtnLoading = ref(false)
const subMenuActiveIndex = ref(0) //
const subMenuActiveIndex = ref(-1) //
const subMenuActionIndex = ref(-1) //
const subMenuList = ref<SubMenuItem[]>([])
const subMenuInputValue = ref<string>('')
const appMessageRef = ref()
const modelOptions: ModelSelect[] = [
{
label: '同聪3.5',
value: ModelTypeEnum.GPT3,
},
{
label: '同聪4.0',
value: ModelTypeEnum.GPT4,
},
]
const modelIndex = ref(0)
const roleList = ref<PictureType[]>([])
const applyList = ref<PictureType[]>([])
const messageList = computed(() => messageStore.getMessageList)
@ -107,11 +122,20 @@ async function handleSubMenuChange(index: number, item?: SubMenuItem) {
message.warn('请先结束对话')
return
}
if (!subMenuList.value.length) {
return
}
subMenuActiveIndex.value = index
historyMessageParams.value.current = 1
historyMessageParams.value.total = 0
messageStore.setConversationData(subMenuList.value[subMenuActiveIndex.value])
messageStore.setMessageClear()
const modelIdx = modelOptions.findIndex(v => v.value === Number(subMenuList.value[subMenuActiveIndex.value].modelType))
if (modelIdx === -1) {
message.warn('未找到该对话下的模型信息')
return
}
modelIndex.value = modelIdx
useMqtt().end()
useMqtt().connect()
@ -127,19 +151,20 @@ async function handleSubMenuChange(index: number, item?: SubMenuItem) {
async function handleSend(value: string) {
sendBtnLoading.value = true
conversationDefaultShow.value = false
if (!conversationData.value) {
return
}
if (subMenuActiveIndex.value === -1) {
try {
spinning.value = true
messageStore.setMessageClear()
await addMessage({ type: MenuTypeEnum.TEXT_TO_TEXT, title: '新的对话', sort: subMenuList.value.length + 1 })
await addMessage({ type: MenuTypeEnum.TEXT_TO_TEXT, title: '新的对话', sort: subMenuList.value.length + 1, modelType: modelOptions[modelIndex.value].value })
await getConversationList()
await nextTick()
subMenuActiveIndex.value = subMenuList.value.length - 1
await handleSubMenuChange(subMenuActiveIndex.value)
if (!conversationData.value) {
message.error('对话发送,请稍后重试!')
return
}
sendMessage(conversationData.value.id, value)
spinning.value = false
}
@ -148,6 +173,9 @@ async function handleSend(value: string) {
}
}
else {
if (!conversationData.value) {
return
}
sendMessage(conversationData.value.id, value)
}
}
@ -168,6 +196,8 @@ async function getConversationList() {
*/
async function getHistoryMessage() {
if (!conversationData.value) {
spinning.value = false
conversationDefaultShow.value = true
return
}
spinning.value = true
@ -195,10 +225,10 @@ async function getHistoryMessage() {
conversationDefaultShow.value = false
//
appMessageShow.value = false
setTimeout(() => {
appMessageShow.value = true
}, 0)
// appMessageShow.value = false
// setTimeout(() => {
// appMessageShow.value = true
// }, 0)
}
/**
@ -249,6 +279,7 @@ async function sendMessage(conversationId: string, question: string): Promise<vo
sendTextToText({
conversationId,
question,
modelType: modelOptions[modelIndex.value].value,
}).catch(() => {
messageStore.getMessageList.splice(-2)
messageStore.setMessageStatus(MessageStatusEnum.END)
@ -295,6 +326,13 @@ function handlePick(_index: number, item: TopPickItem) {
handleSend(item.label)
}
/**
* @description: gpt模型切换
*/
function handleModel(index: number) {
modelIndex.value = index
}
//
function getRoleData() {
getRole(1).then((res) => {
@ -327,6 +365,9 @@ function handleSubMenuInputBlur(index: number, item: SubMenuItem, inputValue: st
onMounted(async () => {
await getConversationList()
if (subMenuList.value.length) {
subMenuActiveIndex.value = 0
}
await handleSubMenuChange(subMenuActiveIndex.value)
getHistoryMessage()
getRoleData()
@ -377,6 +418,13 @@ onBeforeRouteLeave(() => {
</template>
<template #content>
<Spin :spinning="spinning" wrapper-class-name="app-content-spin">
<AppModelSelect
v-if="conversationDefaultShow"
:active-index="modelIndex"
:options="modelOptions"
@change="handleModel"
>
</AppModelSelect>
<!-- 默认导语 -->
<AppConversationDefault
v-if="conversationDefaultShow"

69
src/views/role/index.vue

@ -12,11 +12,13 @@ import type { SubMenuItem } from '@/components/AppSubMenuList/index.d'
import { AppTextarea } from '@/components/AppTextarea'
import { AppMessage } from '@/components/AppMessage'
import { AppModelSelect } from '@/components/AppModelSelect'
import type { ModelSelect } from '@/components/AppModelSelect/index.d'
import type { RoleData, RoleInfoAppModel } from '@/components/AppRoleDefault/index.d'
import type { MessageItem } from '@/components/AppMessage/index.d'
import { useMessageStore } from '@/store/moules/messageStore/index'
import { MenuTypeEnum } from '@/enums/menuEnum'
import { MessageStatusEnum, MessageTypeEnum } from '@/enums/messageEnum'
import { MessageStatusEnum, MessageTypeEnum, ModelTypeEnum } from '@/enums/messageEnum'
import { addMessage, conversationList, conversationToTop, historyMessage, removeMessage, sendTextToText, updateMessage } from '@/api/base/message'
import { getRoleDecs } from '@/api/base/role'
import { useMqtt } from '@/hooks/useMqtt'
@ -27,11 +29,24 @@ const { createConfirm } = useMessage()
const messageStore = useMessageStore()
const sendBtnLoading = ref(false)
const subMenuActiveIndex = ref(0) //
const subMenuActiveIndex = ref(-1) //
const subMenuActionIndex = ref(-1) //
const subMenuList = ref<SubMenuItem[]>([])
const subMenuInputValue = ref<string>('')
const appMessageRef = ref()
const modelOptions: ModelSelect[] = [
{
label: '同聪3.5',
value: ModelTypeEnum.GPT3,
},
{
label: '同聪4.0',
value: ModelTypeEnum.GPT4,
},
]
const modelIndex = ref(0)
const messageList = computed(() => messageStore.getMessageList)
const messageStatus = computed(() => messageStore.getMessageStatus)
const conversationData = computed(() => messageStore.getConversationData)
@ -105,11 +120,20 @@ async function handleSubMenuChange(index: number, item?: SubMenuItem) {
message.warn('请先结束对话')
return
}
if (!subMenuList.value.length) {
return
}
subMenuActiveIndex.value = index
historyMessageParams.value.current = 1
historyMessageParams.value.total = 0
messageStore.setConversationData(subMenuList.value[subMenuActiveIndex.value])
messageStore.setMessageClear()
const modelIdx = modelOptions.findIndex(v => v.value === Number(subMenuList.value[subMenuActiveIndex.value].modelType))
if (modelIdx === -1) {
message.warn('未找到该对话下的模型信息')
return
}
modelIndex.value = modelIdx
useMqtt().end()
useMqtt().connect()
@ -125,26 +149,11 @@ async function handleSubMenuChange(index: number, item?: SubMenuItem) {
async function handleSend(value: string) {
sendBtnLoading.value = true
conversationDefaultShow.value = false
if (!conversationData.value) {
return
}
if (subMenuActiveIndex.value === -1) {
try {
spinning.value = true
await addMessage({ type: MenuTypeEnum.ROLE, title: '新的对话', roleId: String(conversationData.value.roleId), sort: subMenuList.value.length + 1 })
await getConversationList()
await nextTick()
sendMessage(conversationData.value.id, value)
spinning.value = false
}
catch (error) {
message.error('新建对话失败,请稍后重试!')
}
}
else {
sendMessage(conversationData.value.id, value)
}
}
/**
@ -164,6 +173,8 @@ async function getConversationList() {
*/
async function getHistoryMessage() {
if (!conversationData.value) {
spinning.value = false
conversationDefaultShow.value = true
return
}
spinning.value = true
@ -252,6 +263,7 @@ async function sendMessage(conversationId: string, question: string): Promise<vo
sendTextToText({
conversationId,
question,
modelType: modelOptions[modelIndex.value].value,
}).catch(() => {
messageStore.getMessageList.splice(-2)
messageStore.setMessageStatus(MessageStatusEnum.END)
@ -293,7 +305,7 @@ async function handleRole(item: RoleData) {
getHistoryMessage()
}
else {
await addMessage({ type: MenuTypeEnum.ROLE, title: item.roleName, roleId: item.id, sort: subMenuList.value.length + 1 })
await addMessage({ type: MenuTypeEnum.ROLE, title: item.roleName, roleId: item.id, sort: subMenuList.value.length + 1, modelType: modelOptions[modelIndex.value].value })
await getConversationList()
await nextTick()
const index = subMenuList.value.findIndex(v => String(v.roleId) === item.id)
@ -314,7 +326,7 @@ async function handleApply(item: RoleInfoAppModel) {
getHistoryMessage()
}
else {
await addMessage({ type: MenuTypeEnum.ROLE, title: item.roleName, roleId: String(item.id), sort: subMenuList.value.length + 1 })
await addMessage({ type: MenuTypeEnum.ROLE, title: item.roleName, roleId: String(item.id), sort: subMenuList.value.length + 1, modelType: modelOptions[modelIndex.value].value })
await getConversationList()
await nextTick()
const index = subMenuList.value.findIndex(v => v.roleId === item.id)
@ -324,6 +336,13 @@ async function handleApply(item: RoleInfoAppModel) {
}
}
/**
* @description: gpt模型切换
*/
function handleModel(index: number) {
modelIndex.value = index
}
//
function handleSubMenuInputAffirm(index: number, item: SubMenuItem, inputValue: string) {
updateMessage({ ...item, title: inputValue }).then(() => {
@ -342,6 +361,9 @@ function handleSubMenuInputBlur(index: number, item: SubMenuItem, inputValue: st
onMounted(async () => {
await getConversationList()
if (subMenuList.value.length) {
subMenuActiveIndex.value = 0
}
await handleSubMenuChange(subMenuActiveIndex.value)
getHistoryMessage()
})
@ -390,6 +412,13 @@ onBeforeRouteLeave(() => {
</template>
<template #content>
<Spin :spinning="spinning" wrapper-class-name="app-content-spin">
<AppModelSelect
v-if="conversationDefaultShow"
:active-index="modelIndex"
:options="modelOptions"
@change="handleModel"
>
</AppModelSelect>
<!-- 默认导语 -->
<AppRoleDefault
v-if="conversationDefaultShow"

19
src/views/textToImage/index.vue

@ -27,7 +27,7 @@ const { createConfirm } = useMessage()
const messageStore = useMessageStore()
const sendBtnLoading = ref(false)
const subMenuActiveIndex = ref(0) //
const subMenuActiveIndex = ref(-1) //
const subMenuActionIndex = ref(-1) //
const subMenuList = ref<SubMenuItem[]>([])
const subMenuInputValue = ref<string>('')
@ -122,6 +122,9 @@ async function handleSubMenuChange(index: number, item?: SubMenuItem) {
message.warn('请先结束对话')
return
}
if (!subMenuList.value.length) {
return
}
subMenuActiveIndex.value = index
historyMessageParams.value.current = 1
historyMessageParams.value.total = 0
@ -142,9 +145,6 @@ async function handleSubMenuChange(index: number, item?: SubMenuItem) {
async function handleSend(value: string) {
sendBtnLoading.value = true
conversationDefaultShow.value = false
if (!conversationData.value) {
return
}
if (subMenuActiveIndex.value === -1) {
try {
@ -155,6 +155,9 @@ async function handleSend(value: string) {
await getConversationList()
subMenuActiveIndex.value = subMenuList.value.length - 1
await handleSubMenuChange(subMenuActiveIndex.value)
if (!conversationData.value) {
return
}
sendMessage(conversationData.value.id, value)
spinning.value = false
}
@ -163,6 +166,9 @@ async function handleSend(value: string) {
}
}
else {
if (!conversationData.value) {
return
}
sendMessage(conversationData.value.id, value)
}
}
@ -184,6 +190,8 @@ async function getConversationList() {
*/
async function getHistoryMessage() {
if (!conversationData.value) {
spinning.value = false
conversationDefaultShow.value = true
return
}
spinning.value = true
@ -317,6 +325,9 @@ function handleSubMenuInputBlur(index: number, item: SubMenuItem, inputValue: st
onMounted(async () => {
await getConversationList()
if (subMenuList.value.length) {
subMenuActiveIndex.value = 0
}
await handleSubMenuChange(subMenuActiveIndex.value)
getHistoryMessage()
})

Loading…
Cancel
Save