mirror of
https://gitee.com/fit2cloud-feizhiyun/MaxKB.git
synced 2025-12-06 11:19:08 +08:00
fix: update file handling functions and improve documentation
This commit is contained in:
@@ -219,7 +219,9 @@ class BaseToolLibNodeNode(IToolLibNode):
|
||||
**all_params, **self.workflow_params.get('data_source'),
|
||||
'download_file_list': download_file_list
|
||||
}
|
||||
result = function_executor.exec_code(tool_lib.code, all_params)
|
||||
result = download_file_list
|
||||
else:
|
||||
result = function_executor.exec_code(tool_lib.code, all_params)
|
||||
return NodeResult({'result': result},
|
||||
(self.workflow_manage.params.get('knowledge_base') or {}) if self.node.properties.get(
|
||||
'kind') == 'data-source' else {}, _write_context=write_context)
|
||||
|
||||
@@ -280,20 +280,16 @@ const showEditor = ref(false)
|
||||
const currentIndex = ref<any>(null)
|
||||
const showEditIcon = ref(false)
|
||||
const codeTemplate = `
|
||||
from typing import Dict, List
|
||||
|
||||
|
||||
def get_form_list(node, **kwargs) -> List[Dict[str, object]]:
|
||||
"""获取文件列表表单配置
|
||||
|
||||
生成一个树形选择器的表单配置,用于展示和选择文件列表。
|
||||
|
||||
def get_form_list(node, **kwargs):
|
||||
"""
|
||||
获取表单配置列表
|
||||
|
||||
Args:
|
||||
node: 节点对象,用于构造API调用URL
|
||||
**kwargs: 其他可选参数
|
||||
|
||||
node: 节点对象
|
||||
**kwargs: 其他关键字参数
|
||||
|
||||
Returns:
|
||||
list: 表单配置列表,包含树形选择器的配置项
|
||||
list: 包含表单字段配置的列表,用于构建文件树选择器
|
||||
"""
|
||||
return [{
|
||||
"field": 'file_list',
|
||||
@@ -308,56 +304,56 @@ def get_form_list(node, **kwargs) -> List[Dict[str, object]]:
|
||||
}]
|
||||
|
||||
|
||||
def get_file_list(app_id=None, app_secret=None, folder_token=None, **kwargs) -> List[Dict[str, str]]:
|
||||
"""获取指定文件夹下的文件列表
|
||||
|
||||
def get_file_list(app_id=None, app_secret=None, folder_token=None, **kwargs):
|
||||
"""
|
||||
获取文件列表
|
||||
|
||||
Args:
|
||||
app_id: 应用ID,用于身份验证
|
||||
app_secret: 应用密钥,用于身份验证
|
||||
folder_token: 文件夹标识符,不传则获取根目录文件
|
||||
**kwargs: 其他可选参数
|
||||
|
||||
app_id (str, optional): 应用ID
|
||||
app_secret (str, optional): 应用密钥
|
||||
folder_token (str, optional): 文件夹token
|
||||
**kwargs: 其他关键字参数,包括current_node当前节点信息
|
||||
|
||||
Returns:
|
||||
list: 文件列表,每个文件对象包含以下字段:
|
||||
- name (str): 文件名称
|
||||
- token (str): 文件唯一标识符
|
||||
- type (str): 文件类型,如 "docx"、"xlsx" 或 "folder"
|
||||
- 其他元数据字段
|
||||
list: 过滤后的文件列表,每个文件包含leaf标识和原始文件信息
|
||||
"""
|
||||
pass
|
||||
|
||||
Example:
|
||||
[
|
||||
{
|
||||
"name": "示例文档.docx",
|
||||
"token": "abc123",
|
||||
"type": "docx"
|
||||
},
|
||||
{
|
||||
"name": "子文件夹",
|
||||
"token": "def456",
|
||||
"type": "folder"
|
||||
}
|
||||
]
|
||||
def get_down_file_list(app_id=None, app_secret=None, **kwargs):
|
||||
"""
|
||||
获取需要下载的文件列表(过滤掉文件夹)
|
||||
|
||||
Args:
|
||||
app_id (str, optional): 应用ID
|
||||
app_secret (str, optional): 应用密钥
|
||||
**kwargs: 其他关键字参数,包括file_list文件列表
|
||||
|
||||
Returns:
|
||||
list: 过滤后的文件列表,不包含文件夹类型
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def get_raw_file(app_id=None, app_secret=None, **kwargs) -> Dict[str, object]:
|
||||
"""下载文件的原始内容
|
||||
|
||||
Args:
|
||||
app_id: 应用ID,用于身份验证
|
||||
app_secret: 应用密钥,用于身份验证
|
||||
**kwargs: 其他可选参数
|
||||
|
||||
Returns:
|
||||
[
|
||||
{
|
||||
"name": "示例文档.docx",
|
||||
"file_bytes": b"文件的二进制内容"
|
||||
}
|
||||
]
|
||||
def download(app_id=None, app_secret=None, **kwargs):
|
||||
"""
|
||||
下载文件
|
||||
|
||||
支持下载文档(docx)、表格(sheet)和普通文件
|
||||
- 对于文档和表格,先创建导出任务,轮询等待导出完成后下载
|
||||
- 对于普通文件,直接下载
|
||||
|
||||
Args:
|
||||
app_id (str, optional): 应用ID
|
||||
app_secret (str, optional): 应用密钥
|
||||
**kwargs: 其他关键字参数,包括download_item下载项信息
|
||||
|
||||
Returns:
|
||||
dict: 包含文件字节数组(base64编码)和文件名的字典
|
||||
{'file_bytes': [base64_chunk1, base64_chunk2, ...], 'name': 'filename.ext'}
|
||||
|
||||
Raises:
|
||||
Exception: 当创建导出任务失败、查询任务失败或导出任务超时时抛出异常
|
||||
"""
|
||||
|
||||
pass
|
||||
`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user