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.

fix: yuque book id should be string (#9819)

crazywoola5b7b7650909f
diff --git a/api/core/tools/provider/builtin/aliyuque/tools/base.py b/api/core/tools/provider/builtin/aliyuque/tools/base.py
index fb7e219bffe..edfb9fea8ec 100644
--- a/api/core/tools/provider/builtin/aliyuque/tools/base.py
+++ b/api/core/tools/provider/builtin/aliyuque/tools/base.py
@@ -1,10 +1,3 @@
-"""
-语雀客户端
-"""
-
-__author__ = "佐井"
-__created__ = "2024-06-01 09:45:20"
-
from typing import Any
import requests
@@ -29,14 +22,13 @@ class AliYuqueTool:
session = requests.Session()
session.headers.update({"accept": "application/json", "X-Auth-Token": token})
new_params = {**tool_parameters}
- # 找出需要替换的变量
+
replacements = {k: v for k, v in new_params.items() if f"{{{k}}}" in path}
- # 替换 path 中的变量
for key, value in replacements.items():
path = path.replace(f"{{{key}}}", str(value))
- del new_params[key] # 从 kwargs 中删除已经替换的变量
- # 请求接口
+ del new_params[key]
+
if method.upper() in {"POST", "PUT"}:
session.headers.update(
{
diff --git a/api/core/tools/provider/builtin/aliyuque/tools/create_document.py b/api/core/tools/provider/builtin/aliyuque/tools/create_document.py
index feadc292584..01080fd1d57 100644
--- a/api/core/tools/provider/builtin/aliyuque/tools/create_document.py
+++ b/api/core/tools/provider/builtin/aliyuque/tools/create_document.py
@@ -1,10 +1,3 @@
-"""
-创建文档
-"""
-
-__author__ = "佐井"
-__created__ = "2024-06-01 10:45:20"
-
from typing import Any, Union
from core.tools.entities.tool_entities import ToolInvokeMessage
diff --git a/api/core/tools/provider/builtin/aliyuque/tools/create_document.yaml b/api/core/tools/provider/builtin/aliyuque/tools/create_document.yaml
index b9d1c60327f..6ac8ae6696f 100644
--- a/api/core/tools/provider/builtin/aliyuque/tools/create_document.yaml
+++ b/api/core/tools/provider/builtin/aliyuque/tools/create_document.yaml
@@ -13,7 +13,7 @@ description:
parameters:
- name: book_id
- type: number
+ type: string
required: true
form: llm
label:
diff --git a/api/core/tools/provider/builtin/aliyuque/tools/delete_document.py b/api/core/tools/provider/builtin/aliyuque/tools/delete_document.py
index 74c731a944c..84237cec30c 100644
--- a/api/core/tools/provider/builtin/aliyuque/tools/delete_document.py
+++ b/api/core/tools/provider/builtin/aliyuque/tools/delete_document.py
@@ -1,11 +1,3 @@
-#!/usr/bin/env python3
-"""
-删除文档
-"""
-
-__author__ = "佐井"
-__created__ = "2024-09-17 22:04"
-
from typing import Any, Union
from core.tools.entities.tool_entities import ToolInvokeMessage
diff --git a/api/core/tools/provider/builtin/aliyuque/tools/delete_document.yaml b/api/core/tools/provider/builtin/aliyuque/tools/delete_document.yaml
index 87372c53502..dddd62d3048 100644
--- a/api/core/tools/provider/builtin/aliyuque/tools/delete_document.yaml
+++ b/api/core/tools/provider/builtin/aliyuque/tools/delete_document.yaml
@@ -13,7 +13,7 @@ description:
parameters:
- name: book_id
- type: number
+ type: string
required: true
form: llm
label:
diff --git a/api/core/tools/provider/builtin/aliyuque/tools/describe_book_index_page.py b/api/core/tools/provider/builtin/aliyuque/tools/describe_book_index_page.py
index 02bf603a24b..c23d30059a8 100644
--- a/api/core/tools/provider/builtin/aliyuque/tools/describe_book_index_page.py
+++ b/api/core/tools/provider/builtin/aliyuque/tools/describe_book_index_page.py
@@ -1,10 +1,3 @@
-"""
-获取知识库首页
-"""
-
-__author__ = "佐井"
-__created__ = "2024-06-01 22:57:14"
-
from typing import Any, Union
from core.tools.entities.tool_entities import ToolInvokeMessage
diff --git a/api/core/tools/provider/builtin/aliyuque/tools/describe_book_table_of_contents.py b/api/core/tools/provider/builtin/aliyuque/tools/describe_book_table_of_contents.py
index fcfe449c6df..36f8c10d6fd 100644
--- a/api/core/tools/provider/builtin/aliyuque/tools/describe_book_table_of_contents.py
+++ b/api/core/tools/provider/builtin/aliyuque/tools/describe_book_table_of_contents.py
@@ -1,11 +1,3 @@
-#!/usr/bin/env python3
-"""
-获取知识库目录
-"""
-
-__author__ = "佐井"
-__created__ = "2024-09-17 15:17:11"
-
from typing import Any, Union
from core.tools.entities.tool_entities import ToolInvokeMessage
diff --git a/api/core/tools/provider/builtin/aliyuque/tools/describe_book_table_of_contents.yaml b/api/core/tools/provider/builtin/aliyuque/tools/describe_book_table_of_contents.yaml
index 0c2bd221323..0a481b59ebe 100644
--- a/api/core/tools/provider/builtin/aliyuque/tools/describe_book_table_of_contents.yaml
+++ b/api/core/tools/provider/builtin/aliyuque/tools/describe_book_table_of_contents.yaml
@@ -13,7 +13,7 @@ description:
parameters:
- name: book_id
- type: number
+ type: string
required: true
form: llm
label:
diff --git a/api/core/tools/provider/builtin/aliyuque/tools/describe_document_content.py b/api/core/tools/provider/builtin/aliyuque/tools/describe_document_content.py
index 1e70593879e..a69bf121f7e 100644
--- a/api/core/tools/provider/builtin/aliyuque/tools/describe_document_content.py
+++ b/api/core/tools/provider/builtin/aliyuque/tools/describe_document_content.py
@@ -1,10 +1,3 @@
-"""
-获取文档
-"""
-
-__author__ = "佐井"
-__created__ = "2024-06-02 07:11:45"
-
import json
from typing import Any, Union
from urllib.parse import urlparse
@@ -37,7 +30,6 @@ class AliYuqueDescribeDocumentContentTool(AliYuqueTool, BuiltinTool):
book_slug = path_parts[-2]
group_id = path_parts[-3]
- # 1. 请求首页信息,获取book_id
new_params["group_login"] = group_id
new_params["book_slug"] = book_slug
index_page = json.loads(
@@ -46,7 +38,7 @@ class AliYuqueDescribeDocumentContentTool(AliYuqueTool, BuiltinTool):
book_id = index_page.get("data", {}).get("book", {}).get("id")
if not book_id:
raise Exception(f"can not parse book_id from {index_page}")
- # 2. 获取文档内容
+
new_params["book_id"] = book_id
new_params["id"] = doc_id
data = self.request("GET", token, new_params, "/api/v2/repos/{book_id}/docs/{id}")
diff --git a/api/core/tools/provider/builtin/aliyuque/tools/describe_documents.py b/api/core/tools/provider/builtin/aliyuque/tools/describe_documents.py
index ed1b2a86431..7a45684bed0 100644
--- a/api/core/tools/provider/builtin/aliyuque/tools/describe_documents.py
+++ b/api/core/tools/provider/builtin/aliyuque/tools/describe_documents.py
@@ -1,10 +1,3 @@
-"""
-获取文档
-"""
-
-__author__ = "佐井"
-__created__ = "2024-06-01 10:45:20"
-
from typing import Any, Union
from core.tools.entities.tool_entities import ToolInvokeMessage
diff --git a/api/core/tools/provider/builtin/aliyuque/tools/describe_documents.yaml b/api/core/tools/provider/builtin/aliyuque/tools/describe_documents.yaml
index 5156345d719..0b14c1afba6 100644
--- a/api/core/tools/provider/builtin/aliyuque/tools/describe_documents.yaml
+++ b/api/core/tools/provider/builtin/aliyuque/tools/describe_documents.yaml
@@ -14,7 +14,7 @@ description:
parameters:
- name: book_id
- type: number
+ type: string
required: true
form: llm
label:
diff --git a/api/core/tools/provider/builtin/aliyuque/tools/update_book_table_of_contents.py b/api/core/tools/provider/builtin/aliyuque/tools/update_book_table_of_contents.py
index 932559445ee..ca0a3909f80 100644
--- a/api/core/tools/provider/builtin/aliyuque/tools/update_book_table_of_contents.py
+++ b/api/core/tools/provider/builtin/aliyuque/tools/update_book_table_of_contents.py
@@ -1,11 +1,3 @@
-#!/usr/bin/env python3
-"""
-获取知识库目录
-"""
-
-__author__ = "佐井"
-__created__ = "2024-09-17 15:17:11"
-
from typing import Any, Union
from core.tools.entities.tool_entities import ToolInvokeMessage
diff --git a/api/core/tools/provider/builtin/aliyuque/tools/update_book_table_of_contents.yaml b/api/core/tools/provider/builtin/aliyuque/tools/update_book_table_of_contents.yaml
index f0c0024f17f..f85970348b1 100644
--- a/api/core/tools/provider/builtin/aliyuque/tools/update_book_table_of_contents.yaml
+++ b/api/core/tools/provider/builtin/aliyuque/tools/update_book_table_of_contents.yaml
@@ -13,7 +13,7 @@ description:
parameters:
- name: book_id
- type: number
+ type: string
required: true
form: llm
label:
diff --git a/api/core/tools/provider/builtin/aliyuque/tools/update_document.py b/api/core/tools/provider/builtin/aliyuque/tools/update_document.py
index 0c6e0205e1b..d7eba46ad96 100644
--- a/api/core/tools/provider/builtin/aliyuque/tools/update_document.py
+++ b/api/core/tools/provider/builtin/aliyuque/tools/update_document.py
@@ -1,10 +1,3 @@
-"""
-更新文档
-"""
-
-__author__ = "佐井"
-__created__ = "2024-06-19 16:50:07"
-
from typing import Any, Union
from core.tools.entities.tool_entities import ToolInvokeMessage
diff --git a/api/core/tools/provider/builtin/aliyuque/tools/update_document.yaml b/api/core/tools/provider/builtin/aliyuque/tools/update_document.yaml
index 87f88c9b1b0..c2da6b179ac 100644
--- a/api/core/tools/provider/builtin/aliyuque/tools/update_document.yaml
+++ b/api/core/tools/provider/builtin/aliyuque/tools/update_document.yaml
@@ -12,7 +12,7 @@ description:
llm: Update doc in a knowledge base via ID/path.
parameters:
- name: book_id
- type: number
+ type: string
required: true
form: llm
label: