Merge branch 'v2' into pr@v2@feat_knowledge_workflow_version

This commit is contained in:
shaohuzhang1 2025-12-01 15:00:04 +08:00 committed by GitHub
commit 262ffecf70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 158 additions and 16 deletions

View File

@ -105,8 +105,8 @@ except Exception as e:
subprocess_result = self._exec_sandbox(_exec_code)
else:
subprocess_result = self._exec(_exec_code)
if subprocess_result.returncode == 1:
raise Exception(subprocess_result.stderr)
if subprocess_result.returncode != 0:
raise Exception(subprocess_result.stderr or subprocess_result.stdout or "Unknown exception occurred")
lines = subprocess_result.stdout.splitlines()
result_line = [line for line in lines if line.startswith(_id)]
if not result_line:

View File

@ -1569,6 +1569,11 @@ class DocumentSerializers(serializers.Serializer):
# 读取新文件内容
file_content = file.read()
QuerySet(File).filter(
sha256_hash=original_hash,
source_id__in=[self.data.get('knowledge_id'), self.data.get('document_id')]
).update(file_name=file.name)
# 查找所有具有相同sha256_hash的文件
files_to_update = QuerySet(File).filter(
sha256_hash=original_hash,

View File

@ -1,7 +1,7 @@
import { Result } from '@/request/Result'
import { get, post, del, put, exportFile, exportExcel } from '@/request/index'
import { type Ref } from 'vue'
import type { pageRequest } from '@/api/type/common'
import type { Dict, pageRequest } from '@/api/type/common'
const prefix = '/system/resource/knowledge'
@ -254,6 +254,62 @@ const delMulTag: (knowledge_id: string, tags: any, loading?: Ref<boolean>) => Pr
) => {
return put(`${prefix}/${knowledge_id}/tags/batch_delete`, tags, null, loading)
}
const getKnowledgeWorkflowFormList: (
knowledge_id: string,
type: 'loacl' | 'tool',
id: string,
node: any,
loading?: Ref<boolean>,
) => Promise<Result<any>> = (
knowledge_id: string,
type: 'loacl' | 'tool',
id: string,
node,
loading,
) => {
return post(
`${prefix}/${knowledge_id}/datasource/${type}/${id}/form_list`,
{ node },
{},
loading,
)
}
const getKnowledgeWorkflowDatasourceDetails: (
knowledge_id: string,
type: 'loacl' | 'tool',
id: string,
params: any,
function_name: string,
loading?: Ref<boolean>,
) => Promise<Result<any>> = (
knowledge_id: string,
type: 'loacl' | 'tool',
id: string,
params,
function_name,
loading,
) => {
return post(
`${prefix}/${knowledge_id}/datasource/${type}/${id}/${function_name}`,
params,
{},
loading,
)
}
const workflowAction: (
knowledge_id: string,
instance: Dict<any>,
loading?: Ref<boolean>,
) => Promise<Result<any>> = (knowledge_id: string, instance, loading) => {
return post(`${prefix}/${knowledge_id}/action`, instance, {}, loading)
}
const getWorkflowAction: (
knowledge_id: string,
knowledge_action_id: string,
loading?: Ref<boolean>,
) => Promise<Result<any>> = (knowledge_id: string, knowledge_action_id, loading) => {
return get(`${prefix}/${knowledge_id}/action/${knowledge_action_id}`, {}, loading)
}
export default {
@ -275,7 +331,11 @@ export default {
postTags,
putTag,
delTag,
delMulTag
delMulTag,
getKnowledgeWorkflowFormList,
getKnowledgeWorkflowDatasourceDetails,
workflowAction,
getWorkflowAction,
} as {
[key: string]: any
}

View File

@ -1,7 +1,7 @@
import { Result } from '@/request/Result'
import { get, post, del, put, exportFile, exportExcel } from '@/request/index'
import { type Ref } from 'vue'
import type { pageRequest } from '@/api/type/common'
import type { Dict, pageRequest } from '@/api/type/common'
import type { knowledgeData } from '@/api/type/knowledge'
const prefix = '/system/shared/knowledge'
@ -310,6 +310,62 @@ const delMulTag: (knowledge_id: string, tags: any, loading?: Ref<boolean>) => Pr
) => {
return put(`${prefix}/${knowledge_id}/tags/batch_delete`, tags, null, loading)
}
const getKnowledgeWorkflowFormList: (
knowledge_id: string,
type: 'loacl' | 'tool',
id: string,
node: any,
loading?: Ref<boolean>,
) => Promise<Result<any>> = (
knowledge_id: string,
type: 'loacl' | 'tool',
id: string,
node,
loading,
) => {
return post(
`${prefix}/${knowledge_id}/datasource/${type}/${id}/form_list`,
{ node },
{},
loading,
)
}
const getKnowledgeWorkflowDatasourceDetails: (
knowledge_id: string,
type: 'loacl' | 'tool',
id: string,
params: any,
function_name: string,
loading?: Ref<boolean>,
) => Promise<Result<any>> = (
knowledge_id: string,
type: 'loacl' | 'tool',
id: string,
params,
function_name,
loading,
) => {
return post(
`${prefix}/${knowledge_id}/datasource/${type}/${id}/${function_name}`,
params,
{},
loading,
)
}
const workflowAction: (
knowledge_id: string,
instance: Dict<any>,
loading?: Ref<boolean>,
) => Promise<Result<any>> = (knowledge_id: string, instance, loading) => {
return post(`${prefix}/${knowledge_id}/action`, instance, {}, loading)
}
const getWorkflowAction: (
knowledge_id: string,
knowledge_action_id: string,
loading?: Ref<boolean>,
) => Promise<Result<any>> = (knowledge_id: string, knowledge_action_id, loading) => {
return get(`${prefix}/${knowledge_id}/action/${knowledge_action_id}`, {}, loading)
}
export default {
getKnowledgeList,
@ -334,7 +390,11 @@ export default {
postTags,
putTag,
delTag,
delMulTag
delMulTag,
getWorkflowAction,
getKnowledgeWorkflowFormList,
getKnowledgeWorkflowDatasourceDetails,
workflowAction,
} as {
[key: string]: any
}

View File

@ -94,9 +94,8 @@ const appTableRef = ref()
const loading = ref(false)
const showInput = ref(false)
const inputValue = ref('')
const tableHeight = ref(300)
watch(showInput, (bool) => {
const tableHeight = ref(null)
watch(showInput, (bool: boolean) => {
if (!bool) {
inputValue.value = ''
}

View File

@ -22,6 +22,7 @@ export default {
nameMessage: 'Document name cannot be empty!',
importMessage: 'Successful',
migrationSuccess: 'Successful',
replaceSuccess: 'Successful',
fileLimitCountTip1: 'Maximum upload per time',
fileLimitCountTip2: 'files',
fileLimitSizeTip1: 'each file must not exceed',

View File

@ -22,6 +22,7 @@ export default {
nameMessage: '文件名称不能为空!',
importMessage: '导入成功',
migrationSuccess: '迁移成功',
replaceSuccess: '替换成功',
fileLimitCountTip1: '每次最多上传',
fileLimitCountTip2: '个文件',
fileLimitSizeTip1: '每个文件不超过',

View File

@ -21,6 +21,7 @@ export default {
nameMessage: '文件名稱不能为空!',
importMessage: '導入成功',
migrationSuccess: '遷移成功',
replaceSuccess: '替換成功',
fileLimitCountTip1: '每次最多上傳',
fileLimitCountTip2: '個文件',
fileLimitSizeTip1: '每個文件不超過',

View File

@ -1142,6 +1142,7 @@ function replaceDocument(file: any, row: any) {
loadSharedApi({ type: 'document', systemType: apiType.value })
.postReplaceSourceFile(id, row.id, formData, loading)
.then(() => {
MsgSuccess(t('views.document.tip.replaceSuccess'))
getList()
})
.catch((e: any) => {})

View File

@ -53,15 +53,26 @@ import Result from '@/views/knowledge-workflow/component/action/Result.vue'
import applicationApi from '@/api/application/application'
import KnowledgeBase from '@/views/knowledge-workflow/component/action/KnowledgeBase.vue'
import { WorkflowType } from '@/enums/application'
import KnowledgeApi from '@/api/knowledge/knowledge'
import { loadSharedApi } from "@/utils/dynamics-api/shared-api.ts";
import { useRoute } from "vue-router";
provide('upload', (file: any, loading?: Ref<boolean>) => {
return applicationApi.postUploadFile(file, _knowledge_id.value, 'KNOWLEDGE', loading)
})
const ak: any = {
const route = useRoute()
const ak = {
data_source: DataSource,
knowledge_base: KnowledgeBase,
result: Result,
}
const apiType = computed(() => {
if (route.path.includes('shared')) {
return 'systemShare'
} else if (route.path.includes('resource-management')) {
return 'systemManage'
} else {
return 'workspace'
}
})
const loading = ref<boolean>(false)
const action_id = ref<string>()
const ActionRef = ref()
@ -103,10 +114,11 @@ const up = () => {
const upload = () => {
ActionRef.value.validate().then(() => {
form_data.value[active.value] = ActionRef.value.get_data()
KnowledgeApi.workflowAction(_knowledge_id.value, form_data.value, loading).then((ok) => {
action_id.value = ok.data.id
active.value = 'result'
})
loadSharedApi({ type: 'knowledge', systemType: apiType.value })
.workflowAction(_knowledge_id.value, form_data.value, loading).then((ok: any) => {
action_id.value = ok.data.id
active.value = 'result'
})
})
}
defineExpose({ close, open })

View File

@ -56,7 +56,9 @@ const { user } = useStore()
const route = useRoute()
const apiType = computed(() => {
if (route.path.includes('resource-management')) {
if (route.path.includes('shared')) {
return 'systemShare'
} else if (route.path.includes('resource-management')) {
return 'systemManage'
} else {
return 'workspace'