@@ -279,11 +279,97 @@ const visible = ref(false)
279279const showEditor = ref (false )
280280const currentIndex = ref <any >(null )
281281const showEditIcon = ref (false )
282+ const codeTemplate = `
283+ from typing import Dict, List
284+
285+
286+ def get_call_url(node, function_name):
287+ return '/workspace/\$ {current_workspace_id}/knowledge/\$ {current_knowledge_id}/datasource/tool/' + node.get(
288+ 'properties').get('node_data').get('tool_lib_id') + f'/{function_name}'
289+
290+
291+ def get_form_list(node, **kwargs) -> List[Dict[str, object]]:
292+ """获取文件列表表单配置
293+
294+ 生成一个树形选择器的表单配置,用于展示和选择文件列表。
295+
296+ Args:
297+ node: 节点对象,用于构造API调用URL
298+ **kwargs: 其他可选参数
299+
300+ Returns:
301+ list: 表单配置列表,包含树形选择器的配置项
302+ """
303+ return [{
304+ "field": 'file_list',
305+ "text_field": 'name',
306+ "value_field": 'token',
307+ "input_type": 'Tree',
308+ "attrs": {
309+ "lazy": True,
310+ "url": get_call_url(node, 'get_file_list'),
311+ },
312+ "label": '',
313+ }]
314+
315+
316+ def get_file_list(app_id=None, app_secret=None, folder_token=None, **kwargs) -> List[Dict[str, str]]:
317+ """获取指定文件夹下的文件列表
318+
319+ Args:
320+ app_id: 应用ID,用于身份验证
321+ app_secret: 应用密钥,用于身份验证
322+ folder_token: 文件夹标识符,不传则获取根目录文件
323+ **kwargs: 其他可选参数
324+
325+ Returns:
326+ list: 文件列表,每个文件对象包含以下字段:
327+ - name (str): 文件名称
328+ - token (str): 文件唯一标识符
329+ - type (str): 文件类型,如 "docx"、"xlsx" 或 "folder"
330+ - 其他元数据字段
331+
332+ Example:
333+ [
334+ {
335+ "name": "示例文档.docx",
336+ "token": "abc123",
337+ "type": "docx"
338+ },
339+ {
340+ "name": "子文件夹",
341+ "token": "def456",
342+ "type": "folder"
343+ }
344+ ]
345+ """
346+ pass
347+
348+
349+ def get_raw_file(app_id=None, app_secret=None, **kwargs) -> Dict[str, object]:
350+ """下载文件的原始内容
351+
352+ Args:
353+ app_id: 应用ID,用于身份验证
354+ app_secret: 应用密钥,用于身份验证
355+ **kwargs: 其他可选参数
356+
357+ Returns:
358+ [
359+ {
360+ "name": "示例文档.docx",
361+ "file_bytes": b"文件的二进制内容"
362+ }
363+ ]
364+ """
365+
366+ pass
367+ `
282368
283369const form = ref <toolData >({
284370 name: ' ' ,
285371 desc: ' ' ,
286- code: ' ' ,
372+ code: codeTemplate ,
287373 icon: ' ' ,
288374 input_field_list: [],
289375 init_field_list: [],
@@ -298,7 +384,7 @@ watch(visible, (bool) => {
298384 form .value = {
299385 name: ' ' ,
300386 desc: ' ' ,
301- code: ' ' ,
387+ code: codeTemplate ,
302388 icon: ' ' ,
303389 input_field_list: [],
304390 init_field_list: [],
0 commit comments