mirror of
https://github.com/MervinPraison/PraisonAI.git
synced 2026-11-07 17:33:33 -10:00
1.7 KiB
1.7 KiB
PraisonAI Example Plugin
This is a template for creating tool plugins for PraisonAI Agents.
Installation
# Install in development mode
pip install -e .
# Or install from PyPI (after publishing)
pip install praisonai-example-plugin
Usage
After installation, tools are automatically discovered:
from praisonaiagents import Agent
# Use tools by name - they're auto-discovered!
agent = Agent(
name="Assistant",
tools=["example_greet", "example_math", "example_reverse"]
)
# Or import and use directly
from praisonai_example_plugin import GreetTool, MathTool, reverse_text
agent = Agent(
name="Assistant",
tools=[GreetTool(), MathTool(), reverse_text]
)
Creating Your Own Plugin
- Copy this template
- Rename the package in
pyproject.tomlandsrc/directory - Add your tools following the patterns in
__init__.py - Update entry_points in
pyproject.tomlto register your tools
Tool Patterns
Class-based tool:
from praisonaiagents import BaseTool
class MyTool(BaseTool):
name = "my_tool"
description = "What this tool does"
def run(self, param: str) -> str:
return f"Result: {param}"
Decorator-based tool:
from praisonaiagents import tool
@tool
def my_function(param: str) -> str:
"""What this function does."""
return f"Result: {param}"
Registering Tools
In pyproject.toml:
[project.entry-points."praisonaiagents.tools"]
my_tool = "my_package:MyTool"
my_function = "my_package:my_function"
Testing
pip install -e ".[dev]"
pytest
Publishing
pip install build twine
python -m build
twine upload dist/*
License
MIT