af-mobile-client-vue3 1.4.54 → 1.4.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/vite/optimize.ts +36 -36
- package/package.json +1 -1
- package/public/favicon.svg +4 -4
- package/scripts/verifyCommit.js +19 -19
- package/src/components/common/MateChat/apiService.ts +134 -103
- package/src/components/common/MateChat/components/MateChatContent.vue +281 -0
- package/src/components/common/MateChat/components/MateChatHeader.vue +298 -253
- package/src/components/common/MateChat/components/PasswordDialog.vue +97 -0
- package/src/components/common/MateChat/composables/useChatHistoryCache.ts +117 -0
- package/src/components/common/MateChat/composables/useChatMessagesCache.ts +72 -0
- package/src/components/common/MateChat/composables/useMateChat.ts +372 -0
- package/src/components/common/MateChat/composables/usePasswordManager.ts +38 -0
- package/src/components/common/MateChat/index.vue +443 -0
- package/src/components/common/MateChat/types.ts +241 -0
- package/src/components/data/UserDetail/types.ts +1 -1
- package/src/components/data/XFormGroup/doc/DeviceForm.vue +1 -1
- package/src/components/data/XFormGroup/doc/UserForm.vue +1 -1
- package/src/components/data/XReportGrid/XAddReport/index.ts +1 -1
- package/src/components/data/XReportGrid/XReportDemo.vue +33 -33
- package/src/components/data/XReportGrid/XReportDrawer/index.ts +1 -1
- package/src/components/data/XReportGrid/print.js +184 -184
- package/src/components/data/XTag/index.vue +10 -10
- package/src/components/layout/TabBarLayout/index.vue +40 -40
- package/src/hooks/useCommon.ts +9 -9
- package/src/plugins/AppData.ts +38 -38
- package/src/router/invoiceRoutes.ts +33 -33
- package/src/services/api/common.ts +109 -109
- package/src/services/api/manage.ts +8 -8
- package/src/services/api/search.ts +16 -16
- package/src/services/restTools.ts +56 -56
- package/src/utils/authority-utils.ts +84 -84
- package/src/utils/crypto.ts +39 -39
- package/src/utils/runEvalFunction.ts +13 -13
- package/src/utils/timeUtil.ts +27 -27
- package/src/views/component/EvaluateRecordView/index.vue +40 -40
- package/src/views/component/MateChat/MateChatView.vue +10 -51
- package/src/views/component/XCellDetailView/index.vue +217 -217
- package/src/views/component/XReportFormIframeView/index.vue +47 -47
- package/src/views/component/XReportFormView/index.vue +13 -13
- package/src/views/component/XSignatureView/index.vue +50 -50
- package/src/views/component/notice.vue +46 -46
- package/src/views/component/topNav.vue +36 -36
- package/src/views/invoiceShow/index.vue +61 -61
- package/src/views/user/login/index.vue +22 -22
- package/vite.config.ts +2 -1
- package/src/components/common/MateChat/MateChat.vue +0 -248
- package/src/components/common/MateChat/useMateChat.ts +0 -212
package/build/vite/optimize.ts
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
const include = [
|
|
2
|
-
'axios',
|
|
3
|
-
'echarts',
|
|
4
|
-
'lodash-es',
|
|
5
|
-
'resize-detector',
|
|
6
|
-
'vant/es',
|
|
7
|
-
'vant/es/cell-group/style/index',
|
|
8
|
-
'vant/es/popup/style/index',
|
|
9
|
-
'vant/es/picker/style/index',
|
|
10
|
-
'vant/es/cell/style/index',
|
|
11
|
-
'vant/es/switch/style/index',
|
|
12
|
-
'vant/es/space/style/index',
|
|
13
|
-
'vant/es/button/style/index',
|
|
14
|
-
'vant/es/empty/style/index',
|
|
15
|
-
'vant/es/icon/style/index',
|
|
16
|
-
'vant/es/stepper/style/index',
|
|
17
|
-
'vant/es/image/style/index',
|
|
18
|
-
'vant/es/form/style/index',
|
|
19
|
-
'vant/es/field/style/index',
|
|
20
|
-
'vant/es/notify/style/index',
|
|
21
|
-
'vant/es/config-provider/style/index',
|
|
22
|
-
'vant/es/nav-bar/style/index',
|
|
23
|
-
'vant/es/tabbar/style/index',
|
|
24
|
-
'vant/es/tabbar-item/style/index',
|
|
25
|
-
'vant/es/list/style/index',
|
|
26
|
-
'vant/es/text-ellipsis/style/index',
|
|
27
|
-
// 确保 @matechat/core 及其依赖 xss 被正确预构建
|
|
28
|
-
'@matechat/core',
|
|
29
|
-
]
|
|
30
|
-
|
|
31
|
-
const exclude = [
|
|
32
|
-
'@iconify/json',
|
|
33
|
-
'@iconify/vue',
|
|
34
|
-
]
|
|
35
|
-
|
|
36
|
-
export { exclude, include }
|
|
1
|
+
const include = [
|
|
2
|
+
'axios',
|
|
3
|
+
'echarts',
|
|
4
|
+
'lodash-es',
|
|
5
|
+
'resize-detector',
|
|
6
|
+
'vant/es',
|
|
7
|
+
'vant/es/cell-group/style/index',
|
|
8
|
+
'vant/es/popup/style/index',
|
|
9
|
+
'vant/es/picker/style/index',
|
|
10
|
+
'vant/es/cell/style/index',
|
|
11
|
+
'vant/es/switch/style/index',
|
|
12
|
+
'vant/es/space/style/index',
|
|
13
|
+
'vant/es/button/style/index',
|
|
14
|
+
'vant/es/empty/style/index',
|
|
15
|
+
'vant/es/icon/style/index',
|
|
16
|
+
'vant/es/stepper/style/index',
|
|
17
|
+
'vant/es/image/style/index',
|
|
18
|
+
'vant/es/form/style/index',
|
|
19
|
+
'vant/es/field/style/index',
|
|
20
|
+
'vant/es/notify/style/index',
|
|
21
|
+
'vant/es/config-provider/style/index',
|
|
22
|
+
'vant/es/nav-bar/style/index',
|
|
23
|
+
'vant/es/tabbar/style/index',
|
|
24
|
+
'vant/es/tabbar-item/style/index',
|
|
25
|
+
'vant/es/list/style/index',
|
|
26
|
+
'vant/es/text-ellipsis/style/index',
|
|
27
|
+
// 确保 @matechat/core 及其依赖 xss 被正确预构建
|
|
28
|
+
'@matechat/core',
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
const exclude = [
|
|
32
|
+
'@iconify/json',
|
|
33
|
+
'@iconify/vue',
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
export { exclude, include }
|
package/package.json
CHANGED
package/public/favicon.svg
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<svg t="1709866807903" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4913" width="32" height="32">
|
|
2
|
-
<path d="M512 598.528a111.232 111.232 0 0 0-111.232 111.2064V870.4h222.464v-160.6656c0-61.44-49.792-111.232-111.232-111.232z m0 58.0608c-30.72 0-55.6032 24.9088-55.6032 55.6288v105.0368h111.2064v-105.0368c0-30.72-24.8832-55.6288-55.6032-55.6288z" fill="#FB4D31" p-id="4914"></path>
|
|
3
|
-
<path d="M542.08 270.208l45.2608-78.5408a24.5248 24.5248 0 0 0 0-25.6A26.4448 26.4448 0 0 0 564.1472 153.6a26.3424 26.3424 0 0 0-22.5792 13.44L512 217.6256l-29.5424-50.5344c-4.5824-8.192-13.184-13.312-22.5536-13.4912a26.4448 26.4448 0 0 0-23.2448 12.4928 24.5248 24.5248 0 0 0 0 25.6l45.2352 78.5152L156.928 832.768a24.4736 24.4736 0 0 0 0.3328 25.088c4.8384 7.8336 13.3888 12.544 22.5792 12.5184h664.3456c9.3184 0 17.92-4.7616 22.6304-12.4672a24.4736 24.4736 0 0 0 0.3072-25.088l-325.0176-562.688v0.0512zM619.52 816.64h-33.3568c-12.3648 0-9.6768 0.1024-65.0496 0H512c-55.3728 0.1024-24.704 0-61.7984 0H225.28L512 322.1248 798.72 816.64h-179.2z" fill="#000000" p-id="4915"></path>
|
|
4
|
-
</svg>
|
|
1
|
+
<svg t="1709866807903" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4913" width="32" height="32">
|
|
2
|
+
<path d="M512 598.528a111.232 111.232 0 0 0-111.232 111.2064V870.4h222.464v-160.6656c0-61.44-49.792-111.232-111.232-111.232z m0 58.0608c-30.72 0-55.6032 24.9088-55.6032 55.6288v105.0368h111.2064v-105.0368c0-30.72-24.8832-55.6288-55.6032-55.6288z" fill="#FB4D31" p-id="4914"></path>
|
|
3
|
+
<path d="M542.08 270.208l45.2608-78.5408a24.5248 24.5248 0 0 0 0-25.6A26.4448 26.4448 0 0 0 564.1472 153.6a26.3424 26.3424 0 0 0-22.5792 13.44L512 217.6256l-29.5424-50.5344c-4.5824-8.192-13.184-13.312-22.5536-13.4912a26.4448 26.4448 0 0 0-23.2448 12.4928 24.5248 24.5248 0 0 0 0 25.6l45.2352 78.5152L156.928 832.768a24.4736 24.4736 0 0 0 0.3328 25.088c4.8384 7.8336 13.3888 12.544 22.5792 12.5184h664.3456c9.3184 0 17.92-4.7616 22.6304-12.4672a24.4736 24.4736 0 0 0 0.3072-25.088l-325.0176-562.688v0.0512zM619.52 816.64h-33.3568c-12.3648 0-9.6768 0.1024-65.0496 0H512c-55.3728 0.1024-24.704 0-61.7984 0H225.28L512 322.1248 798.72 816.64h-179.2z" fill="#000000" p-id="4915"></path>
|
|
4
|
+
</svg>
|
package/scripts/verifyCommit.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import fs from 'node:fs'
|
|
2
|
-
|
|
3
|
-
// import process from 'node:process'
|
|
4
|
-
|
|
5
|
-
const msg = fs.readFileSync('.git/COMMIT_EDITMSG', 'utf-8').trim()
|
|
6
|
-
|
|
7
|
-
const commitRE = /^(?:revert: )?(?:feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip|release)(?:\(.+\))?: .{1,50}/
|
|
8
|
-
// const mergeRe = /^(Merge pull request|Merge branch)/
|
|
9
|
-
|
|
10
|
-
if (!commitRE.test(msg)) {
|
|
11
|
-
// if (!mergeRe.test(msg)) {
|
|
12
|
-
// console.log('git commit unpass')
|
|
13
|
-
// console.error('git commit error, needs title(scope): desc')
|
|
14
|
-
// process.exit(1)
|
|
15
|
-
// }
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
console.log('git commit pass')
|
|
19
|
-
}
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
|
|
3
|
+
// import process from 'node:process'
|
|
4
|
+
|
|
5
|
+
const msg = fs.readFileSync('.git/COMMIT_EDITMSG', 'utf-8').trim()
|
|
6
|
+
|
|
7
|
+
const commitRE = /^(?:revert: )?(?:feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip|release)(?:\(.+\))?: .{1,50}/
|
|
8
|
+
// const mergeRe = /^(Merge pull request|Merge branch)/
|
|
9
|
+
|
|
10
|
+
if (!commitRE.test(msg)) {
|
|
11
|
+
// if (!mergeRe.test(msg)) {
|
|
12
|
+
// console.log('git commit unpass')
|
|
13
|
+
// console.error('git commit error, needs title(scope): desc')
|
|
14
|
+
// process.exit(1)
|
|
15
|
+
// }
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
console.log('git commit pass')
|
|
19
|
+
}
|
|
@@ -1,92 +1,17 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ChatBizResult,
|
|
3
|
+
ChatCompletionsRequest,
|
|
4
|
+
ChatCompletionsResponse,
|
|
5
|
+
ChatStreamCallbacks,
|
|
6
|
+
GetHistoriesRequest,
|
|
7
|
+
GetHistoriesResponse,
|
|
8
|
+
GetPaginationRecordsRequest,
|
|
9
|
+
GetPaginationRecordsResponse,
|
|
10
|
+
} from '@af-mobile-client-vue3/components/common/MateChat/types'
|
|
1
11
|
import type { AxiosInstance } from 'axios'
|
|
12
|
+
import { useUserStore } from '@af-mobile-client-vue3/stores/modules/user'
|
|
2
13
|
import axios from 'axios'
|
|
3
14
|
|
|
4
|
-
/**
|
|
5
|
-
* 聊天消息接口
|
|
6
|
-
*/
|
|
7
|
-
export interface ChatMessage {
|
|
8
|
-
role: 'user' | 'assistant' | 'system'
|
|
9
|
-
content: string
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* 聊天请求参数接口
|
|
14
|
-
*/
|
|
15
|
-
export interface ChatCompletionsRequest {
|
|
16
|
-
chatId: string
|
|
17
|
-
stream: boolean
|
|
18
|
-
detail: boolean
|
|
19
|
-
variables: {
|
|
20
|
-
uid: string
|
|
21
|
-
name: string
|
|
22
|
-
}
|
|
23
|
-
messages: ChatMessage[]
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* 聊天响应使用情况接口
|
|
28
|
-
*/
|
|
29
|
-
export interface ChatUsage {
|
|
30
|
-
prompt_tokens: number
|
|
31
|
-
completion_tokens: number
|
|
32
|
-
total_tokens: number
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* 聊天响应选择项接口
|
|
37
|
-
*/
|
|
38
|
-
export interface ChatChoice {
|
|
39
|
-
message: {
|
|
40
|
-
role: 'assistant'
|
|
41
|
-
content: string
|
|
42
|
-
}
|
|
43
|
-
finish_reason: string
|
|
44
|
-
index: number
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* 聊天响应接口
|
|
49
|
-
*/
|
|
50
|
-
export interface ChatCompletionsResponse {
|
|
51
|
-
id: string
|
|
52
|
-
model: string
|
|
53
|
-
usage: ChatUsage
|
|
54
|
-
choices: ChatChoice[]
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* 业务层聊天结果
|
|
59
|
-
*/
|
|
60
|
-
export interface ChatBizResult {
|
|
61
|
-
/**
|
|
62
|
-
* normal: 普通回复
|
|
63
|
-
* transfer: 转人工
|
|
64
|
-
*/
|
|
65
|
-
type: 'normal' | 'transfer'
|
|
66
|
-
/**
|
|
67
|
-
* 大模型原始返回内容
|
|
68
|
-
*/
|
|
69
|
-
content: string
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* 流式对话回调
|
|
74
|
-
*/
|
|
75
|
-
export interface ChatStreamCallbacks {
|
|
76
|
-
/**
|
|
77
|
-
* 每次收到 FastGPT SSE 的增量内容时触发
|
|
78
|
-
*/
|
|
79
|
-
onMessage?: (chunk: string) => void
|
|
80
|
-
/**
|
|
81
|
-
* 流结束时触发(包括收到 [DONE] 或正常读取结束)
|
|
82
|
-
*/
|
|
83
|
-
onComplete?: () => void
|
|
84
|
-
/**
|
|
85
|
-
* 请求或解析发生异常时触发
|
|
86
|
-
*/
|
|
87
|
-
onError?: (error: unknown) => void
|
|
88
|
-
}
|
|
89
|
-
|
|
90
15
|
/**
|
|
91
16
|
* 创建独立的 axios 实例,不经过拦截器
|
|
92
17
|
*/
|
|
@@ -98,34 +23,56 @@ const chatAxiosInstance: AxiosInstance = axios.create({
|
|
|
98
23
|
},
|
|
99
24
|
})
|
|
100
25
|
|
|
26
|
+
/**
|
|
27
|
+
* 生成 outLinkUid:用户类型 + 用户ID
|
|
28
|
+
* @returns outLinkUid 字符串,格式:用户类型_用户ID
|
|
29
|
+
*/
|
|
30
|
+
export function generateOutLinkUid(): string {
|
|
31
|
+
const userStore = useUserStore()
|
|
32
|
+
const userInfo = userStore.getUserInfo()
|
|
33
|
+
const userType = userStore.getUserType()
|
|
34
|
+
|
|
35
|
+
// 用户类型:SYSTEM 或 EXTERNAL,如果为 null 则默认为 SYSTEM
|
|
36
|
+
const type = userType || 'SYSTEM'
|
|
37
|
+
// 用户ID
|
|
38
|
+
const userId = userInfo?.id || ''
|
|
39
|
+
|
|
40
|
+
return `${type}_${userId}`
|
|
41
|
+
}
|
|
42
|
+
|
|
101
43
|
/**
|
|
102
44
|
* 发送聊天请求
|
|
103
45
|
* @param content 用户输入的内容
|
|
46
|
+
* @param appId FastGPT 应用 ID
|
|
47
|
+
* @param appKey FastGPT API Key
|
|
48
|
+
* @param chatId 会话 ID
|
|
104
49
|
* @returns Promise<ChatCompletionsResponse>
|
|
105
50
|
*/
|
|
106
|
-
export function chatCompletions(
|
|
51
|
+
export function chatCompletions(
|
|
52
|
+
content: string,
|
|
53
|
+
appId: string,
|
|
54
|
+
appKey: string,
|
|
55
|
+
chatId: string,
|
|
56
|
+
): Promise<ChatCompletionsResponse> {
|
|
107
57
|
const requestData: ChatCompletionsRequest = {
|
|
108
|
-
chatId
|
|
58
|
+
chatId,
|
|
109
59
|
stream: false,
|
|
110
60
|
detail: false,
|
|
111
|
-
variables: {
|
|
112
|
-
uid: 'asdfadsfasfd2323',
|
|
113
|
-
name: '张三',
|
|
114
|
-
},
|
|
115
61
|
messages: [
|
|
116
62
|
{
|
|
117
63
|
role: 'user',
|
|
118
64
|
content,
|
|
119
65
|
},
|
|
120
66
|
],
|
|
67
|
+
customUid: generateOutLinkUid(),
|
|
121
68
|
}
|
|
122
69
|
|
|
123
70
|
return chatAxiosInstance.post<ChatCompletionsResponse>(
|
|
124
|
-
'/v1/chat/completions',
|
|
71
|
+
'/fastApi/v1/chat/completions',
|
|
125
72
|
requestData,
|
|
126
73
|
{
|
|
127
74
|
headers: {
|
|
128
|
-
Authorization:
|
|
75
|
+
Authorization: `Bearer ${appKey}`,
|
|
129
76
|
},
|
|
130
77
|
},
|
|
131
78
|
).then(response => response.data)
|
|
@@ -135,9 +82,18 @@ export function chatCompletions(content: string): Promise<ChatCompletionsRespons
|
|
|
135
82
|
* 封装后的业务聊天请求
|
|
136
83
|
* - 负责从大模型返回中解析出业务含义(普通回复 / 转人工)
|
|
137
84
|
* - UI 层只需要根据 type 决定渲染哪种气泡
|
|
85
|
+
* @param content 用户输入的内容
|
|
86
|
+
* @param appId FastGPT 应用 ID
|
|
87
|
+
* @param appKey FastGPT API Key
|
|
88
|
+
* @param chatId 会话 ID
|
|
138
89
|
*/
|
|
139
|
-
export async function chatBiz(
|
|
140
|
-
|
|
90
|
+
export async function chatBiz(
|
|
91
|
+
content: string,
|
|
92
|
+
appId: string,
|
|
93
|
+
appKey: string,
|
|
94
|
+
chatId: string,
|
|
95
|
+
): Promise<ChatBizResult> {
|
|
96
|
+
const response = await chatCompletions(content, appId, appKey, chatId)
|
|
141
97
|
|
|
142
98
|
if (!response.choices || response.choices.length === 0) {
|
|
143
99
|
throw new Error('响应数据格式错误')
|
|
@@ -167,36 +123,41 @@ export async function chatBiz(content: string): Promise<ChatBizResult> {
|
|
|
167
123
|
/**
|
|
168
124
|
* 使用 FastGPT /v1/chat/completions 的 stream=true 进行流式对话
|
|
169
125
|
* 参考官方文档: https://doc.fastgpt.io/docs/introduction/development/openapi/chat
|
|
126
|
+
* @param content 用户输入的内容
|
|
127
|
+
* @param appId FastGPT 应用 ID
|
|
128
|
+
* @param appKey FastGPT API Key
|
|
129
|
+
* @param chatId 会话 ID
|
|
130
|
+
* @param callbacks 流式回调函数
|
|
170
131
|
*/
|
|
171
132
|
export async function chatCompletionsStream(
|
|
172
133
|
content: string,
|
|
134
|
+
appId: string,
|
|
135
|
+
appKey: string,
|
|
136
|
+
chatId: string,
|
|
173
137
|
callbacks: ChatStreamCallbacks,
|
|
174
138
|
): Promise<void> {
|
|
175
139
|
const { onMessage, onComplete, onError } = callbacks
|
|
176
140
|
|
|
177
141
|
const requestData: ChatCompletionsRequest = {
|
|
178
|
-
chatId
|
|
142
|
+
chatId,
|
|
179
143
|
stream: true,
|
|
180
144
|
detail: false,
|
|
181
|
-
variables: {
|
|
182
|
-
uid: 'asdfadsfasfd2323',
|
|
183
|
-
name: '张三',
|
|
184
|
-
},
|
|
185
145
|
messages: [
|
|
186
146
|
{
|
|
187
147
|
role: 'user',
|
|
188
148
|
content,
|
|
189
149
|
},
|
|
190
150
|
],
|
|
151
|
+
customUid: generateOutLinkUid(),
|
|
191
152
|
}
|
|
192
153
|
|
|
193
154
|
try {
|
|
194
155
|
const baseUrl = import.meta.env.VITE_APP_API_BASE_URL || ''
|
|
195
|
-
const res = await fetch(`${baseUrl}/v1/chat/completions`, {
|
|
156
|
+
const res = await fetch(`${baseUrl}/fastApi/v1/chat/completions`, {
|
|
196
157
|
method: 'POST',
|
|
197
158
|
headers: {
|
|
198
159
|
'Content-Type': 'application/json',
|
|
199
|
-
'Authorization':
|
|
160
|
+
'Authorization': `Bearer ${appKey}`,
|
|
200
161
|
},
|
|
201
162
|
body: JSON.stringify(requestData),
|
|
202
163
|
})
|
|
@@ -252,3 +213,73 @@ export async function chatCompletionsStream(
|
|
|
252
213
|
onError?.(error)
|
|
253
214
|
}
|
|
254
215
|
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* 获取历史会话列表
|
|
219
|
+
* @param appId FastGPT 应用 ID
|
|
220
|
+
* @param appKey FastGPT API Key
|
|
221
|
+
* @param offset 偏移量
|
|
222
|
+
* @param pageSize 每页数量
|
|
223
|
+
* @returns Promise<GetHistoriesResponse>
|
|
224
|
+
*/
|
|
225
|
+
export function getHistories(
|
|
226
|
+
appId: string,
|
|
227
|
+
appKey: string,
|
|
228
|
+
offset: number = 0,
|
|
229
|
+
pageSize: number = 5,
|
|
230
|
+
): Promise<GetHistoriesResponse> {
|
|
231
|
+
const requestData: GetHistoriesRequest = {
|
|
232
|
+
appId,
|
|
233
|
+
outLinkUid: generateOutLinkUid(),
|
|
234
|
+
offset,
|
|
235
|
+
pageSize,
|
|
236
|
+
source: 'api',
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return chatAxiosInstance.post<GetHistoriesResponse>(
|
|
240
|
+
'/fastApi/core/chat/getHistories',
|
|
241
|
+
requestData,
|
|
242
|
+
{
|
|
243
|
+
headers: {
|
|
244
|
+
Authorization: `Bearer ${appKey}`,
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
).then(response => response.data)
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* 获取历史会话记录
|
|
252
|
+
* @param appId FastGPT 应用 ID
|
|
253
|
+
* @param appKey FastGPT API Key
|
|
254
|
+
* @param chatId 会话 ID
|
|
255
|
+
* @param offset 偏移量
|
|
256
|
+
* @param pageSize 每页数量
|
|
257
|
+
* @param loadCustomFeedbacks 是否加载自定义反馈
|
|
258
|
+
* @returns Promise<GetPaginationRecordsResponse>
|
|
259
|
+
*/
|
|
260
|
+
export function getPaginationRecords(
|
|
261
|
+
appId: string,
|
|
262
|
+
appKey: string,
|
|
263
|
+
chatId: string,
|
|
264
|
+
offset: number = 0,
|
|
265
|
+
pageSize: number = 10,
|
|
266
|
+
loadCustomFeedbacks: boolean = true,
|
|
267
|
+
): Promise<GetPaginationRecordsResponse> {
|
|
268
|
+
const requestData: GetPaginationRecordsRequest = {
|
|
269
|
+
appId,
|
|
270
|
+
chatId,
|
|
271
|
+
offset,
|
|
272
|
+
pageSize,
|
|
273
|
+
loadCustomFeedbacks,
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return chatAxiosInstance.post<GetPaginationRecordsResponse>(
|
|
277
|
+
'/fastApi/core/chat/getPaginationRecords',
|
|
278
|
+
requestData,
|
|
279
|
+
{
|
|
280
|
+
headers: {
|
|
281
|
+
Authorization: `Bearer ${appKey}`,
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
).then(response => response.data)
|
|
285
|
+
}
|