Skip to main content

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

  1. Initialize a new project:
agentflow init
  1. Start the API server with default configuration:
agentflow api
  1. Start the API server with custom configuration:
agentflow api --config custom-config.json
  1. Start the API server on different host/port:
agentflow api --host 127.0.0.1 --port 9000
  1. 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:

  1. Absolute path (if provided with --config)
  2. Current working directory
  3. Relative to script location (for development)
  4. 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

  1. Clone the repository:

    git clone https://github.com/10XScale-in/backend-base.git
    
  2. Create a virtual environment and activate:

    python -m venv venv
    source venv/bin/activate
    
  3. 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:

  1. Initialize the database initially:

    aerich init -t src.app.db.setup_database.TORTOISE_ORM
    
  2. Create initial database schema:

    aerich init-db
    
  3. Generate migration files:

    aerich migrate
    
  4. Apply migrations:

    aerich upgrade
    
  5. Revert migrations (if needed):

    aerich downgrade
    

Running the Application

Command Line

To run the FastAPI application using Uvicorn:

  1. Start the application:

    uvicorn src.app.main:app --reload
    
  2. 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

  1. 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:

  1. Clone the repository:

    git clone https://github.com/Iamsdt/agentflow-cli.git
    cd agentflow-cli
    
  2. Create a virtual environment:

    python -m venv .venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
    
  3. Install in development mode:

    pip install -e .
    
  4. Install development dependencies:

    pip install pytest pytest-cov ruff mypy pre-commit
    
  5. 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

  1. Test your package locally:

    make test-cli
    
  2. Publish to TestPyPI first:

    make publish-test
    
  3. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

10xscale_agentflow_cli-0.1.7.tar.gz (59.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

10xscale_agentflow_cli-0.1.7-py3-none-any.whl (74.7 kB view details)

Uploaded Python 3

File details

Details for the file 10xscale_agentflow_cli-0.1.7.tar.gz.

File metadata

  • Download URL: 10xscale_agentflow_cli-0.1.7.tar.gz
  • Upload date:
  • Size: 59.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for 10xscale_agentflow_cli-0.1.7.tar.gz
Algorithm Hash digest
SHA256 29ae861c91f56a9fec38400958927c9c46506c5e2113dee82dc3b23c4df8c4cf
MD5 03129aacc9cd904d6f75bc01202b016c
BLAKE2b-256 36bc5e5bf526f84c8468a7a9423cc57cd42a1627eb315b5bcbff97e195ffae43

See more details on using hashes here.

File details

Details for the file 10xscale_agentflow_cli-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for 10xscale_agentflow_cli-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 b6076d5e9e372609149ea62de90fcd8ad3c4843528cddbbdaf3fc47cea8e3a19
MD5 18991f8a42ec7ee3558ff3e36154e658
BLAKE2b-256 58407698c34096e8d8091e4a62d5e2c8098fa084a6c197ae48d872aae6054c22

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page