Toolkit for Persona, an agent AI system — provides modular, callable tools for dynamic function execution
Project description
Persona CLI
Persona CLI is a command-line tool for creating and managing projects that use the persona-toolkit — a modular
function-calling framework designed for agent-based systems.
This CLI helps you scaffold projects, generate tools, test them locally, and run the FastAPI server that exposes your tools via REST API.
🚀 Installation
To use the CLI, first install the persona-toolkit library (assuming it's published or available locally):
pip install persona-toolkit
Or if you're developing locally:
cd persona-toolkit/
poetry install
The CLI is exposed as:
persona-toolkit
📆 Features
init
Create a new project scaffold with Poetry and the required structure:
persona-toolkit init my-project
This will:
- Initialize a Poetry project
- Install
persona-toolkitas a dependency - Create a
tools/folder where your tools will live
add-tool
Add a new tool interactively:
persona-toolkit add-tool
You'll be prompted for a tool name. A new Python file will be created in the tools/ directory with a ready-to-edit
template including:
InputandOutputmodels (using Pydantic)- A
run()function
test-tool
Test a tool locally by manually entering its input values:
persona-toolkit test-tool echo
This will:
- Import the specified tool from the
tools/directory - Prompt for input fields
- Run the
run()function and show the output
You can use the cli to pass input values:
persona-toolkit test-tool echo --input '{"message": "Hello, World!"}'
run
Start the FastAPI server and expose your tools via HTTP:
persona-toolkit run --port 8000
You can now access:
GET /tools— list available toolsGET /tools/{tool}/schema— get tool schemaPOST /invocations— run a tool
🗂 Project Structure
my-project/
├── pyproject.toml # Poetry project config
├── tools/
│ └── echo_test.py # Example tool
Each tool must define:
NAME(a str with tool name)Input(a Pydantic model)Output(a Pydantic model)run(context: AgentContext, input: Input) -> Output
💡 Example Tool
from pydantic import BaseModel, Field
from persona_toolkit.model import AgentContext
NAME = "echo"
class Input(BaseModel):
message: str = Field(description="Message to echo")
class Output(BaseModel):
message: str
def run(context: AgentContext, args: Input) -> Output:
"""
Echo the message back.
The `context` can be used to store and retrieve state across invocations.
For example, if a previous message exists in the context, it will be appended to the current message.
"""
previous_message = context.get("message")
if previous_message:
input.message = f"{previous_message} {input.message}"
context.set("message", args.message)
return Output(message=f"Echo: {args.message}")
Understanding kwargs and context
The context parameter is an instance of AgentContext, which is a dictionary-like object that provides access to the
current execution context of the tool, it includes the following keys:
project_id: The ID of the project where the tool is being executed.session_id: The ID of the current session, which can be used to track the state of the conversation or interaction.user_id: The ID of the user invoking the tool, which can be useful for personalizing responses or tracking user-specific data.
And expose a set of methods to manage the context:
get(key: str, default: Any = None): Retrieve a value from the context by key. If the key does not exist, return the default value.set(key: str, value: Any): Set a value in the context by key.delete(key: str): Delete a value from the context by key.
For example, if a tool needs to keep track of the last message sent by the user, it can store that message in the
context and retrieve it in subsequent invocations, it can be used to:
- Store intermediate results.
- Append or modify input values based on previous invocations.
- Share data across different tools in the same session.
Example of using kwargs
# tools/echo_test.py
from pydantic import BaseModel, Field
from persona_toolkit.model import AgentContext
NAME = "echo"
class Input(BaseModel):
message: str = Field(description="Message to echo")
class Output(BaseModel):
message: str
def run(context: AgentContext, args: Input) -> Output:
"""
Echo the message back.
"""
# Access primary infos from kwargs
project_id = context.project_id
session_id = context.session_id
user_id = context.user_id
# TODO: Do something with project_id, session_id, user_id
return Output(message=f"Echo: {args.message}")
💻 Local Development
To run the CLI locally, you can use the following command:
python persona_toolkit/cli.py --port 8001
You can use local tools folder to test your tools. Just make sure to set the PYTHONPATH to the root of the project:
✅ Requirements
- Python 3.10+
- Poetry
- Uvicorn (installed automatically)
📃 License
MIT License
Built for the Persona Agent System 🤖
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file persona_toolkit-1.0.29.tar.gz.
File metadata
- Download URL: persona_toolkit-1.0.29.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.11.4 Linux/6.1.79
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5086d52196a9cd00cfc425ced7cd38723b4657621b746ad3f03431d972e5dcba
|
|
| MD5 |
f74994f725381e4fcd9f4ca2ac9b246a
|
|
| BLAKE2b-256 |
e8fca7c9d06e8d3e37834eb8a84786e4bf4ea0569b45c8bf9d01d0dc91c7f45a
|
File details
Details for the file persona_toolkit-1.0.29-py3-none-any.whl.
File metadata
- Download URL: persona_toolkit-1.0.29-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.11.4 Linux/6.1.79
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19fb68f0ae873367c7e4ce5d42f0f4483d5c338ef0428f6b7505f1fc740338e1
|
|
| MD5 |
6a006acddf9e6c53855de94ca89458c5
|
|
| BLAKE2b-256 |
5409d85939c0a56ecb664c36aca443edd9c30ec38e45587f34f5607e264a4b19
|