Modular tools library for AI agents on the Weni platform
Project description
Weni Tools
Modular tools library for AI agents on the Weni platform.
๐ฆ Installation
pip install weni-utils-tools
Note: The package name on PyPI is
weni-utils-tools(with hyphens), and you import it asweni_utils.tools:
- Install:
pip install weni-utils-tools- Import:
from weni_utils.tools import ...
๐ฏ Problem Solved
Before this library, each client had a complete copy of the agent code, resulting in:
- โ Duplicated code (70%+ identical between clients)
- โ Bug fix = N manual deploys
- โ Exponential maintenance
- โ Difficult onboarding of new clients
โ Solution
A centralized library with plugin system:
- โ Shared core (search, simulation, stock)
- โ Optional plugins (regionalization, carousel)
- โ Bug fix = 1 deploy, all updated
- โ New client = import and configure plugins
๐ Basic Usage
Modular Functions (Recommended)
from weni_utils.tools import search_products, get_region, simulate_cart
# Search products
products = search_products(
base_url_vtex="https://store.vtexcommercestable.com.br",
product_name="drill",
max_products=10
)
# Get region by postal code
region_id, error, sellers = get_region(
base_url_vtex="https://store.vtexcommercestable.com.br",
postal_code="01310-100"
)
# Simulate cart
result = simulate_cart(
base_url_vtex="https://store.vtexcommercestable.com.br",
items=[{"id": "61556", "quantity": 1, "seller": "1"}],
postal_code="01310-100"
)
Orchestration Class
from weni_utils.tools import ProductConcierge
concierge = ProductConcierge(
base_url_vtex="https://store.vtexcommercestable.com.br",
store_url_vtex="https://store.com.br"
)
result = concierge.search(product_name="drill")
๐ Available Plugins
Regionalization
For clients with postal code-based regionalization.
from weni_utils.tools import ProductConcierge
from weni_utils.tools.plugins import Regionalization
concierge = ProductConcierge(
base_url_vtex="...",
store_url_vtex="...",
plugins=[
Regionalization()
]
)
result = concierge.search(
product_name="cement",
postal_code="01310-100"
)
Carousel
For sending products via WhatsApp carousel.
from weni_utils.tools.plugins import Carousel
concierge = ProductConcierge(
plugins=[
Carousel(
weni_token="your-token",
max_items=10,
auto_send=True
)
]
)
result = concierge.search(
product_name="shirt",
contact_info={"urn": "whatsapp:5511999999999"}
)
CAPI (Meta Conversions API)
For sending conversion events to Meta.
from weni_utils.tools.plugins import CAPI
concierge = ProductConcierge(
plugins=[
CAPI(event_type="lead", auto_send=True)
]
)
WeniFlowTrigger
For triggering Weni flows.
from weni_utils.tools.plugins import WeniFlowTrigger
concierge = ProductConcierge(
plugins=[
WeniFlowTrigger(
flow_uuid="flow-uuid",
trigger_once=True
)
]
)
๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ProductConcierge โ
โ (Orchestrates entire flow) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโ
โ โ โ
โผ โผ โผ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ VTEXClient โ โ StockManager โ โ Plugins โ
โ โ โ โ โ โ
โ โข search() โ โ โข check() โ โ โข before_search โ
โ โข simulate() โ โ โข filter() โ โ โข after_search โ
โ โข get_region() โ โ โข limit_size() โ โ โข enrich() โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
๐ Execution Flow
- before_search - Plugins modify context (e.g., get region_id)
- intelligent_search - Search products in VTEX
- after_search - Plugins filter/modify products
- check_availability - Verify stock
- filter_products - Filter only products with stock
- enrich_products - Plugins add extra data
- finalize_result - Plugins perform final actions (e.g., send events)
๐ค Creating a New Plugin
from weni_utils.tools.plugins import PluginBase
class MyPlugin(PluginBase):
name = "my_plugin"
def before_search(self, context, client):
# Modify context before search
return context
def after_search(self, products, context, client):
# Modify products after search
return products
def after_stock_check(self, products_with_stock, context, client):
# Enrich products after stock check
return products_with_stock
def finalize_result(self, result, context):
# Final modification before return
return result
๐ License
MIT License - Weni AI
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_utils_tools-0.0.2.tar.gz.
File metadata
- Download URL: weni_utils_tools-0.0.2.tar.gz
- Upload date:
- Size: 49.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57b449868f071a679331198942336cc4d3e7f0d58d48644c7bb756512dc1d61d
|
|
| MD5 |
7ed04bbe747e7b5743c163d9a1193b0c
|
|
| BLAKE2b-256 |
44756104d36a4c8a9ab163f602dd758d05baedc5a5ed8c0824e5db71bdd9c4e4
|
File details
Details for the file weni_utils_tools-0.0.2-py3-none-any.whl.
File metadata
- Download URL: weni_utils_tools-0.0.2-py3-none-any.whl
- Upload date:
- Size: 46.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
797f48fadbb706e8da9e878bcb634233d5597fd58e52a7aed4de68d1bc656626
|
|
| MD5 |
0b4411b961a969972b91305199d66459
|
|
| BLAKE2b-256 |
8872885b6c2f2a7ff13815815017899f1d551c9bca257a3642f7a0f9508b4243
|