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.3.tar.gz (53.3 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.3-py3-none-any.whl (46.6 kB view details)

Uploaded Python 3

File details

Details for the file weni_utils_tools-0.0.3.tar.gz.

File metadata

  • Download URL: weni_utils_tools-0.0.3.tar.gz
  • Upload date:
  • Size: 53.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for weni_utils_tools-0.0.3.tar.gz
Algorithm Hash digest
SHA256 af9e9069e1abd6a911f513a25c1552160b63cafcdbd230fd9ff0f1f17de60741
MD5 25f2704e1c41cfcfc154150ab07b152d
BLAKE2b-256 c9229f42deae774b0be0f6df444c1dc5b77d221411e8415ebdc81796970fd77b

See more details on using hashes here.

Provenance

The following attestation bundles were made for weni_utils_tools-0.0.3.tar.gz:

Publisher: publish.yml on weni-ai/weni-utils-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for weni_utils_tools-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ae1584ca30777868c513ce12808249c077a89d188f2f2291474702929ebddd2f
MD5 5e4061c25d925789b7dce720c64dce23
BLAKE2b-256 a1dc233721679f47428eb15a4d75e4f7d4517d43d8c7b5cfbeccbdc6f6e3ad62

See more details on using hashes here.

Provenance

The following attestation bundles were made for weni_utils_tools-0.0.3-py3-none-any.whl:

Publisher: publish.yml on weni-ai/weni-utils-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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