PharonAgent is a powerful agent designed to create and manage Docker-based resources and execute tools in a safe environment. The agent handles resource provisioning, management, and execution using Python functions, with outputs stored securely for easy access by other tools.
visit my site ahmehttps://www.ahmedsedik.site/
- Quickstart Guide - Get up and running in minutes
- User Manual - Comprehensive guide to using PharonAgent
- Advanced Usage - Advanced techniques and patterns
- Resource Management: Create and manage Docker-based resources (MongoDB, PostgreSQL, Redis, Elasticsearch, etc.)
- Tool Execution: Run Python functions as tools in a secure environment
- Error Handling: Robust error handling during execution of generated Python code
- Environment Configuration: Use .env files for API keys and other configuration
- Clone the repository:
git clone https://github.com/ahmesedeeek3/pharonAgent.git
cd pharonAgent
- Install the required dependencies:
pip install -r requirements.txt
- Create a
.env
file based on.env.example
:
cp .env.example .env
- Edit the
.env
file with your API keys.
The project includes comprehensive unit tests for all components. To run the tests:
# Run all tests
./tests/run_tests.py
# Run specific test files
python -m unittest tests/test_safe_execution.py
python -m unittest tests/test_docker_manager.py
python -m unittest tests/test_agent.py
python -m unittest tests/test_resource_tools.py
- Python 3.8+
- Docker
- OpenAI API key (for LLM)
- Grok API key (optional)
The main script provides an interactive interface to work with PharonAgent:
# Run in interactive mode
./main.py
# Run with a specific query
./main.py --query "Create a MongoDB database and run a simple query to store user data"
# Show help
./main.py --help
from src.agent.agent import PharonAgent
from src.tools.resource_tools import ResourceTools
from src.utils.safe_execution import SafeExecutionEnvironment
# Initialize the agent
agent = PharonAgent()
# Create resource tools
resource_tools = ResourceTools(output_dir="./outputs")
# Add tools to the agent
agent.add_tools(resource_tools.get_tools())
# Run the agent with a query
result = agent.run("Create a MongoDB database and run a simple query to store user data")
print(result)
PharonAgent can create various resources using Docker:
- MongoDB
- PostgreSQL
- Redis
- Elasticsearch
- Custom containers
Example:
# The agent can handle natural language requests to create resources
result = agent.run("Create a PostgreSQL database with username 'admin' and password 'secure_password'")
PharonAgent provides a safe environment for executing code:
from src.utils.safe_execution import SafeExecutionEnvironment
# Initialize safe execution environment
safe_env = SafeExecutionEnvironment(output_dir="./outputs")
# Execute code
code = """
import pandas as pd
# Create a simple dataframe
data = {'Name': ['Alice', 'Bob', 'Charlie'],
'Age': [25, 30, 35]}
df = pd.DataFrame(data)
# Save to CSV
df.to_csv('output_path/data.csv', index=False)
print("Data saved successfully!")
"""
result = safe_env.execute_code(code, inputs={"output_path": "./outputs"})
print(f"Success: {result['success']}")
print(f"Output: {result['output']}")
pharonAgent/
├── .env # API keys (to be filled by you)
├── .env.example # Template for environment variables
├── .gitignore # Git ignore file
├── README.md # Project documentation
├── requirements.txt # Project dependencies
├── src/ # Source code
│ ├── __init__.py
│ ├── agent/ # Agent implementation
│ │ ├── __init__.py
│ │ └── agent.py # Main agent class
│ ├── resources/ # Resource management
│ │ ├── __init__.py
│ │ └── docker_manager.py # Docker resource handling
│ ├── tools/ # Tool implementations
│ │ ├── __init__.py
│ │ └── resource_tools.py # Resource creation/management tools
│ └── utils/ # Utility functions
│ ├── __init__.py
│ └── safe_execution.py # Safe execution environment
├── outputs/ # Tool outputs folder
└── tests/ # Test files