diff --git a/docs/en/plugin/dev/basic-info.md b/docs/en/plugin/dev/basic-info.md index 7e662ae9c..73b996872 100644 --- a/docs/en/plugin/dev/basic-info.md +++ b/docs/en/plugin/dev/basic-info.md @@ -140,6 +140,71 @@ Prompt editor. Displays a prompt editor from the pipeline configuration page, wi ... ``` +### type: text + +Large text input. Rendered as a textarea in the frontend for user input, and passed to the plugin as a string. + +```yaml +- name: prompt + type: text + ... +``` + +### type: file + +File upload. Supports file uploads up to 10MB, passed to the plugin in the format `{"file_key": "xxxxx.xxx", "mimetype": "xxxxx"}`. The plugin can use the `get_config_file` API to retrieve the file content. + +```yaml +- name: config_file + type: file + accept: 'application/json' # Optional, specify accepted file MIME types + ... +``` + +Retrieving the file in the plugin: + +```python +# Get file information from config +file_config = self.get_config()['config_file'] +file_key = file_config['file_key'] +mimetype = file_config['mimetype'] + +# Example output: {'file_input': {'file_key': 'plugin_config_d2234fd802054faf80babe0679a97fa9.json', 'mimetype': 'application/json'}} +print(file_config) + +# Get file content +file_bytes = await self.get_config_file(file_key) +``` + +::: info +Common MIME type and file extension reference: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types) +::: + +### type: array[file] + +Multiple file upload. Similar to the file type, but supports uploading multiple files, passed to the plugin in the format `[{"file_key": "xxxxx.xxx", "mimetype": "xxxxx"}]`. + +```yaml +- name: resource_files + type: array[file] + accept: 'image/*' # Optional, specify accepted file MIME types + ... +``` + +Retrieving files in the plugin: + +```python +# Get file list from config +files_config = self.get_config()['resource_files'] + +for file_config in files_config: + file_key = file_config['file_key'] + mimetype = file_config['mimetype'] + + # Get file content + file_bytes = await self.get_config_file(file_key) +``` + ### type: llm-model-selector LLM model selector. Displays an LLM model selector where you can choose configured LLM models, with the final result represented as the LLM model UUID. diff --git a/docs/zh/plugin/dev/basic-info.md b/docs/zh/plugin/dev/basic-info.md index 7fc6764d7..0e3339083 100644 --- a/docs/zh/plugin/dev/basic-info.md +++ b/docs/zh/plugin/dev/basic-info.md @@ -140,6 +140,71 @@ spec: ... ``` +### type: text + +大段文本。前端渲染为 textarea 以供用户输入,最终以 string 类型传递给插件。 + +```yaml +- name: prompt + type: text + ... +``` + +### type: file + +文件上传。支持最大 10MB 的文件上传,最终以 `{"file_key": "xxxxx.xxx", "mimetype": "xxxxx"}` 格式传递给插件。插件可使用 `get_config_file` API 获取文件内容。 + +```yaml +- name: config_file + type: file + accept: 'application/json' # 可选,指定接受的文件 MIME 类型 + ... +``` + +在插件中获取文件: + +```python +# 从配置中获取文件信息 +file_config = self.get_config()['config_file'] +file_key = file_config['file_key'] +mimetype = file_config['mimetype'] + +# {'file_input': {'file_key': 'plugin_config_d2234fd802054faf80babe0679a97fa9.json', 'mimetype': 'application/json'}} +print(file_config) + +# 获取文件内容 +file_bytes = await self.get_config_file(file_key) +``` + +::: info +常见 mimetype 与文件扩展名对应参考:[mdn 文档](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Guides/MIME_types/Common_types) +::: + +### type: array[file] + +多文件上传。与 file 类型类似,但支持上传多个文件,最终以 `[{"file_key": "xxxxx.xxx", "mimetype": "xxxxx"}]` 格式传递给插件。 + +```yaml +- name: resource_files + type: array[file] + accept: 'image/*' # 可选,指定接受的文件 MIME 类型 + ... +``` + +在插件中获取文件: + +```python +# 从配置中获取文件列表 +files_config = self.get_config()['resource_files'] + +for file_config in files_config: + file_key = file_config['file_key'] + mimetype = file_config['mimetype'] + + # 获取文件内容 + file_bytes = await self.get_config_file(file_key) +``` + ### type: llm-model-selector LLM 模型选择器。会展示一个 LLM 模型选择器,可选择已配置的 LLM 模型,最终结果表示为 LLM 模型 uuid。