ソースを参照

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

crazywoola 6 ヶ月 前
コミット
5b7b765090

+ 3 - 11
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(
                 {

+ 0 - 7
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

+ 1 - 1
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:

+ 0 - 8
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

+ 1 - 1
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:

+ 0 - 7
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

+ 0 - 8
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

+ 1 - 1
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:

+ 1 - 9
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}")

+ 0 - 7
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

+ 1 - 1
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:

+ 0 - 8
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

+ 1 - 1
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:

+ 0 - 7
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

+ 1 - 1
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: