Skip to content

Commit e9527bd

Browse files
feat: chat log
1 parent fa818fc commit e9527bd

File tree

17 files changed

+1645
-58
lines changed

17 files changed

+1645
-58
lines changed

ui/src/api/application/application.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { get, post, postStream, del, put, request, download, exportFile } from '
33
import type { pageRequest } from '@/api/type/common'
44
import type { ApplicationFormType } from '@/api/type/application'
55
import { type Ref } from 'vue'
6-
import type { FormField } from '@/components/dynamics-form/type'
76

87
const prefix = '/workspace/' + localStorage.getItem('workspace_id') + '/application'
98

ui/src/api/application/chat-log.ts

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
import { Result } from '@/request/Result'
2+
import {
3+
get,
4+
post,
5+
exportExcelPost,
6+
postStream,
7+
del,
8+
put,
9+
request,
10+
download,
11+
exportFile,
12+
} from '@/request/index'
13+
import type { pageRequest } from '@/api/type/common'
14+
import type { ApplicationFormType } from '@/api/type/application'
15+
import { type Ref } from 'vue'
16+
17+
const prefix = '/workspace/' + localStorage.getItem('workspace_id') + '/application'
18+
/**
19+
* 对话记录提交至知识库
20+
* @param data
21+
* @param loading
22+
* @param application_id
23+
* @param knowledge_id
24+
*/
25+
26+
const postChatLogAddKnowledge: (
27+
application_id: string,
28+
data: any,
29+
loading?: Ref<boolean>,
30+
) => Promise<Result<any>> = (application_id, data, loading) => {
31+
return post(`${prefix}/${application_id}/add_knowledge`, data, undefined, loading)
32+
}
33+
34+
/**
35+
* 对话日志
36+
* @param 参数
37+
* application_id
38+
* param {
39+
"start_time": "string",
40+
"end_time": "string",
41+
}
42+
*/
43+
const getChatLog: (
44+
application_id: String,
45+
page: pageRequest,
46+
param: any,
47+
loading?: Ref<boolean>,
48+
) => Promise<Result<any>> = (application_id, page, param, loading) => {
49+
return get(
50+
`${prefix}/${application_id}/chat/${page.current_page}/${page.page_size}`,
51+
param,
52+
loading,
53+
)
54+
}
55+
56+
/**
57+
* 获得对话日志记录
58+
* @param 参数
59+
* application_id, chart_id,order_asc
60+
*/
61+
const getChatRecordLog: (
62+
application_id: String,
63+
chart_id: String,
64+
page: pageRequest,
65+
loading?: Ref<boolean>,
66+
order_asc?: boolean,
67+
) => Promise<Result<any>> = (application_id, chart_id, page, loading, order_asc) => {
68+
return get(
69+
`${prefix}/${application_id}/chat/${chart_id}/chat_record/${page.current_page}/${page.page_size}`,
70+
{ order_asc: order_asc !== undefined ? order_asc : true },
71+
loading,
72+
)
73+
}
74+
75+
/**
76+
* 获取标注段落列表信息
77+
* @param 参数
78+
* application_id, chart_id, chart_record_id, knowledge_id, document_id
79+
*/
80+
const getMarkChatRecord: (
81+
application_id: String,
82+
chart_id: String,
83+
chart_record_id: String,
84+
knowledge_id: String,
85+
document_id: String,
86+
loading?: Ref<boolean>,
87+
) => Promise<Result<any>> = (
88+
application_id,
89+
chart_id,
90+
chart_record_id,
91+
knowledge_id,
92+
document_id,
93+
loading,
94+
) => {
95+
return get(
96+
`${prefix}/${application_id}/chat/${chart_id}/chat_record/${chart_record_id}/knowledge/${knowledge_id}/document/${document_id}/improve`,
97+
undefined,
98+
loading,
99+
)
100+
}
101+
102+
/**
103+
* 修改日志记录内容
104+
* @param 参数
105+
* application_id, chart_id, chart_record_id, knowledge_id, document_id
106+
* data {
107+
"title": "string",
108+
"content": "string",
109+
"problem_text": "string"
110+
}
111+
*/
112+
const putChatRecordLog: (
113+
application_id: String,
114+
chart_id: String,
115+
chart_record_id: String,
116+
knowledge_id: String,
117+
document_id: String,
118+
data: any,
119+
loading?: Ref<boolean>,
120+
) => Promise<Result<any>> = (
121+
application_id,
122+
chart_id,
123+
chart_record_id,
124+
knowledge_id,
125+
document_id,
126+
data,
127+
loading,
128+
) => {
129+
return put(
130+
`${prefix}/${application_id}/chat/${chart_id}/chat_record/${chart_record_id}/dataset/${knowledge_id}/document/${document_id}/improve`,
131+
data,
132+
undefined,
133+
loading,
134+
)
135+
}
136+
137+
/**
138+
* 删除标注
139+
* @param 参数
140+
* application_id, chart_id, chart_record_id, dataset_id, document_id,paragraph_id
141+
*/
142+
const delMarkChatRecord: (
143+
application_id: String,
144+
chart_id: String,
145+
chart_record_id: String,
146+
knowledge_id: String,
147+
document_id: String,
148+
paragraph_id: String,
149+
loading?: Ref<boolean>,
150+
) => Promise<Result<any>> = (
151+
application_id,
152+
chart_id,
153+
chart_record_id,
154+
knowledge_id,
155+
document_id,
156+
paragraph_id,
157+
loading,
158+
) => {
159+
return del(
160+
`${prefix}/${application_id}/chat/${chart_id}/chat_record/${chart_record_id}/knowledge/${knowledge_id}/document/${document_id}/paragraph/${paragraph_id}/improve`,
161+
undefined,
162+
{},
163+
loading,
164+
)
165+
}
166+
167+
/**
168+
* 导出对话日志
169+
* @param 参数
170+
* application_id
171+
* param {
172+
"start_time": "string",
173+
"end_time": "string",
174+
}
175+
*/
176+
const postExportChatLog: (
177+
application_id: string,
178+
application_name: string,
179+
param: any,
180+
data: any,
181+
loading?: Ref<boolean>,
182+
) => void = (application_id, application_name, param, data, loading) => {
183+
exportExcelPost(
184+
application_name + '.xlsx',
185+
`${prefix}/${application_id}/chat/export`,
186+
param,
187+
data,
188+
loading,
189+
)
190+
}
191+
192+
export default {
193+
postChatLogAddKnowledge,
194+
getChatLog,
195+
getChatRecordLog,
196+
getMarkChatRecord,
197+
putChatRecordLog,
198+
delMarkChatRecord,
199+
postExportChatLog,
200+
}

