Skip to content

Commit 553d5b4

Browse files
authored
Merge pull request #154 from wgzesg-bd/feat/builtin-tools
Feat/builtin tools add calculator and link reader as built in tools
2 parents ab9df68 + 00475ce commit 553d5b4

File tree

11 files changed

+65
-6
lines changed

11 files changed

+65
-6
lines changed

arkitect/core/component/asr/asr_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def __init__(
9090
self.user = user
9191
self.model_name = model_name
9292

93-
self.conn: Optional[websockets.WebSocketClientProtocol] = None
93+
self.conn: Optional[websockets.WebSocketClientProtocol] = None # type: ignore
9494
self.session_id: Optional[str] = None
9595
self.inited = False
9696

arkitect/core/component/tool/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@
1313
# limitations under the License.
1414

1515
from .builder import build_mcp_clients_from_config
16+
from .builtin_tools import calculator, link_reader
1617
from .mcp_client import MCPClient
17-
from .tool_pool import ToolPool, build_tool_pool
1818
from .mcp_server import ArkFastMCP
19+
from .tool_pool import ToolPool, build_tool_pool
1920

2021
__all__ = [
2122
"MCPClient",
2223
"ToolPool",
2324
"build_tool_pool",
2425
"build_mcp_clients_from_config",
2526
"ArkFastMCP",
27+
"link_reader",
28+
"calculator",
2629
]
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Copyright 2025 Bytedance Ltd. and/or its affiliates
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from pydantic import BaseModel
16+
17+
from arkitect.core.client.http import default_ark_client
18+
19+
20+
async def link_reader(url_list: list[str]) -> dict:
21+
"""
22+
当你需要获取网页、pdf、抖音视频内容时,使用此工具。可以获取url链接下的标题和内容。
23+
24+
25+
examples: {"url_list":["abc.com", "xyz.com"]}
26+
Args:
27+
url_list (list[str]): 需要解析网页链接,最多3个,以列表返回
28+
"""
29+
client = default_ark_client()
30+
body = {
31+
"action_name": "LinkReader",
32+
"tool_name": "LinkReader",
33+
"parameters": {"url_list": url_list},
34+
}
35+
36+
response = await client.post(path="/tools/execute", body=body, cast_to=BaseModel)
37+
return response
38+
39+
40+
async def calculator(input: str) -> dict:
41+
"""Evaluate a given mathematical expression
42+
43+
Args:
44+
input(str): The mathematical expression in WolframLanguage InputForm
45+
46+
47+
"""
48+
client = default_ark_client()
49+
body = {
50+
"action_name": "Calculator",
51+
"tool_name": "Calculator",
52+
"parameters": {"input": input},
53+
}
54+
55+
response = await client.post(path="/tools/execute", body=body, cast_to=BaseModel)
56+
return response

arkitect/core/component/tool/mcp_server.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from typing import Any, Literal, Sequence
1616

17+
from arkitect.telemetry.trace import setup_tracing, task
1718
from mcp.server.fastmcp import FastMCP
1819
from mcp.types import (
1920
EmbeddedResource,
@@ -24,8 +25,6 @@
2425
Tool as MCPTool,
2526
)
2627

27-
from arkitect.telemetry.trace import setup_tracing, task
28-
2928

3029
class ArkFastMCP(FastMCP):
3130
def __init__(self, *args, **kwargs): # type: ignore

arkitect/core/component/tts/tts_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def __init__(
6161
self.log_id = log_id
6262
self.base_url = base_url
6363

64-
self.conn: Optional[websockets.WebSocketClientProtocol] = None
64+
self.conn: Optional[websockets.WebSocketClientProtocol] = None # type: ignore
6565
self.session_id: Optional[str] = None
6666
self.connection_params: ConnectionParams = connection_params
6767
self.inited = False
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ markers = [
7575
]
7676
asyncio_mode = "auto"
7777

78+
7879
[dependency-groups]
7980
lint = [
8081
"ruff<1.0.0,>=0.1.5",

0 commit comments

Comments
 (0)