PyPI release arcade-serve and arcade-tdk (#432)

This commit is contained in:
Eric Gustin 2025-06-13 13:06:11 -07:00 committed by GitHub
parent 86cde2d9bd
commit 8a9845b484
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 49 additions and 47 deletions

View file

@ -21,17 +21,21 @@ pip install arcade-core
## Usage ## Usage
1. Install an arcade toolkit
```bash
pip install arcade-math
```
2. Load the toolkit
```python ```python
from arcade_core import ToolCatalog, Toolkit, ArcadeConfig import arcade_math
from arcade_core import ToolCatalog, Toolkit
# Create a tool catalog # Create a tool catalog
catalog = ToolCatalog() catalog = ToolCatalog()
# Load a toolkit # Load a toolkit
toolkit = Toolkit.from_directory("path/to/toolkit") toolkit = Toolkit.from_module(arcade_math)
# Configure Arcade
config = ArcadeConfig.from_file("config.yaml")
``` ```
## License ## License

View file

@ -20,49 +20,49 @@ pip install arcade-serve
## Usage ## Usage
### FastAPI Worker To add a toolkit to a hosted worker such as FastAPI, you can register them in the worker itself.
This allows you to explicitly define which tools should be included on a particular worker.
Here is an example of adding the math toolkit (pip install arcade-math) to a FastAPI Worker:
```python ```python
from arcade_serve import FastAPIWorker import arcade_math
from fastapi import FastAPI
from arcade_tdk import Toolkit
from arcade_serve.fastapi import FastAPIWorker
# Create a FastAPI worker app = FastAPI()
worker = FastAPIWorker()
# Add tools to the worker worker_secret = os.environ.get("ARCADE_WORKER_SECRET")
worker.add_toolkit("path/to/toolkit") worker = FastAPIWorker(app, secret=worker_secret)
# Start the server worker.register_toolkit(Toolkit.from_module(arcade_math))
worker.start(host="0.0.0.0", port=8000)
``` ```
### MCP Server Here is an example of adding the math toolkit (pip install arcade-math) to a MCP Worker
```python ```python
from arcade_serve import StdioServer import arcade_math
from arcade_core.catalog import ToolCatalog
from arcade_serve.mcp.stdio import StdioServer
# Create an MCP server # 1. Create and populate the tool catalog
server = StdioServer() catalog = ToolCatalog()
catalog.add_module(arcade_math)
# Add tools
server.add_toolkit("path/to/toolkit")
# Start the server # 2. Main entrypoint
server.run() async def main():
``` # Create the worker with the tool catalog
worker = StdioServer(catalog)
### Custom Worker # Run the worker
await worker.run()
```python
from arcade_serve import BaseWorker, WorkerComponent
class MyWorker(BaseWorker): if __name__ == "__main__":
def __init__(self): import asyncio
super().__init__()
self.add_component(MyCustomComponent())
async def handle_request(self, request): asyncio.run(main())
# Custom request handling
return await super().handle_request(request)
``` ```
## License ## License

View file

@ -1,6 +1,6 @@
[project] [project]
name = "arcade-serve" name = "arcade-serve"
version = "1.0.0" version = "2.0.0"
description = "Arcade Serve - Serving infrastructure for Arcade tools and workers" description = "Arcade Serve - Serving infrastructure for Arcade tools and workers"
readme = "README.md" readme = "README.md"
license = {text = "MIT"} license = {text = "MIT"}

View file

@ -38,19 +38,17 @@ def hello_world(name: Annotated[str, "The name of the person to greet"]) -> str:
from typing import Annotated from typing import Annotated
from arcade_tdk import tool, ToolCatalog, Toolkit from arcade_tdk import tool, ToolCatalog, Toolkit
from arcade_tdk.auth import Reddit
# Create tools with more complex parameters # Create tools with auth requirement
@tool @tool(requires_auth=Reddit(scopes=["read"]))
def calculate_sum(numbers: Annotated[list[float], "The numbers to sum"]) -> float: def get_posts_in_subreddit(
"""Calculate the sum of a list of numbers.""" subreddit: Annotated[str, "The name of the subreddit"],
return sum(numbers) limit: Annotated[int, "The number of posts to return]
) -> dict:
# Access the tool catalog """Get posts from a specific subreddit"""
catalog = ToolCatalog() # TODO: Implement your Reddit tool
tools = catalog.get_all_tools() return {}
# Work with toolkits
toolkit = Toolkit.from_directory("my_toolkit")
``` ```
## License ## License

View file

@ -1,6 +1,6 @@
[project] [project]
name = "arcade-tdk" name = "arcade-tdk"
version = "1.0.0" version = "2.0.0"
description = "Arcade TDK - Toolkit Development Kit for building Arcade tools" description = "Arcade TDK - Toolkit Development Kit for building Arcade tools"
readme = "README.md" readme = "README.md"
license = {text = "MIT"} license = {text = "MIT"}