ui/src/locales/lang/en-US/views/log.ts renamed to ui/src/locales/lang/en-US/views/chat-log.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ export default {
2222
mark: 'Marks',
2323
recenTimes: 'Last Chat Time'
2424
},
25-
addToDataset: 'Add to Knowledge',
25+
addToKnowledge: 'Add to Knowledge',
2626
daysText: 'Days ago',
27-
selectDataset: 'Select Knowledge',
28-
selectDatasetPlaceholder: 'Please select a knowledge',
27+
selectKnowledge: 'Select Knowledge',
28+
selectKnowledgePlaceholder: 'Please select a knowledge',
2929
saveToDocument: 'Save to Document',
3030
documentPlaceholder: 'Please select a document',
3131
editContent: 'Edit Content',

ui/src/locales/lang/en-US/views/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import model from './model'
1212
import document from './document'
1313
import paragraph from './paragraph'
1414
import problem from './problem'
15-
import log from './log'
15+
import chatLog from './chat-log'
1616
import applicationWorkflow from './application-workflow'
1717
import login from './login'
1818
import operateLog from './operate-log'
@@ -31,7 +31,7 @@ export default {
3131
document,
3232
paragraph,
3333
problem,
34-
log,
34+
chatLog,
3535
login,
3636
operateLog,
3737
role

ui/src/locales/lang/zh-CN/views/log.ts renamed to ui/src/locales/lang/zh-CN/views/chat-log.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ export default {
2222
mark: '改进标注',
2323
recenTimes: '最近对话时间'
2424
},
25-
addToDataset: '添加至知识库',
25+
addToKnowledge: '添加至知识库',
2626
daysText: '天之前的对话记录',
27-
selectDataset: '选择知识库',
28-
selectDatasetPlaceholder: '请选择知识库',
27+
selectKnowledge: '选择知识库',
28+
selectKnowledgePlaceholder: '请选择知识库',
2929
saveToDocument: '保存至文档',
3030
documentPlaceholder: '请选择文档',
3131
editContent: '修改内容',

ui/src/locales/lang/zh-CN/views/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import problem from './problem'
1212
import applicationOverview from './application-overview'
1313
import applicationWorkflow from './application-workflow'
1414
import paragraph from './paragraph'
15-
import log from './log'
15+
import chatLog from './chat-log'
1616
// import notFound from './404'
1717

1818
// import operateLog from './operate-log'
@@ -31,7 +31,7 @@ export default {
3131
applicationOverview,
3232
applicationWorkflow,
3333
paragraph,
34-
log,
34+
chatLog,
3535
// notFound,
3636

3737
// operateLog

ui/src/locales/lang/zh-Hant/views/log.ts renamed to ui/src/locales/lang/zh-Hant/views/chat-log.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ export default {
2222
mark: '改進標註',
2323
recenTimes: '最近對話時間'
2424
},
25-
addToDataset: '添加至知識庫',
25+
addToKnowledge: '添加至知識庫',
2626
daysText: '天之前的對話記錄',
27-
selectDataset: '選擇知識庫',
28-
selectDatasetPlaceholder: '請選擇知識庫',
27+
selectKnowledge: '選擇知識庫',
28+
selectKnowledgePlaceholder: '請選擇知識庫',
2929
saveToDocument: '保存至文件',
3030
documentPlaceholder: '請選擇文件',
3131
editContent: '修改內容',

ui/src/locales/lang/zh-Hant/views/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import model from './model'
1212
import document from './document'
1313
import paragraph from './paragraph'
1414
import problem from './problem'
15-
import log from './log'
15+
import chatLog from './chat-log'
1616
import applicationWorkflow from './application-workflow'
1717
import login from './login'
1818
import operateLog from './operate-log'
@@ -31,7 +31,7 @@ export default {
3131
document,
3232
paragraph,
3333
problem,
34-
log,
34+
chatLog,
3535
login,
3636
operateLog,
3737
role

ui/src/router/modules/application-detail.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,19 @@ const ApplicationDetailRouter = {
5757
},
5858
component: () => import('@/views/hit-test/index.vue'),
5959
},
60-
// {
61-
// path: 'log',
62-
// name: 'Log',
63-
// meta: {
64-
// icon: 'app-document',
65-
// iconActive: 'app-document-active',
66-
// title: 'views.log.title',
67-
// active: 'log',
68-
// parentPath: '/application/:id/:type',
69-
// parentName: 'ApplicationDetail'
70-
// },
71-
// component: () => import('@/views/log/index.vue')
72-
// }
60+
{
61+
path: 'chat-log',
62+
name: 'ChatLog',
63+
meta: {
64+
icon: 'app-document',
65+
iconActive: 'app-document-active',
66+
title: 'views.chatLog.title',
67+
active: 'log',
68+
parentPath: '/application/:id/:type',
69+
parentName: 'ApplicationDetail'
70+
},
71+
component: () => import('@/views/chat-log/index.vue')
72+
}
7373
],
7474
}
7575

ui/src/stores/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import useProblemStore from './modules/problem'
1010
import useParagraphStore from './modules/paragraph'
1111
import useDocumentStore from './modules/document'
1212
import useApplicationStore from './modules/application'
13-
13+
import useChatLogStore from './modules/chat-log'
1414
const useStore = () => ({
1515
common: useCommonStore(),
1616
login: useLoginStore(),
@@ -24,6 +24,7 @@ const useStore = () => ({
2424
paragraph: useParagraphStore(),
2525
document: useDocumentStore(),
2626
application: useApplicationStore(),
27+
chatLog: useChatLogStore(),
2728
})
2829

2930
export default useStore

0 commit comments

Comments
 (0)