Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

Bugfix/fix feishu plugins (#8443)

走在修行的大街上72b7f8a949e5
diff --git a/api/core/tools/provider/builtin/feishu_document/tools/get_document_raw_content.py b/api/core/tools/provider/builtin/feishu_document/tools/get_document_content.py
similarity index 79%
rename from api/core/tools/provider/builtin/feishu_document/tools/get_document_raw_content.py
rename to api/core/tools/provider/builtin/feishu_document/tools/get_document_content.py
index 83073e08223..c94a5f70ed7 100644
--- a/api/core/tools/provider/builtin/feishu_document/tools/get_document_raw_content.py
+++ b/api/core/tools/provider/builtin/feishu_document/tools/get_document_content.py
@@ -12,6 +12,8 @@ class GetDocumentRawContentTool(BuiltinTool):
client = FeishuRequest(app_id, app_secret)
document_id = tool_parameters.get("document_id")
+ mode = tool_parameters.get("mode")
+ lang = tool_parameters.get("lang", 0)
- res = client.get_document_raw_content(document_id)
+ res = client.get_document_content(document_id, mode, lang)
return self.create_json_message(res)
diff --git a/api/core/tools/provider/builtin/feishu_document/tools/get_document_content.yaml b/api/core/tools/provider/builtin/feishu_document/tools/get_document_content.yaml
new file mode 100644
index 00000000000..51eda73a600
--- /dev/null
+++ b/api/core/tools/provider/builtin/feishu_document/tools/get_document_content.yaml
@@ -0,0 +1,49 @@
+identity:
+ name: get_document_content
+ author: Doug Lea
+ label:
+ en_US: Get Document Content
+ zh_Hans: 获取飞书云文档的内容
+description:
+ human:
+ en_US: Get document content
+ zh_Hans: 获取飞书云文档的内容
+ llm: A tool for retrieving content from Feishu cloud documents.
+parameters:
+ - name: document_id
+ type: string
+ required: true
+ label:
+ en_US: document_id
+ zh_Hans: 飞书文档的唯一标识
+ human_description:
+ en_US: Unique identifier for a Feishu document. You can also input the document's URL.
+ zh_Hans: 飞书文档的唯一标识,支持输入文档的 URL。
+ llm_description: 飞书文档的唯一标识,支持输入文档的 URL。
+ form: llm
+
+ - name: mode
+ type: string
+ required: false
+ label:
+ en_US: mode
+ zh_Hans: 文档返回格式
+ human_description:
+ en_US: Format of the document return, optional values are text, markdown, can be empty, default is markdown.
+ zh_Hans: 文档返回格式,可选值有 text、markdown,可以为空,默认值为 markdown。
+ llm_description: 文档返回格式,可选值有 text、markdown,可以为空,默认值为 markdown。
+ form: llm
+
+ - name: lang
+ type: number
+ required: false
+ default: 0
+ label:
+ en_US: lang
+ zh_Hans: 指定@用户的语言
+ human_description:
+ en_US: |
+ Specifies the language for MentionUser, optional values are [0, 1]. 0: User's default name, 1: User's English name, default is 0.
+ zh_Hans: 指定返回的 MentionUser,即 @用户 的语言,可选值有 [0,1]。0:该用户的默认名称,1:该用户的英文名称,默认值为 0。
+ llm_description: 指定返回的 MentionUser,即 @用户 的语言,可选值有 [0,1]。0:该用户的默认名称,1:该用户的英文名称,默认值为 0。
+ form: llm
diff --git a/api/core/tools/provider/builtin/feishu_document/tools/get_document_raw_content.yaml b/api/core/tools/provider/builtin/feishu_document/tools/get_document_raw_content.yaml
deleted file mode 100644
index e5b0937e03d..00000000000
--- a/api/core/tools/provider/builtin/feishu_document/tools/get_document_raw_content.yaml
+++ /dev/null
@@ -1,23 +0,0 @@
-identity:
- name: get_document_raw_content
- author: Doug Lea
- label:
- en_US: Get Document Raw Content
- zh_Hans: 获取文档纯文本内容
-description:
- human:
- en_US: Get document raw content
- zh_Hans: 获取文档纯文本内容
- llm: A tool for getting the plain text content of Feishu documents
-parameters:
- - name: document_id
- type: string
- required: true
- label:
- en_US: document_id
- zh_Hans: 飞书文档的唯一标识
- human_description:
- en_US: Unique ID of Feishu document document_id
- zh_Hans: 飞书文档的唯一标识 document_id
- llm_description: 飞书文档的唯一标识 document_id
- form: llm
diff --git a/api/core/tools/provider/builtin/feishu_document/tools/list_document_block.yaml b/api/core/tools/provider/builtin/feishu_document/tools/list_document_block.yaml
deleted file mode 100644
index d51e5a837cc..00000000000
--- a/api/core/tools/provider/builtin/feishu_document/tools/list_document_block.yaml
+++ /dev/null
@@ -1,48 +0,0 @@
-identity:
- name: list_document_block
- author: Doug Lea
- label:
- en_US: List Document Block
- zh_Hans: 获取飞书文档所有块
-description:
- human:
- en_US: List document block
- zh_Hans: 获取飞书文档所有块的富文本内容并分页返回。
- llm: A tool to get all blocks of Feishu documents
-parameters:
- - name: document_id
- type: string
- required: true
- label:
- en_US: document_id
- zh_Hans: 飞书文档的唯一标识
- human_description:
- en_US: Unique ID of Feishu document document_id
- zh_Hans: 飞书文档的唯一标识 document_id
- llm_description: 飞书文档的唯一标识 document_id
- form: llm
-
- - name: page_size
- type: number
- required: false
- default: 500
- label:
- en_US: page_size
- zh_Hans: 分页大小
- human_description:
- en_US: Paging size, the default and maximum value is 500.
- zh_Hans: 分页大小, 默认值和最大值为 500。
- llm_description: 分页大小, 表示一次请求最多返回多少条数据,默认值和最大值为 500。
- form: llm
-
- - name: page_token
- type: string
- required: false
- label:
- en_US: page_token
- zh_Hans: 分页标记
- human_description:
- en_US: Pagination tag, used to paginate query results so that more items can be obtained in the next traversal.
- zh_Hans: 分页标记,用于分页查询结果,以便下次遍历时获取更多项。
- llm_description: 分页标记,第一次请求不填,表示从头开始遍历;分页查询结果还有更多项时会同时返回新的 page_token,下次遍历可采用该 page_token 获取查询结果。
- form: llm
diff --git a/api/core/tools/provider/builtin/feishu_document/tools/list_document_block.py b/api/core/tools/provider/builtin/feishu_document/tools/list_document_blocks.py
similarity index 90%
rename from api/core/tools/provider/builtin/feishu_document/tools/list_document_block.py
rename to api/core/tools/provider/builtin/feishu_document/tools/list_document_blocks.py
index 8c0c4a3c97a..572a7abf284 100644
--- a/api/core/tools/provider/builtin/feishu_document/tools/list_document_block.py
+++ b/api/core/tools/provider/builtin/feishu_document/tools/list_document_blocks.py
@@ -15,5 +15,5 @@ class ListDocumentBlockTool(BuiltinTool):
page_size = tool_parameters.get("page_size", 500)
page_token = tool_parameters.get("page_token", "")
- res = client.list_document_block(document_id, page_token, page_size)
+ res = client.list_document_blocks(document_id, page_token, page_size)
return self.create_json_message(res)
diff --git a/api/core/tools/provider/builtin/feishu_document/tools/list_document_blocks.yaml b/api/core/tools/provider/builtin/feishu_document/tools/list_document_blocks.yaml
new file mode 100644
index 00000000000..019ac983906
--- /dev/null
+++ b/api/core/tools/provider/builtin/feishu_document/tools/list_document_blocks.yaml
@@ -0,0 +1,74 @@
+identity:
+ name: list_document_blocks
+ author: Doug Lea
+ label:
+ en_US: List Document Blocks
+ zh_Hans: 获取飞书文档所有块
+description:
+ human:
+ en_US: List document blocks
+ zh_Hans: 获取飞书文档所有块的富文本内容并分页返回
+ llm: A tool to get all blocks of Feishu documents
+parameters:
+ - name: document_id
+ type: string
+ required: true
+ label:
+ en_US: document_id
+ zh_Hans: 飞书文档的唯一标识
+ human_description:
+ en_US: Unique identifier for a Feishu document. You can also input the document's URL.
+ zh_Hans: 飞书文档的唯一标识,支持输入文档的 URL。
+ llm_description: 飞书文档的唯一标识,支持输入文档的 URL。
+ form: llm
+
+ - name: user_id_type
+ type: select
+ required: false
+ options:
+ - value: open_id
+ label:
+ en_US: open_id
+ zh_Hans: open_id
+ - value: union_id
+ label:
+ en_US: union_id
+ zh_Hans: union_id
+ - value: user_id
+ label:
+ en_US: user_id
+ zh_Hans: user_id
+ default: "open_id"
+ label:
+ en_US: user_id_type
+ zh_Hans: 用户 ID 类型
+ human_description:
+ en_US: User ID type, optional values are open_id, union_id, user_id, with a default value of open_id.
+ zh_Hans: 用户 ID 类型,可选值有 open_id、union_id、user_id,默认值为 open_id。
+ llm_description: 用户 ID 类型,可选值有 open_id、union_id、user_id,默认值为 open_id。
+ form: llm
+
+ - name: page_size
+ type: number
+ required: false
+ default: "500"
+ label:
+ en_US: page_size
+ zh_Hans: 分页大小
+ human_description:
+ en_US: Paging size, the default and maximum value is 500.
+ zh_Hans: 分页大小, 默认值和最大值为 500。
+ llm_description: 分页大小, 表示一次请求最多返回多少条数据,默认值和最大值为 500。
+ form: llm
+
+ - name: page_token
+ type: string
+ required: false
+ label:
+ en_US: page_token
+ zh_Hans: 分页标记
+ human_description:
+ en_US: Pagination token used to navigate through query results, allowing retrieval of additional items in subsequent requests.
+ zh_Hans: 分页标记,用于分页查询结果,以便下次遍历时获取更多项。
+ llm_description: 分页标记,第一次请求不填,表示从头开始遍历;分页查询结果还有更多项时会同时返回新的 page_token,下次遍历可采用该 page_token 获取查询结果。
+ form: llm
diff --git a/api/core/tools/provider/builtin/feishu_document/tools/write_document.yaml b/api/core/tools/provider/builtin/feishu_document/tools/write_document.yaml
index 8ee219d4a7a..4282e3dcf39 100644
--- a/api/core/tools/provider/builtin/feishu_document/tools/write_document.yaml
+++ b/api/core/tools/provider/builtin/feishu_document/tools/write_document.yaml
@@ -17,33 +17,35 @@ parameters:
en_US: document_id
zh_Hans: 飞书文档的唯一标识
human_description:
- en_US: Unique ID of Feishu document document_id
- zh_Hans: 飞书文档的唯一标识 document_id
- llm_description: 飞书文档的唯一标识 document_id
+ en_US: Unique identifier for a Feishu document. You can also input the document's URL.
+ zh_Hans: 飞书文档的唯一标识,支持输入文档的 URL。
+ llm_description: 飞书文档的唯一标识,支持输入文档的 URL。
form: llm
- name: content
type: string
required: true
label:
- en_US: document content
- zh_Hans: 文档内容
+ en_US: Plain text or Markdown content
+ zh_Hans: 纯文本或 Markdown 内容
human_description:
- en_US: Document content, supports markdown syntax, can be empty.
- zh_Hans: 文档内容,支持 markdown 语法,可以为空。
- llm_description:
+ en_US: Plain text or Markdown content. Note that embedded tables in the document should not have merged cells.
+ zh_Hans: 纯文本或 Markdown 内容。注意文档的内嵌套表格不允许有单元格合并。
+ llm_description: 纯文本或 Markdown 内容,注意文档的内嵌套表格不允许有单元格合并。
form: llm
- name: position
- type: select
- required: true
- default: start
+ type: string
+ required: false
label:
- en_US: Choose where to add content
- zh_Hans: 选择添加内容的位置
+ en_US: position
+ zh_Hans: 添加位置
human_description:
- en_US: Please fill in start or end to add content at the beginning or end of the document respectively.
- zh_Hans: 请填入 start 或 end, 分别表示在文档开头(start)或结尾(end)添加内容。
+ en_US: |
+ Enumeration values: start or end. Use 'start' to add content at the beginning of the document, and 'end' to add content at the end. The default value is 'end'.
+ zh_Hans: 枚举值:start 或 end。使用 'start' 在文档开头添加内容,使用 'end' 在文档结尾添加内容,默认值为 'end'。
+ llm_description: |
+ 枚举值 start、end,start: 在文档开头添加内容;end: 在文档结尾添加内容,默认值为 end。
form: llm
options:
- value: start
@@ -54,3 +56,4 @@ parameters:
label:
en_US: end
zh_Hans: 在文档结尾添加内容
+ default: start
diff --git a/api/core/tools/utils/feishu_api_utils.py b/api/core/tools/utils/feishu_api_utils.py
index 44803d7d653..ffdb06498fd 100644
--- a/api/core/tools/utils/feishu_api_utils.py
+++ b/api/core/tools/utils/feishu_api_utils.py
@@ -76,9 +76,9 @@ class FeishuRequest:
url = "https://lark-plugin-api.solutionsuite.cn/lark-plugin/document/write_document"
payload = {"document_id": document_id, "content": content, "position": position}
res = self._send_request(url, payload=payload)
- return res.get("data")
+ return res
- def get_document_raw_content(self, document_id: str) -> dict:
+ def get_document_content(self, document_id: str, mode: str, lang: int = 0) -> dict:
"""
API url: https://open.larkoffice.com/document/server-docs/docs/docs/docx-v1/document/raw_content
Example Response:
@@ -92,16 +92,18 @@ class FeishuRequest:
""" # noqa: E501
params = {
"document_id": document_id,
+ "mode": mode,
+ "lang": lang,
}
- url = "https://lark-plugin-api.solutionsuite.cn/lark-plugin/document/get_document_raw_content"
+ url = "https://lark-plugin-api.solutionsuite.cn/lark-plugin/document/get_document_content"
res = self._send_request(url, method="get", params=params)
return res.get("data").get("content")
- def list_document_block(self, document_id: str, page_token: str, page_size: int = 500) -> dict:
+ def list_document_blocks(self, document_id: str, page_token: str, page_size: int = 500) -> dict:
"""
API url: https://open.larkoffice.com/document/server-docs/docs/docs/docx-v1/document/list
"""
- url = "https://lark-plugin-api.solutionsuite.cn/lark-plugin/document/list_document_block"
+ url = "https://lark-plugin-api.solutionsuite.cn/lark-plugin/document/list_document_blocks"
params = {
"document_id": document_id,
"page_size": page_size,