Skip to content

Commit 262ffec

Browse files
authored
Merge branch 'v2' into pr@v2@feat_knowledge_workflow_version
2 parents 7c16456 + e3c36b3 commit 262ffec

File tree

11 files changed

+158
-16
lines changed

11 files changed

+158
-16
lines changed

apps/common/utils/tool_code.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ def exec_code(self, code_str, keywords, function_name=None):
105105
subprocess_result = self._exec_sandbox(_exec_code)
106106
else:
107107
subprocess_result = self._exec(_exec_code)
108-
if subprocess_result.returncode == 1:
109-
raise Exception(subprocess_result.stderr)
108+
if subprocess_result.returncode != 0:
109+
raise Exception(subprocess_result.stderr or subprocess_result.stdout or "Unknown exception occurred")
110110
lines = subprocess_result.stdout.splitlines()
111111
result_line = [line for line in lines if line.startswith(_id)]
112112
if not result_line:

apps/knowledge/serializers/document.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,11 @@ def replace(self):
15691569
# 读取新文件内容
15701570
file_content = file.read()
15711571

1572+
QuerySet(File).filter(
1573+
sha256_hash=original_hash,
1574+
source_id__in=[self.data.get('knowledge_id'), self.data.get('document_id')]
1575+
).update(file_name=file.name)
1576+
15721577
# 查找所有具有相同sha256_hash的文件
15731578
files_to_update = QuerySet(File).filter(
15741579
sha256_hash=original_hash,

ui/src/api/system-resource-management/knowledge.ts

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Result } from '@/request/Result'
22
import { get, post, del, put, exportFile, exportExcel } from '@/request/index'
33
import { type Ref } from 'vue'
4-
import type { pageRequest } from '@/api/type/common'
4+
import type { Dict, pageRequest } from '@/api/type/common'
55

66
const prefix = '/system/resource/knowledge'
77

@@ -254,6 +254,62 @@ const delMulTag: (knowledge_id: string, tags: any, loading?: Ref<boolean>) => Pr
254254
) => {
255255
return put(`${prefix}/${knowledge_id}/tags/batch_delete`, tags, null, loading)
256256
}
257+
const getKnowledgeWorkflowFormList: (
258+
knowledge_id: string,
259+
type: 'loacl' | 'tool',
260+
id: string,
261+
node: any,
262+
loading?: Ref<boolean>,
263+
) => Promise<Result<any>> = (
264+
knowledge_id: string,
265+
type: 'loacl' | 'tool',
266+
id: string,
267+
node,
268+
loading,
269+
) => {
270+
return post(
271+
`${prefix}/${knowledge_id}/datasource/${type}/${id}/form_list`,
272+
{ node },
273+
{},
274+
loading,
275+
)
276+
}
277+
const getKnowledgeWorkflowDatasourceDetails: (
278+
knowledge_id: string,
279+
type: 'loacl' | 'tool',
280+
id: string,
281+
params: any,
282+
function_name: string,
283+
loading?: Ref<boolean>,
284+
) => Promise<Result<any>> = (
285+
knowledge_id: string,
286+
type: 'loacl' | 'tool',
287+
id: string,
288+
params,
289+
function_name,
290+
loading,
291+
) => {
292+
return post(
293+
`${prefix}/${knowledge_id}/datasource/${type}/${id}/${function_name}`,
294+
params,
295+
{},
296+
loading,
297+
)
298+
}
299+
const workflowAction: (
300+
knowledge_id: string,
301+
instance: Dict<any>,
302+
loading?: Ref<boolean>,
303+
) => Promise<Result<any>> = (knowledge_id: string, instance, loading) => {
304+
return post(`${prefix}/${knowledge_id}/action`, instance, {}, loading)
305+
}
306+
const getWorkflowAction: (
307+
knowledge_id: string,
308+
knowledge_action_id: string,
309+
loading?: Ref<boolean>,
310+
) => Promise<Result<any>> = (knowledge_id: string, knowledge_action_id, loading) => {
311+
return get(`${prefix}/${knowledge_id}/action/${knowledge_action_id}`, {}, loading)
312+
}
257313

