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

This commit is contained in:
crazywoola 2024-10-25 11:11:18 +08:00 committed by GitHub
parent 90769ac709
commit 5b7b765090
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 10 additions and 78 deletions

View File

@ -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(
{

View File

@ -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

View File

@ -13,7 +13,7 @@ description:
parameters:
- name: book_id
type: number
type: string
required: true
form: llm
label:

View File

@ -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

View File

@ -13,7 +13,7 @@ description:
parameters:
- name: book_id
type: number
type: string
required: true
form: llm
label:

View File

@ -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

View File

@ -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

View File

@ -13,7 +13,7 @@ description:
parameters:
- name: book_id
type: number
type: string
required: true
form: llm
label:

View File

@ -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}")

View File

@ -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

View File

@ -14,7 +14,7 @@ description:
parameters:
- name: book_id
type: number
type: string
required: true
form: llm
label:

View File

@ -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

View File

@ -13,7 +13,7 @@ description:
parameters:
- name: book_id
type: number
type: string
required: true
form: llm
label:

View File

@ -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

View File

@ -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: