No project description provided
Project description
Weni Agents Toolkit
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)
Sending an Event
You can send custom events to the Weni Datalake using the Event class. This is useful for logging actions, integrations, or relevant data during skill execution.
from weni.events import Event
Event.register(Event(
event_name="event_name",
key="key_name",
value_type="string",
value="value",
metadata={
"agent_collaboration": {
"agent_name": "agent_name",
"input_text": "input_text"
}
}
))
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.
Registered events are available for integration and further analysis.
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 messagesQuickReplies: Interactive quick reply buttonsListMessage: Interactive list menusCTAMessage: Call-to-action messagesLocation: Location request messagesOrderDetails: Order information messagesAttachments: File attachmentsHeader: Message headersFooter: Message footers
Response Types
TextResponse: Simple text messagesQuickReplyResponse: Messages with quick reply buttonsListMessageResponse: Interactive list menusCTAMessageResponse: Call-to-action messagesLocationResponse: Location-based messagesOrderDetailsResponse: Order information displays
Development
Prerequisites
- Python 3.9+
- Poetry
Setup
- Clone the repository:
git clone https://github.com/weni-ai/agents-toolkit.git
cd agents-toolkit
- Install dependencies:
poetry install
- Run tests:
poetry run pytest
Code Quality
We use several tools to ensure code quality:
pytestfor testingmypyfor type checkingrufffor linting
Run all checks:
poetry run pytest
poetry run mypy weni
poetry run ruff check .
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file weni_agents_toolkit-2.4.1a17.tar.gz.
File metadata
- Download URL: weni_agents_toolkit-2.4.1a17.tar.gz
- Upload date:
- Size: 27.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.5 CPython/3.13.12 Linux/6.14.0-1017-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
286674401a666a63be9381acf7097283f3fab17c51c0f30bea2af6fb0a4cad03
|
|
| MD5 |
2a3d222349decbb53e99309a381fcb85
|
|
| BLAKE2b-256 |
769ecdfb38629d3d3bab5e75f5b038a31a6ff20d00ef87515eafc0b452ec6534
|
File details
Details for the file weni_agents_toolkit-2.4.1a17-py3-none-any.whl.
File metadata
- Download URL: weni_agents_toolkit-2.4.1a17-py3-none-any.whl
- Upload date:
- Size: 35.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.5 CPython/3.13.12 Linux/6.14.0-1017-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0c099f153263dcae9bd947ce3172b2c2c3531a6408825b2bdef27a8e5b5762f
|
|
| MD5 |
aef63fe1a2a9a0ff34922312a6912536
|
|
| BLAKE2b-256 |
d62fcf163eb66cf435ed6f2b13fcbc06186f2f24767ebb4bc710a16bd0ff0e94
|