Skip to content

Commit 64a691a

Browse files
committed
Merge branch 'dev' of https://gitee.com/yudaocode/yudao-ui-admin-vue3 into feature/bpm
2 parents 88356c7 + 7fe8b8b commit 64a691a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+6505
-267
lines changed

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"private": false,
77
"scripts": {
88
"i": "pnpm install",
9-
"dev": "vite",
9+
"dev": "vite --mode env.local",
1010
"dev-server": "vite --mode dev",
1111
"ts:check": "vue-tsc --noEmit",
1212
"build:local": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build",
@@ -29,6 +29,7 @@
2929
"@form-create/designer": "^3.1.3",
3030
"@form-create/element-ui": "^3.1.24",
3131
"@iconify/iconify": "^3.1.1",
32+
"@microsoft/fetch-event-source": "^2.0.1",
3233
"@videojs-player/vue": "^1.0.0",
3334
"@vueuse/core": "^10.9.0",
3435
"@wangeditor/editor": "^5.1.23",
@@ -46,11 +47,12 @@
4647
"driver.js": "^1.3.1",
4748
"echarts": "^5.5.0",
4849
"echarts-wordcloud": "^2.1.0",
49-
"element-plus": "2.6.1",
50+
"element-plus": "2.7.0",
5051
"fast-xml-parser": "^4.3.2",
5152
"highlight.js": "^11.9.0",
5253
"jsencrypt": "^3.3.2",
5354
"lodash-es": "^4.17.21",
55+
"marked": "^12.0.2",
5456
"min-dash": "^4.1.1",
5557
"mitt": "^3.0.1",
5658
"nprogress": "^0.2.0",

pnpm-lock.yaml

Lines changed: 20 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/App.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,8 @@ body {
5454
.#{$prefix-cls}-grey-mode {
5555
filter: grayscale(100%);
5656
}
57+
58+
.scrollbar__view {
59+
height: 99%!important;
60+
}
5761
</style>

src/api/ai/chat/conversation/index.ts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import request from '@/config/axios'
2+
3+
// AI 聊天对话 VO
4+
export interface ChatConversationVO {
5+
id: string // ID 编号
6+
userId: number // 用户编号
7+
title: string // 对话标题
8+
pinned: boolean // 是否置顶
9+
roleId: number // 角色编号
10+
modelId: number // 模型编号
11+
model: string // 模型标志
12+
temperature: number // 温度参数
13+
maxTokens: number // 单条回复的最大 Token 数量
14+
maxContexts: number // 上下文的最大 Message 数量
15+
// 额外字段
16+
systemMessage?: string // 角色设定
17+
modelName?: string // 模型名字
18+
roleAvatar?: string // 角色头像
19+
modelMaxTokens?: string // 模型的单条回复的最大 Token 数量
20+
modelMaxContexts?: string // 模型的上下文的最大 Message 数量
21+
}
22+
23+
// AI 聊天对话 API
24+
export const ChatConversationApi = {
25+
// 获得【我的】聊天对话
26+
getChatConversationMy: async (id: string) => {
27+
return await request.get({ url: `/ai/chat/conversation/get-my?id=${id}` })
28+
},
29+
30+
// 新增【我的】聊天对话
31+
createChatConversationMy: async (data?: ChatConversationVO) => {
32+
return await request.post({ url: `/ai/chat/conversation/create-my`, data })
33+
},
34+
35+
// 更新【我的】聊天对话
36+
updateChatConversationMy: async (data: ChatConversationVO) => {
37+
return await request.put({ url: `/ai/chat/conversation/update-my`, data })
38+
},
39+
40+
// 删除【我的】聊天对话
41+
deleteChatConversationMy: async (id: string) => {
42+
return await request.delete({ url: `/ai/chat/conversation/delete-my?id=${id}` })
43+
},
44+
45+
// 删除【我的】所有对话,置顶除外
46+
deleteMyAllExceptPinned: async () => {
47+
return await request.delete({ url: `/ai/chat/conversation/delete-my-all-except-pinned` })
48+
},
49+
50+
// 获得【我的】聊天对话列表
51+
getChatConversationMyList: async () => {
52+
return await request.get({ url: `/ai/chat/conversation/my-list` })
53+
},
54+
55+
// 获得对话分页
56+
getChatConversationPage: async (params: any) => {
57+
return await request.get({ url: `/ai/chat/conversation/page`, params })
58+
},
59+
60+
// 管理员删除消息
61+
deleteChatConversationByAdmin: async (id: number) => {
62+
return await request.delete({ url: `/ai/chat/conversation/delete-by-admin?id=${id}` })
63+
}
64+
}

src/api/ai/chat/message/index.ts

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import request from '@/config/axios'
2+
import { fetchEventSource } from '@microsoft/fetch-event-source'
3+
import { getAccessToken } from '@/utils/auth'
4+
import { config } from '@/config/axios/config'
5+
6+
// 聊天VO
7+
export interface ChatMessageVO {
8+
id: number // 编号
9+
conversationId: number // 对话编号
10+
type: string // 消息类型
11+
userId: string // 用户编号
12+
roleId: string // 角色编号
13+
model: number // 模型标志
14+
modelId: number // 模型编号
15+
content: string // 聊天内容
16+
tokens: number // 消耗 Token 数量
17+
createTime: Date // 创建时间
18+
roleAvatar: string // 角色头像
19+
userAvatar: string // 创建时间
20+
}
21+
22+
export interface ChatMessageSendVO {
23+
conversationId: string // 对话编号
24+
content: number // 聊天内容
25+
}
26+
27+
// AI chat 聊天
28+
export const ChatMessageApi = {
29+
// 消息列表
30+
messageList: async (conversationId: string | null) => {
31+
return await request.get({
32+
url: `/ai/chat/message/list-by-conversation-id?conversationId=${conversationId}`
33+
})
34+
},
35+
36+
// 发送 send stream 消息
37+
// TODO axios 可以么? https://apifox.com/apiskills/how-to-create-axios-stream/
38+
sendStream: async (
39+
conversationId: number,
40+
content: string,
41+
ctrl,
42+
enableContext: boolean,
43+
onMessage,
44+
onError,
45+
onClose
46+
) => {
47+
const token = getAccessToken()
48+
return fetchEventSource(`${config.base_url}/ai/chat/message/send-stream`, {
49+
method: 'post',
50+
headers: {
51+
'Content-Type': 'application/json',
52+
Authorization: `Bearer ${token}`
53+
},
54+
openWhenHidden: true,
55+
body: JSON.stringify({
56+
conversationId,
57+
content,
58+
useContext: enableContext
59+
}),
60+
onmessage: onMessage,
61+
onerror: onError,
62+
onclose: onClose,
63+
signal: ctrl.signal
64+
})
65+
},
66+
67+
// 删除消息
68+
delete: async (id: string) => {
69+
return await request.delete({ url: `/ai/chat/message/delete?id=${id}` })
70+
},
71+
72+
// 删除消息 - 对话所有消息
73+
deleteByConversationId: async (conversationId: string) => {
74+
return await request.delete({
75+
url: `/ai/chat/message/delete-by-conversation-id?conversationId=${conversationId}`
76+
})
77+
},
78+
79+
// 获得消息分页
80+
getChatMessagePage: async (params: any) => {
81+
return await request.get({ url: '/ai/chat/message/page', params })
82+
},
83+
84+
// 管理员删除消息
85+
deleteChatMessageByAdmin: async (id: number) => {
86+
return await request.delete({ url: `/ai/chat/message/delete-by-admin?id=${id}` })
87+
}
88+
}

src/api/ai/image/index.ts

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import request from '@/config/axios'
2+
3+
// AI API 密钥 VO
4+
// TODO @fan:要不前端不弄太多 VO,就用这个 ImageDetailVO?!
5+
export interface ImageDetailVO {
6+
id: number // 编号
7+
prompt: string // 提示词
8+
status: number // 状态
9+
errorMessage: string // 错误信息
10+
type: string // 模型下分不同的类型(清晰、真实...)
11+
taskId: number // dr 任务id
12+
picUrl: string // 任务地址
13+
originalPicUrl: string // 绘制图片地址
14+
platform: string // 平台
15+
model: string // 模型
16+
style: string // 图像生成的风格
17+
size: string // 图片尺寸
18+
buttons: ImageMjButtonsVO[] // mj 操作按钮
19+
createTime: string // 创建时间
20+
updateTime: string // 更新事件
21+
}
22+
23+
export interface ImageMjButtonsVO {
24+
customId: string // MJ::JOB::upsample::1::85a4b4c1-8835-46c5-a15c-aea34fad1862 动作标识
25+
emoji: string // 图标 emoji
26+
label: string // Make Variations 文本
27+
style: number // 样式: 2(Primary)、3(Green)
28+
}
29+
30+
export interface ImageMjActionVO {
31+
id: string // MJ::JOB::upsample::1::85a4b4c1-8835-46c5-a15c-aea34fad1862 动作标识
32+
customId: string // MJ::JOB::upsample::1::85a4b4c1-8835-46c5-a15c-aea34fad1862 动作标识
33+
}
34+
35+
36+
export interface ImagePageReqVO {
37+
pageNo: number // 分页编号
38+
pageSize: number // 分页大小
39+
}
40+
41+
export interface ImageDallReqVO {
42+
prompt: string // 提示词
43+
model: string // 模型
44+
style: string // 图像生成的风格
45+
width: string // 图片宽度
46+
height: string // 图片高度
47+
}
48+
49+
export interface ImageDrawReqVO {
50+
platform: string // 平台
51+
prompt: string // 提示词
52+
model: string // 模型
53+
style: string // 图像生成的风格
54+
width: string // 图片宽度
55+
height: string // 图片高度
56+
options: object // 绘制参数,Map<String, String>
57+
}
58+
59+
export interface ImageMidjourneyImagineReqVO {
60+
prompt: string // 提示词
61+
model: string // 模型 mj nijj
62+
base64Array: string[] // size不能为空
63+
width: string // 图片宽度
64+
height: string // 图片高度
65+
version: string // 版本
66+
}
67+
68+
// TODO 芋艿:review 下整体注释、方法名
69+
// AI API 密钥 API
70+
export const ImageApi = {
71+
// 获取 image 列表
72+
getImageList: async (params: ImagePageReqVO) => {
73+
return await request.get({ url: `/ai/image/my-page`, params })
74+
},
75+
// 获取 image 详细信息
76+
getImageDetail: async (id: number) => {
77+
return await request.get({ url: `/ai/image/get-my?id=${id}`})
78+
},
79+
// 生成图片
80+
drawImage: async (data: ImageDrawReqVO)=> {
81+
return await request.post({ url: `/ai/image/draw`, data })
82+
},
83+
// 删除
84+
deleteImage: async (id: number)=> {
85+
return await request.delete({ url: `/ai/image/delete-my?id=${id}`})
86+
},
87+
88+
// ------------ midjourney
89+
90+
// midjourney - imagine
91+
midjourneyImagine: async (data: ImageMidjourneyImagineReqVO)=> {
92+
return await request.post({ url: `/ai/image/midjourney/imagine`, data })
93+
},
94+
// midjourney - action
95+
midjourneyAction: async (params: ImageMjActionVO)=> {
96+
return await request.get({ url: `/ai/image/midjourney/action`, params })
97+
},
98+
}

0 commit comments

Comments
 (0)