258314

259315
export default {
@@ -275,7 +331,11 @@ export default {
275331
postTags,
276332
putTag,
277333
delTag,
278-
delMulTag
334+
delMulTag,
335+
getKnowledgeWorkflowFormList,
336+
getKnowledgeWorkflowDatasourceDetails,
337+
workflowAction,
338+
getWorkflowAction,
279339
} as {
280340
[key: string]: any
281341
}

ui/src/api/system-shared/knowledge.ts

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Result } from '@/request/Result'
22
import { get, post, del, put, exportFile, exportExcel } from '@/request/index'
33
import { type Ref } from 'vue'
4-
import type { pageRequest } from '@/api/type/common'
4+
import type { Dict, pageRequest } from '@/api/type/common'
55
import type { knowledgeData } from '@/api/type/knowledge'
66

77
const prefix = '/system/shared/knowledge'
@@ -310,6 +310,62 @@ const delMulTag: (knowledge_id: string, tags: any, loading?: Ref<boolean>) => Pr
310310
) => {
311311
return put(`${prefix}/${knowledge_id}/tags/batch_delete`, tags, null, loading)
312312
}
313+
const getKnowledgeWorkflowFormList: (
314+
knowledge_id: string,
315+
type: 'loacl' | 'tool',
316+
id: string,
317+
node: any,
318+
loading?: Ref<boolean>,
319+
) => Promise<Result<any>> = (
320+
knowledge_id: string,
321+
type: 'loacl' | 'tool',
322+
id: string,
323+
node,
324+
loading,
325+
) => {
326+
return post(
327+
`${prefix}/${knowledge_id}/datasource/${type}/${id}/form_list`,
328+
{ node },
329+
{},
330+
loading,
331+
)
332+
}
333+
const getKnowledgeWorkflowDatasourceDetails: (
334+
knowledge_id: string,
335+
type: 'loacl' | 'tool',
336+
id: string,
337+
params: any,
338+
function_name: string,
339+
loading?: Ref<boolean>,
340+
) => Promise<Result<any>> = (
341+
knowledge_id: string,
342+
type: 'loacl' | 'tool',
343+
id: string,
344+
params,
345+
function_name,
346+
loading,
347+
) => {
348+
return post(
349+
`${prefix}/${knowledge_id}/datasource/${type}/${id}/${function_name}`,
350+
params,
351+
{},
352+
loading,
353+
)
354+
}
355+
const workflowAction: (
356+
knowledge_id: string,
357+
instance: Dict<any>,
358+
loading?: Ref<boolean>,
359+
) => Promise<Result<any>> = (knowledge_id: string, instance, loading) => {
360+
return post(`${prefix}/${knowledge_id}/action`, instance, {}, loading)
361+
}
362+
const getWorkflowAction: (
363+
knowledge_id: string,
364+
knowledge_action_id: string,
365+
loading?: Ref<boolean>,
366+
) => Promise<Result<any>> = (knowledge_id: string, knowledge_action_id, loading) => {
367+
return get(`${prefix}/${knowledge_id}/action/${knowledge_action_id}`, {}, loading)
368+
}
313369

