Skip to main content

Backend API service for the PyLama ecosystem

Project description

APILama

APILama is the API gateway for the PyLama ecosystem. It serves as the central communication layer between the frontend WebLama interface and the various backend services (PyLama, PyBox, PyLLM, SheLLama). APILama integrates with LogLama as the primary service for centralized logging, environment management, and service orchestration.

Features

  • Unified API Gateway: Single entry point for all PyLama ecosystem services
  • Service Routing: Intelligent routing of requests to appropriate backend services (PyBox, PyLLM, SheLLama, PyLama)
  • RESTful API Design: Clean and consistent API endpoints for all operations
  • Cross-Origin Resource Sharing (CORS): Support for cross-origin requests from the WebLama frontend
  • Authentication and Authorization: Secure access to API endpoints
  • Response Standardization: Consistent response format across all services
  • Error Handling: Comprehensive error handling and reporting
  • LogLama Integration: Integrates with LogLama for centralized logging, environment management, and service orchestration
  • Structured Logging: All API requests and responses are logged with component context for better debugging and monitoring

Installation

# Create a virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install the package in development mode
pip install -e .  # This is important! Always install in development mode before starting

IMPORTANT: Always run pip install -e . before starting the project to ensure all dependencies are properly installed and the package is available in development mode.

Usage

Running the API Gateway

# Start the API server with default settings
python -m apilama.app --port 8080 --host 127.0.0.1

# Or with environment variables
export PORT=8080
export HOST=127.0.0.1
python -m apilama.app

Using the Makefile

# Start the API server with default settings
make run

# Start with custom port
make run PORT=8090

Environment Variables

APILama uses the following environment variables for configuration:

  • PORT: The port to run the server on (default: 8080)
  • HOST: The host to bind to (default: 127.0.0.1)
  • DEBUG: Enable debug mode (default: False)
  • PYBOX_API_URL: URL of the PyBox API (default: http://localhost:8000)
  • PYLLM_API_URL: URL of the PyLLM API (default: http://localhost:8001)
  • SHELLAMA_API_URL: URL of the SheLLama API (default: http://localhost:8002)
  • PYLAMA_API_URL: URL of the PyLama API (default: http://localhost:8003)

You can set these variables in a .env file or pass them directly when starting the server.

API Documentation

Health Check

GET /api/health

Returns the health status of the APILama service.

SheLLama Endpoints

File Operations

GET /api/shellama/files?directory=/path/to/dir   # List files in a directory
GET /api/shellama/file?filename=/path/to/file     # Get file content
POST /api/shellama/file                           # Create/update a file
DELETE /api/shellama/file?filename=/path/to/file  # Delete a file

Directory Operations

GET /api/shellama/directory?directory=/path/to/dir  # Get directory information
POST /api/shellama/directory                        # Create a directory
DELETE /api/shellama/directory?directory=/path      # Delete a directory

Shell Operations

POST /api/shellama/shell  # Execute a shell command

PyBox Endpoints

GET /api/pybox/health     # Check PyBox health
POST /api/pybox/execute   # Execute Python code

PyLLM Endpoints

GET /api/pyllm/health     # Check PyLLM health
POST /api/pyllm/generate  # Generate code or text

PyLama Endpoints

GET /api/pylama/health    # Check PyLama health
GET /api/pylama/models    # List available models
POST /api/pylama/execute  # Execute a model

Development

# Install development dependencies
pip install -e ".[dev]"

# Run tests
python -m pytest

# Format code
black apilama tests

# Lint code
flake8 apilama tests

License

MIT

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

apilama-0.1.6.tar.gz (19.1 kB view details)

Uploaded Source

Built Distribution

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

apilama-0.1.6-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file apilama-0.1.6.tar.gz.

File metadata

  • Download URL: apilama-0.1.6.tar.gz
  • Upload date:
  • Size: 19.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for apilama-0.1.6.tar.gz
Algorithm Hash digest
SHA256 64171d6377b6353b76e043a1432037d5aa08b8fdc152e3c664c2a05ab102d1c8
MD5 79c8c0c95299ae50e85ac1b5ef1befb8
BLAKE2b-256 fbd9996a640ffd4d208a954a8e260bad3e2e5c0fe94fe1eb4ed3e4c14b7d487d

See more details on using hashes here.

File details

Details for the file apilama-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: apilama-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for apilama-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 15ff33d034f4e917742932b1a905ca54f4c7ca112fe6aec79ba5c132891fb2d5
MD5 0c5889ab6adb3ab957e05b288230a608
BLAKE2b-256 684d2bf52b9a83fa06382084ec8c1d96e80c354e56f3954ade2bd7886eb367e7

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