Skip to main content

No project description provided

Project description

Weni Agents Toolkit

CI CD PyPI version Python Versions License: MIT

A Python library for creating and managing agent skills for the Weni platform. Build powerful conversational agents with type-safe components and a robust skill system.

Installation

pip install weni-agents-toolkit

Or with Poetry:

poetry add weni-agents-toolkit

Quick Start

Creating a Skill

import requests
from weni import Skill
from weni.context import Context
from weni.components import Text, QuickReplies
from weni.data import register_result

class GetAddress(Skill):

    def execute(self, context: Context):
        # This is how we would retrieve credentials or sensitive information from context
        token = context.credentials.get("X-App-Token")

        # This is how we would retrieve parameters for this agent tool
        cep = context.parameters.get("cep")

        # This is how we would retrieve global constants for this project
        api_url = context.globals.get("cep_api_url")

        # This block is the business logic for the sake of this example on retrieving an address based on the received CEP
        base_url = f"{api_url}/{cep}"
        response = requests.get(base_url, headers={"Authorization": f"Bearer {token}"})

        result = response.json()

        # This block is where data is registered for further analysis in the future
        register_result("address", result.get("street"))
        # This example I'm respoonding allowing quick replies message or a location
        return TextResponse(data=result)

Registering Events

Register analytics events to the Weni Datalake using self.register_event() inside your tool:

from weni import Tool
from weni.context import Context
from weni.events.event import Event
from weni.responses import TextResponse

class MyTool(Tool):
    def execute(self, context: Context):
        result = do_work()

        self.register_event(Event(
            event_name="order_placed",
            key="order_123",
            value_type="string",
            value="completed",
            metadata={"customer": "John Doe"},
        ))

        return TextResponse(data=result)

Parameters:

  • event_name: Event name.
  • key: Unique key for the event.
  • value_type: Value type (string, int, etc).
  • value: Event value.
  • metadata: (Optional) Additional event metadata.
  • date: (Optional) ISO 8601 date string (defaults to current time).

Events are collected automatically per tool execution with full isolation between Lambda warm starts.

Core Concepts

Context System

The context system provides secure access to:

context = Context(
    credentials={"api_key": "secret123"},     # Sensitive data
    parameters={"user_id": "123"},            # Skill parameters
    globals={"env": "production"}             # Global configuration
)

Available Components

  • Text: Basic text messages
  • QuickReplies: Interactive quick reply buttons
  • ListMessage: Interactive list menus
  • CTAMessage: Call-to-action messages
  • Location: Location request messages
  • OrderDetails: Order information messages
  • Attachments: File attachments
  • Header: Message headers
  • Footer: Message footers

Response Types

  • TextResponse: Simple text messages
  • QuickReplyResponse: Messages with quick reply buttons
  • ListMessageResponse: Interactive list menus
  • CTAMessageResponse: Call-to-action messages
  • LocationResponse: Location-based messages
  • OrderDetailsResponse: Order information displays

Development

Prerequisites

  • Python 3.9+
  • Poetry

Setup

  1. Clone the repository:
git clone https://github.com/weni-ai/agents-toolkit.git
cd agents-toolkit
  1. Install dependencies:
poetry install
  1. Run tests:
poetry run pytest

Code Quality

We use several tools to ensure code quality:

  • pytest for testing
  • mypy for type checking
  • ruff for linting

Run all checks:

poetry run pytest
poetry run mypy weni
poetry run ruff check .

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

weni_agents_toolkit-2.6.3a0.tar.gz (24.0 kB view details)

Uploaded Source

Built Distribution

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

weni_agents_toolkit-2.6.3a0-py3-none-any.whl (30.0 kB view details)

Uploaded Python 3

File details

Details for the file weni_agents_toolkit-2.6.3a0.tar.gz.

File metadata

  • Download URL: weni_agents_toolkit-2.6.3a0.tar.gz
  • Upload date:
  • Size: 24.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.13.13 Linux/6.17.0-1010-azure

File hashes

Hashes for weni_agents_toolkit-2.6.3a0.tar.gz
Algorithm Hash digest
SHA256 dd2870a8426d639f3d998dbd0e3623d968e77cf73d722f60f244d7d6e07bd6ff
MD5 e86ac7795749fa4948e6de4d25d80078
BLAKE2b-256 22de360ab3bb848c9dfb721811d3ec3a8bfec834eeab8a7cf272bd020e52665a

See more details on using hashes here.

File details

Details for the file weni_agents_toolkit-2.6.3a0-py3-none-any.whl.

File metadata

  • Download URL: weni_agents_toolkit-2.6.3a0-py3-none-any.whl
  • Upload date:
  • Size: 30.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.13.13 Linux/6.17.0-1010-azure

File hashes

Hashes for weni_agents_toolkit-2.6.3a0-py3-none-any.whl
Algorithm Hash digest
SHA256 32a206ddbfa12008d7e03781d20932df609559b8577e81736b8e5ff16fa99a34
MD5 97fc83bf9695312c0e4d9c60d28b5471
BLAKE2b-256 4f43e6c5ae85428434f1fcdf2aaac179290e4d08e8c87f39a21f194a43756c1a

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