314370
export default {
315371
getKnowledgeList,
@@ -334,7 +390,11 @@ export default {
334390
postTags,
335391
putTag,
336392
delTag,
337-
delMulTag
393+
delMulTag,
394+
getWorkflowAction,
395+
getKnowledgeWorkflowFormList,
396+
getKnowledgeWorkflowDatasourceDetails,
397+
workflowAction,
338398
} as {
339399
[key: string]: any
340400
}

ui/src/components/app-table/index.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,8 @@ const appTableRef = ref()
9494
const loading = ref(false)
9595
const showInput = ref(false)
9696
const inputValue = ref('')
97-
const tableHeight = ref(300)
98-
99-
watch(showInput, (bool) => {
97+
const tableHeight = ref(null)
98+
watch(showInput, (bool: boolean) => {
10099
if (!bool) {
101100
inputValue.value = ''
102101
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default {
2222
nameMessage: 'Document name cannot be empty!',
2323
importMessage: 'Successful',
2424
migrationSuccess: 'Successful',
25+
replaceSuccess: 'Successful',
2526
fileLimitCountTip1: 'Maximum upload per time',
2627
fileLimitCountTip2: 'files',
2728
fileLimitSizeTip1: 'each file must not exceed',

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default {
2222
nameMessage: '文件名称不能为空!',
2323
importMessage: '导入成功',
2424
migrationSuccess: '迁移成功',
25+
replaceSuccess: '替换成功',
2526
fileLimitCountTip1: '每次最多上传',
2627
fileLimitCountTip2: '个文件',
2728
fileLimitSizeTip1: '每个文件不超过',

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default {
2121
nameMessage: '文件名稱不能为空!',
2222
importMessage: '導入成功',
2323
migrationSuccess: '遷移成功',
24+
replaceSuccess: '替換成功',
2425
fileLimitCountTip1: '每次最多上傳',
2526
fileLimitCountTip2: '個文件',
2627
fileLimitSizeTip1: '每個文件不超過',

ui/src/views/document/index.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,7 @@ function replaceDocument(file: any, row: any) {
11421142
loadSharedApi({ type: 'document', systemType: apiType.value })
11431143
.postReplaceSourceFile(id, row.id, formData, loading)
11441144
.then(() => {
1145+
MsgSuccess(t('views.document.tip.replaceSuccess'))
11451146
getList()
11461147
})
11471148
.catch((e: any) => {})

ui/src/views/knowledge-workflow/component/DebugDrawer.vue

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,26 @@ import Result from '@/views/knowledge-workflow/component/action/Result.vue'
5353
import applicationApi from '@/api/application/application'
5454
import KnowledgeBase from '@/views/knowledge-workflow/component/action/KnowledgeBase.vue'
5555
import { WorkflowType } from '@/enums/application'
56-
import KnowledgeApi from '@/api/knowledge/knowledge'
56+
import { loadSharedApi } from "@/utils/dynamics-api/shared-api.ts";
57+
import { useRoute } from "vue-router";
5758
provide('upload', (file: any, loading?: Ref<boolean>) => {
5859
return applicationApi.postUploadFile(file, _knowledge_id.value, 'KNOWLEDGE', loading)
5960
})
60-
const ak: any = {
61+
const route = useRoute()
62+
const ak = {
6163
data_source: DataSource,
6264
knowledge_base: KnowledgeBase,
6365
result: Result,
6466
}
67+
const apiType = computed(() => {
68+
if (route.path.includes('shared')) {
69+
return 'systemShare'
70+
} else if (route.path.includes('resource-management')) {
71+
return 'systemManage'
72+
} else {
73+
return 'workspace'
74+
}
75+
})
6576
const loading = ref<boolean>(false)
6677
const action_id = ref<string>()
6778
const ActionRef = ref()
@@ -103,10 +114,11 @@ const up = () => {
103114
const upload = () => {
104115
ActionRef.value.validate().then(() => {
105116
form_data.value[active.value] = ActionRef.value.get_data()
106-
KnowledgeApi.workflowAction(_knowledge_id.value, form_data.value, loading).then((ok) => {
107-
action_id.value = ok.data.id
108-
active.value = 'result'
109-
})
117+
loadSharedApi({ type: 'knowledge', systemType: apiType.value })
118+
.workflowAction(_knowledge_id.value, form_data.value, loading).then((ok: any) => {
119+
action_id.value = ok.data.id
120+
active.value = 'result'
121+
})
110122
})
111123
}
112124
defineExpose({ close, open })

0 commit comments

Comments
 (0)