Skip to main content

A comprehensive integration package supporting various services.

Project description

polvo-python

Version: 1.1.0

Polvo is an open-source Python library designed to streamline the process of integrating multiple APIs into your applications. With a focus on developer experience, Polvo provides a suite of tools and abstractions that make it easy to interact with third-party services, both within and outside the context of Large Language Models (LLMs).

Features

  • Core: The foundation of Polvo providing shared functionality:
    • Auth: Flexible authentication handlers for various API protocols
    • Clients: Templated API clients for quick integration development
    • Rate Limiters: Smart strategies to manage API quotas and prevent throttling
    • Base Tentacles: Core components for building integrations
    • Webhooks: Secure webhook processing with signature validation, event handling, and an integrated server for receiving callbacks
  • Brain: A high-level abstraction for building AI-powered applications. The Brain manages cognitive processing, memory, and communication between components.
  • Tentacles: Ready-to-use API integrations and tools that provide a unified interface. Tentacles handle authentication, rate limiting, caching, and more.
  • LLM Tools: Seamlessly integrate Tentacles into LLM tools, enabling AI agents to interact with external services.
  • Async Support: Built from the ground up with asynchronous programming for optimal performance.
  • Developer Experience: Clear abstractions, powerful utilities, and comprehensive documentation.

Project Structure

usepolvo/
├── core/                       # Shared functionality
│   ├── auth/                  # Authentication handlers
│   ├── clients/               # API client templates
│   ├── rate_limiters/         # Rate limiting strategies
│   ├── tentacles/             # Base integration components
│   └── webhooks/              # Webhook processing and server
├── brain/                      # High-level LLM abstractions
└── tentacles/                  # Tools and integrations

Installation

pip install usepolvo

Quick Start

1. HubSpot Integration Example

from usepolvo.tentacles.integrations.hubspot import HubSpotContactsTentacle
from usepolvo.brain import create_brain

async def main():
    # Initialize HubSpot contacts integration
    contacts = HubSpotContactsTentacle()

    # Create a new contact
    result = await contacts.execute({
        "operation": "create",
        "email": "john@example.com",
        "firstname": "John",
        "lastname": "Smith"
    })

    # Use with Brain for AI-powered operations
    brain = await create_brain(
        name="HubSpot Assistant",
        tentacles=[contacts],
        system_prompt="You are a HubSpot CRM management assistant."
    )

    response = await brain.process(
        "Create a new contact with email jane@example.com and name Jane Doe"
    )

2. Custom API Integration Example

from pydantic import BaseModel, Field
from usepolvo.core.clients.rest import RESTClient
from usepolvo.core.tentacles.api import APITentacle

# Define your models
class WeatherInput(BaseModel):
    operation: str = Field(..., description="Operation: current or forecast")
    city: str = Field(..., description="City to get weather for")

class WeatherOutput(BaseModel):
    city: str
    temperature: float
    conditions: str

# Create API client
class WeatherClient(RESTClient):
    def __init__(self):
        super().__init__()
        self.base_url = "https://api.weather.com/v1"

    def get_current(self, city: str):
        return self._request("GET", f"/weather/{city}")

# Create your integration
class WeatherTentacle(APITentacle[WeatherInput, WeatherOutput]):
    def __init__(self):
        self.client = WeatherClient()
        super().__init__(self.client)

    def _setup(self) -> None:
        """Set up the weather tentacle definition."""
        self._definition = TentacleDefinition(
            name="weather",
            description="""
            Get weather information for cities.
            Available cities: San Francisco, New York, London, Tokyo.

            Operations:
            - current: Get current weather conditions
            - forecast: Get multi-day forecast
            """,
            input_schema=WeatherInput.model_json_schema(),
            output_schema=WeatherOutput.model_json_schema(),
        )

    async def execute(self, input: WeatherInput) -> WeatherOutput:
        if input.operation == "current":
            data = self.client.get_current(input.city)
            return WeatherOutput(**data)

# Usage
async def main():
    weather = WeatherTentacle()

    # Direct usage
    result = await weather({
        "operation": "current",
        "city": "San Francisco"
    })

    # Use with Brain
    brain = await create_brain(
        name="Weather Assistant",
        tentacles=[weather]
    )

    response = await brain.process(
        "What's the current weather in San Francisco?"
    )

Configuration

Create a .env file with your API credentials:

# HubSpot Configuration
POLVO_HUBSPOT_CLIENT_ID=your_client_id
POLVO_HUBSPOT_CLIENT_SECRET=your_client_secret
POLVO_HUBSPOT_REDIRECT_URI=your_redirect_uri

# Custom API Configuration
POLVO_WEATHER_API_KEY=your_api_key

Documentation

For detailed documentation and examples, visit docs.usepolvo.com

License

MIT License

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

usepolvo-1.1.5.tar.gz (45.8 kB view details)

Uploaded Source

Built Distribution

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

usepolvo-1.1.5-py3-none-any.whl (69.5 kB view details)

Uploaded Python 3

File details

Details for the file usepolvo-1.1.5.tar.gz.

File metadata

  • Download URL: usepolvo-1.1.5.tar.gz
  • Upload date:
  • Size: 45.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for usepolvo-1.1.5.tar.gz
Algorithm Hash digest
SHA256 f6ee8f01a60ba61d92da558eaa5bcc36d500925276d2be43fb3b2441e50a766f
MD5 af3261d9ccead525607c253c1fe22f4e
BLAKE2b-256 e1176a0416ef5ff00095d3412b70a29d7caae7140c866bbf9c216163fce29822

See more details on using hashes here.

File details

Details for the file usepolvo-1.1.5-py3-none-any.whl.

File metadata

  • Download URL: usepolvo-1.1.5-py3-none-any.whl
  • Upload date:
  • Size: 69.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for usepolvo-1.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 fe2fe9699d4ac04aedba41ddf77a5f425d3c1d6769530db26e89523e8a7e48cb
MD5 35f8b7e6585c5c4e42fa90c61f92349f
BLAKE2b-256 8dfd5dc0dbc8b4268451d387ba9fcc84f3ec1d933ad4b432d58f65abf005bf52

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