Skip to main content

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 as weni_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

  1. before_search - Plugins modify context (e.g., get region_id)
  2. intelligent_search - Search products in VTEX
  3. after_search - Plugins filter/modify products
  4. check_availability - Verify stock
  5. filter_products - Filter only products with stock
  6. enrich_products - Plugins add extra data
  7. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

weni_utils_tools-0.0.2.tar.gz (49.5 kB view details)

Uploaded Source

Built Distribution

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

weni_utils_tools-0.0.2-py3-none-any.whl (46.6 kB view details)

Uploaded Python 3

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

Hashes for weni_utils_tools-0.0.2.tar.gz
Algorithm Hash digest
SHA256 57b449868f071a679331198942336cc4d3e7f0d58d48644c7bb756512dc1d61d
MD5 7ed04bbe747e7b5743c163d9a1193b0c
BLAKE2b-256 44756104d36a4c8a9ab163f602dd758d05baedc5a5ed8c0824e5db71bdd9c4e4

See more details on using hashes here.

File details

Details for the file weni_utils_tools-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for weni_utils_tools-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 797f48fadbb706e8da9e878bcb634233d5597fd58e52a7aed4de68d1bc656626
MD5 0b4411b961a969972b91305199d66459
BLAKE2b-256 8872885b6c2f2a7ff13815815017899f1d551c9bca257a3642f7a0f9508b4243

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