Skip to main content

An agent for interacting with Blask API based on Swagger spec

Project description

BlaskAPIAgentManager

BlaskAPIAgentManager is a Python library that provides a sophisticated pipeline for interacting with the Blask API based on Swagger specifications. It automates API discovery, planning, and execution to retrieve relevant data based on natural language queries.

Features

  • Automatic API Planning: Intelligently plans the right API calls based on natural language queries
  • API Call Orchestration: Executes API calls in the optimal order with proper parameters
  • Data Enrichment: Automatically enriches data by resolving IDs to human-readable names
  • Result Synthesis: Summarizes API responses into coherent, user-friendly answers
  • RAG Enhancement: Can enhance Retrieval-Augmented Generation answers with live API data

Installation

Quick Install with pip

pip install BlaskAPIAgentManager

Install with uv (Recommended)

For a faster, more reliable installation, you can use uv, a Python packaging tool for fast installation:

# Install uv if you don't have it
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install BlaskAPIAgentManager with uv
uv pip install BlaskAPIAgentManager

Local Development Installation

For local development or contributing to the project:

  1. Clone the repository:
git clone https://gitlab.private.blask.com/blask/ml-ai/blaskapiagentmanager
cd blaskapiagentmanager
  1. Create and activate a virtual environment:

Using standard venv:

# Create virtual environment
python -m venv venv

# Activate on macOS/Linux
source venv/bin/activate

# Activate on Windows
venv\Scripts\activate

Using uv (recommended):

# Create virtual environment
uv venv

# Activate on macOS/Linux
source .venv/bin/activate

# Activate on Windows
.venv\Scripts\activate
  1. Install the package in development mode:
# Using standard pip
pip install -e .

# Using uv (recommended)
uv pip install -e .

Configuration

Create a .env file in your project root with the following variables:

BLASK_USERNAME=your_username
BLASK_PASSWORD=your_password
OPENROUTER_API_KEY=your_openrouter_api_key
SWAGGER_JSON_URL=link_to_swagger_json
LOGIN_URL=link_to_login
BASE_URL=base_api_url

Usage

Basic Usage

from BlaskAPIAgentManager import BlaskPipeline

# Initialize the pipeline
pipeline = BlaskPipeline()

# Process a natural language query
result = pipeline.process_query("What are the top 5 performing countries by GGR in the last 3 months?")

# Print the summary
print(result["summary"])

# Access the raw data
api_data = result["data"]

Components

  • BlaskAPIAgentManager: The name of the Python package.
  • BlaskPipeline: Main orchestrator that manages the entire workflow from query to summarized result.
  • BlaskAPIAgent: Core agent for authenticating and interacting with the Blask API.
  • PlannerTool: Plans the sequence of API calls based on natural language queries.
  • ProcessorTool: Processes raw API responses by filtering, sorting, and aggregating data.

Development

To contribute to this project:

  1. Clone the repository
  2. Create and activate a virtual environment (see Local Development Installation section)
  3. Install development dependencies:
uv pip install -e ".[dev]"
  1. Set up environment variables for testing:

    • Create a .env file in the project root with your Blask API credentials
    • Tests will skip API-dependent tests if credentials are not available
  2. Run tests:

# Run all tests
python -m unittest discover

# Run specific test files
python -m unittest tests.test_basic
python -m unittest tests.test_api_agents

Note that tests in test_api_agents.py require valid API credentials and will be skipped if they're not available.

License

MIT

Support

For support, please contact elijah@blask.com.

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

blaskapiagentmanager-0.1.21.tar.gz (39.4 kB view details)

Uploaded Source

Built Distribution

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

blaskapiagentmanager-0.1.21-py3-none-any.whl (45.1 kB view details)

Uploaded Python 3

File details

Details for the file blaskapiagentmanager-0.1.21.tar.gz.

File metadata

  • Download URL: blaskapiagentmanager-0.1.21.tar.gz
  • Upload date:
  • Size: 39.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for blaskapiagentmanager-0.1.21.tar.gz
Algorithm Hash digest
SHA256 c418ef496cbd2eb8ac00e9fc3563ec76db8fb5e3740207471b90289c79d5aa1d
MD5 41e774bdce5a57d62ebf8a476237a0f2
BLAKE2b-256 82397697db538f9d3b4dbbaa6378d3d404e164c1ec31cf68b2f5f2202bde3d8f

See more details on using hashes here.

File details

Details for the file blaskapiagentmanager-0.1.21-py3-none-any.whl.

File metadata

File hashes

Hashes for blaskapiagentmanager-0.1.21-py3-none-any.whl
Algorithm Hash digest
SHA256 297daf2e2960aaf6a18c4ed9450edc044f5c97d552ced63a2176e267a59e21ac
MD5 e91723bfc1009db119a01bbeed6fc369
BLAKE2b-256 83a0fbe459c63066fdcea8a5c82ae47c3a3226be6a5a32cec7ccd9da84e13a03

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