CLI and API for 10xscale AgentFlow
Project description
AgentFlow CLI
A Python API framework with GraphQL support, task management, and CLI tools for building scalable web applications.
Installation
From PyPI (Recommended)
pip install agentflow-cli
From Source
git clone https://github.com/Iamsdt/agentflow-cli.git
cd agentflow-cli
pip install -e .
Quick Start
- Initialize a new project:
agentflow init
- Start the API server with default configuration:
agentflow api
- Start the API server with custom configuration:
agentflow api --config custom-config.json
- Start the API server on different host/port:
agentflow api --host 127.0.0.1 --port 9000
- Generate a Dockerfile for containerization:
agentflow build
CLI Commands
The agentflow command provides the following subcommands:
agentflow api
Start the Pyagenity API server.
Options:
--config TEXT: Path to config file (default: agentflow.json)--host TEXT: Host to run the API on (default: 0.0.0.0)--port INTEGER: Port to run the API on (default: 8000)--reload/--no-reload: Enable auto-reload (default: enabled)
Examples:
# Start with default configuration
agentflow api
# Start with custom config file
agentflow api --config my-config.json
# Start on localhost only, port 9000
agentflow api --host 127.0.0.1 --port 9000
# Start without auto-reload
agentflow api --no-reload
agentflow init
Initialize a new config file with default settings.
Options:
--output TEXT: Output config file path (default: agentflow.json)--force: Overwrite existing config file
Examples:
# Create default config
agentflow init
# Create config with custom name
agentflow init --output custom-config.json
# Overwrite existing config
agentflow init --force
agentflow version
Show the CLI version information.
agentflow version
agentflow build
Generate a Dockerfile for the Pyagenity API application.
Options:
--output TEXT: Output Dockerfile path (default: Dockerfile)--force/--no-force: Overwrite existing Dockerfile (default: no-force)--python-version TEXT: Python version to use (default: 3.11)--port INTEGER: Port to expose in the container (default: 8000)
Examples:
# Generate default Dockerfile
agentflow build
# Generate with custom Python version and port
agentflow build --python-version 3.12 --port 9000
# Overwrite existing Dockerfile
agentflow build --force
# Generate with custom filename
agentflow build --output MyDockerfile
Features:
- ๐ Automatic requirements.txt detection: Searches for requirements files in multiple locations
- โ ๏ธ Smart fallback: If no requirements.txt found, installs agentflow-cli from PyPI
- ๐ณ Production-ready: Generates optimized Dockerfile with security best practices
- ๐ง Customizable: Supports custom Python versions, ports, and output paths
- ๐ฅ Health checks: Includes built-in health check endpoint
- ๐ค Non-root user: Runs container as non-root for security
Configuration
The configuration file (agentflow.json) supports the following structure:
{
"app": {
"name": "Pyagenity API",
"version": "1.0.0",
"debug": true
},
"server": {
"host": "0.0.0.0",
"port": 8000,
"workers": 1
},
"database": {
"url": "sqlite://./agentflowdb"
},
"redis": {
"url": "redis://localhost:6379"
}
}
File Resolution
The CLI automatically finds your config file in this order:
- Absolute path (if provided with
--config) - Current working directory
- Relative to script location (for development)
- Package installation directory (fallback)
Project Structure
agentflow-cli/
โโโ pyagenity_api/ # Main package directory
โ โโโ __init__.py # Package initialization
โ โโโ cli.py # CLI module
โ โโโ src/ # Source code
โ โโโ app/ # FastAPI application
โ โโโ main.py # FastAPI app entry point
โ โโโ core/ # Core functionality
โ โโโ routers/ # API routes
โ โโโ tasks/ # Background tasks
โโโ graph/ # Graph implementation
โโโ migrations/ # Database migrations
โโโ scripts/ # Utility scripts
โโโ docs/ # Documentation
โโโ pyproject.toml # Project configuration
โโโ requirements.txt # Dependencies
โโโ Makefile # Development commands
โโโ MANIFEST.in # Package manifest
โโโ README.md # This file
Features
- FastAPI Backend: High-performance async web framework
- GraphQL Support: Built-in GraphQL API with Strawberry
- Task Management: Background task processing with Taskiq
- CLI Tools: Command-line interface for easy management
- Database Integration: Support for multiple databases via Tortoise ORM
- Redis Integration: Caching and session management
- Authentication: Firebase authentication support
- Development Tools: Pre-commit hooks, linting, testing
- Docker Support: Container deployment ready
Setup
Prerequisites
- Python 3.x
- pip
- [Any other prerequisites]
Installation
-
Clone the repository:
git clone https://github.com/10XScale-in/backend-base.git
-
Create a virtual environment and activate:
python -m venv venv source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
Database
Database Configuration
The database configuration is located in src/app/db/setup_database.py.
Database Migration
We use Aerich for database migrations. Follow these steps to manage your database:
-
Initialize the database initially:
aerich init -t src.app.db.setup_database.TORTOISE_ORM
-
Create initial database schema:
aerich init-db -
Generate migration files:
aerich migrate -
Apply migrations:
aerich upgrade -
Revert migrations (if needed):
aerich downgrade
Running the Application
Command Line
To run the FastAPI application using Uvicorn:
-
Start the application:
uvicorn src.app.main:app --reload
-
You can also run the debugger.
VS Code
Add the following configuration to your .vscode/launch.json file:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: FastAPI",
"type": "python",
"request": "launch",
"module": "uvicorn",
"args": [
"src.app.main:app",
"--host",
"localhost",
"--port",
"8880"
],
"jinja": true,
"justMyCode": true
}
]
}
Then you can run and debug the application using the VS Code debugger.
Run the Broker
- Run the taskiq worker
</code></pre>
<h2>Development</h2>
<h3>Using the Makefile</h3>
<p>The project includes a comprehensive Makefile for development tasks:</p>
<pre lang="bash"><code># Show all available commands
make help
# Install package in development mode
make dev-install
# Run tests
make test
# Test CLI installation
make test-cli
# Format code
make format
# Run linting
make lint
# Run all checks (lint + test)
make check
# Clean build artifacts
make clean
# Build package
make build
# Publish to TestPyPI
make publish-test
# Publish to PyPI
make publish
# Complete release workflow
make release
Manual Development Setup
If you prefer manual setup:
-
Clone the repository:
git clone https://github.com/Iamsdt/agentflow-cli.git cd agentflow-cli
-
Create a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install in development mode:
pip install -e .
-
Install development dependencies:
pip install pytest pytest-cov ruff mypy pre-commit
-
Set up pre-commit hooks:
pre-commit install
Testing
Run tests using pytest:
pytest src/tests/ -v --cov=pyagenity_api
Or use the Makefile:
make test
Publishing to PyPI
-
Test your package locally:
make test-cli -
Publish to TestPyPI first:
make publish-test -
If everything works, publish to PyPI:
make publish
Resources
https://keda.sh/ Get all the fixers pytest --fixtures https://www.tutorialspoint.com/pytest/pytest_run_tests_in_parallel.html
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 10xscale_agentflow_cli-0.1.6.tar.gz.
File metadata
- Download URL: 10xscale_agentflow_cli-0.1.6.tar.gz
- Upload date:
- Size: 59.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f92c7e6175241ff11458ef83fc6ad24e75cc0cdffbd3c8b8384e162b3c6a871
|
|
| MD5 |
8d4e58fca2dc9ec2da119333b6dc4974
|
|
| BLAKE2b-256 |
08ac82d80cf6e1905f8ca89e8d7a6f583617dd723e6e66e85dba6002ff006032
|
File details
Details for the file 10xscale_agentflow_cli-0.1.6-py3-none-any.whl.
File metadata
- Download URL: 10xscale_agentflow_cli-0.1.6-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03509cc3d501061f3d704f46b2a107c49ec4fc84a7f4b1c833c401e2187e9703
|
|
| MD5 |
964280d67f9f926f3dabcb03559c1403
|
|
| BLAKE2b-256 |
f6f7aeb48be060dfa364b28df64a01b1319b7552fdec1aaadec5d87bb5bf238b
|