fix: yuque book id should be string (#9819)
This commit is contained in:
parent
90769ac709
commit
5b7b765090
@ -1,10 +1,3 @@
|
|||||||
"""
|
|
||||||
语雀客户端
|
|
||||||
"""
|
|
||||||
|
|
||||||
__author__ = "佐井"
|
|
||||||
__created__ = "2024-06-01 09:45:20"
|
|
||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
@ -29,14 +22,13 @@ class AliYuqueTool:
|
|||||||
session = requests.Session()
|
session = requests.Session()
|
||||||
session.headers.update({"accept": "application/json", "X-Auth-Token": token})
|
session.headers.update({"accept": "application/json", "X-Auth-Token": token})
|
||||||
new_params = {**tool_parameters}
|
new_params = {**tool_parameters}
|
||||||
# 找出需要替换的变量
|
|
||||||
replacements = {k: v for k, v in new_params.items() if f"{{{k}}}" in path}
|
replacements = {k: v for k, v in new_params.items() if f"{{{k}}}" in path}
|
||||||
|
|
||||||
# 替换 path 中的变量
|
|
||||||
for key, value in replacements.items():
|
for key, value in replacements.items():
|
||||||
path = path.replace(f"{{{key}}}", str(value))
|
path = path.replace(f"{{{key}}}", str(value))
|
||||||
del new_params[key] # 从 kwargs 中删除已经替换的变量
|
del new_params[key]
|
||||||
# 请求接口
|
|
||||||
if method.upper() in {"POST", "PUT"}:
|
if method.upper() in {"POST", "PUT"}:
|
||||||
session.headers.update(
|
session.headers.update(
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,10 +1,3 @@
|
|||||||
"""
|
|
||||||
创建文档
|
|
||||||
"""
|
|
||||||
|
|
||||||
__author__ = "佐井"
|
|
||||||
__created__ = "2024-06-01 10:45:20"
|
|
||||||
|
|
||||||
from typing import Any, Union
|
from typing import Any, Union
|
||||||
|
|
||||||
from core.tools.entities.tool_entities import ToolInvokeMessage
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
|||||||
@ -13,7 +13,7 @@ description:
|
|||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
- name: book_id
|
- name: book_id
|
||||||
type: number
|
type: string
|
||||||
required: true
|
required: true
|
||||||
form: llm
|
form: llm
|
||||||
label:
|
label:
|
||||||
|
|||||||
@ -1,11 +1,3 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
"""
|
|
||||||
删除文档
|
|
||||||
"""
|
|
||||||
|
|
||||||
__author__ = "佐井"
|
|
||||||
__created__ = "2024-09-17 22:04"
|
|
||||||
|
|
||||||
from typing import Any, Union
|
from typing import Any, Union
|
||||||
|
|
||||||
from core.tools.entities.tool_entities import ToolInvokeMessage
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
|||||||
@ -13,7 +13,7 @@ description:
|
|||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
- name: book_id
|
- name: book_id
|
||||||
type: number
|
type: string
|
||||||
required: true
|
required: true
|
||||||
form: llm
|
form: llm
|
||||||
label:
|
label:
|
||||||
|
|||||||
@ -1,10 +1,3 @@
|
|||||||
"""
|
|
||||||
获取知识库首页
|
|
||||||
"""
|
|
||||||
|
|
||||||
__author__ = "佐井"
|
|
||||||
__created__ = "2024-06-01 22:57:14"
|
|
||||||
|
|
||||||
from typing import Any, Union
|
from typing import Any, Union
|
||||||
|
|
||||||
from core.tools.entities.tool_entities import ToolInvokeMessage
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
|||||||
@ -1,11 +1,3 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
"""
|
|
||||||
获取知识库目录
|
|
||||||
"""
|
|
||||||
|
|
||||||
__author__ = "佐井"
|
|
||||||
__created__ = "2024-09-17 15:17:11"
|
|
||||||
|
|
||||||
from typing import Any, Union
|
from typing import Any, Union
|
||||||
|
|
||||||
from core.tools.entities.tool_entities import ToolInvokeMessage
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
|||||||
@ -13,7 +13,7 @@ description:
|
|||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
- name: book_id
|
- name: book_id
|
||||||
type: number
|
type: string
|
||||||
required: true
|
required: true
|
||||||
form: llm
|
form: llm
|
||||||
label:
|
label:
|
||||||
|
|||||||
@ -1,10 +1,3 @@
|
|||||||
"""
|
|
||||||
获取文档
|
|
||||||
"""
|
|
||||||
|
|
||||||
__author__ = "佐井"
|
|
||||||
__created__ = "2024-06-02 07:11:45"
|
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from typing import Any, Union
|
from typing import Any, Union
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
@ -37,7 +30,6 @@ class AliYuqueDescribeDocumentContentTool(AliYuqueTool, BuiltinTool):
|
|||||||
book_slug = path_parts[-2]
|
book_slug = path_parts[-2]
|
||||||
group_id = path_parts[-3]
|
group_id = path_parts[-3]
|
||||||
|
|
||||||
# 1. 请求首页信息,获取book_id
|
|
||||||
new_params["group_login"] = group_id
|
new_params["group_login"] = group_id
|
||||||
new_params["book_slug"] = book_slug
|
new_params["book_slug"] = book_slug
|
||||||
index_page = json.loads(
|
index_page = json.loads(
|
||||||
@ -46,7 +38,7 @@ class AliYuqueDescribeDocumentContentTool(AliYuqueTool, BuiltinTool):
|
|||||||
book_id = index_page.get("data", {}).get("book", {}).get("id")
|
book_id = index_page.get("data", {}).get("book", {}).get("id")
|
||||||
if not book_id:
|
if not book_id:
|
||||||
raise Exception(f"can not parse book_id from {index_page}")
|
raise Exception(f"can not parse book_id from {index_page}")
|
||||||
# 2. 获取文档内容
|
|
||||||
new_params["book_id"] = book_id
|
new_params["book_id"] = book_id
|
||||||
new_params["id"] = doc_id
|
new_params["id"] = doc_id
|
||||||
data = self.request("GET", token, new_params, "/api/v2/repos/{book_id}/docs/{id}")
|
data = self.request("GET", token, new_params, "/api/v2/repos/{book_id}/docs/{id}")
|
||||||
|
|||||||
@ -1,10 +1,3 @@
|
|||||||
"""
|
|
||||||
获取文档
|
|
||||||
"""
|
|
||||||
|
|
||||||
__author__ = "佐井"
|
|
||||||
__created__ = "2024-06-01 10:45:20"
|
|
||||||
|
|
||||||
from typing import Any, Union
|
from typing import Any, Union
|
||||||
|
|
||||||
from core.tools.entities.tool_entities import ToolInvokeMessage
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
|||||||
@ -14,7 +14,7 @@ description:
|
|||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
- name: book_id
|
- name: book_id
|
||||||
type: number
|
type: string
|
||||||
required: true
|
required: true
|
||||||
form: llm
|
form: llm
|
||||||
label:
|
label:
|
||||||
|
|||||||
@ -1,11 +1,3 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
"""
|
|
||||||
获取知识库目录
|
|
||||||
"""
|
|
||||||
|
|
||||||
__author__ = "佐井"
|
|
||||||
__created__ = "2024-09-17 15:17:11"
|
|
||||||
|
|
||||||
from typing import Any, Union
|
from typing import Any, Union
|
||||||
|
|
||||||
from core.tools.entities.tool_entities import ToolInvokeMessage
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
|||||||
@ -13,7 +13,7 @@ description:
|
|||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
- name: book_id
|
- name: book_id
|
||||||
type: number
|
type: string
|
||||||
required: true
|
required: true
|
||||||
form: llm
|
form: llm
|
||||||
label:
|
label:
|
||||||
|
|||||||
@ -1,10 +1,3 @@
|
|||||||
"""
|
|
||||||
更新文档
|
|
||||||
"""
|
|
||||||
|
|
||||||
__author__ = "佐井"
|
|
||||||
__created__ = "2024-06-19 16:50:07"
|
|
||||||
|
|
||||||
from typing import Any, Union
|
from typing import Any, Union
|
||||||
|
|
||||||
from core.tools.entities.tool_entities import ToolInvokeMessage
|
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||||
|
|||||||
@ -12,7 +12,7 @@ description:
|
|||||||
llm: Update doc in a knowledge base via ID/path.
|
llm: Update doc in a knowledge base via ID/path.
|
||||||
parameters:
|
parameters:
|
||||||
- name: book_id
|
- name: book_id
|
||||||
type: number
|
type: string
|
||||||
required: true
|
required: true
|
||||||
form: llm
|
form: llm
|
||||||
label:
|
label:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user