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, wholesale, 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="https://store.vtexcommercestable.com.br",
    product_name="drill",
    max_products=10
)

# Get region by postal code
region_id, error, sellers = get_region(
    base_url="https://store.vtexcommercestable.com.br",
    postal_code="01310-100"
)

# Simulate cart
result = simulate_cart(
    base_url="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="https://store.vtexcommercestable.com.br",
    store_url="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="...",
    store_url="...",
    plugins=[
        Regionalization()
    ]
)

result = concierge.search(
    product_name="cement",
    postal_code="01310-100"
)

Wholesale

For clients with wholesale pricing.

from weni_utils.tools.plugins import Wholesale

concierge = ProductConcierge(
    plugins=[
        Wholesale(fixed_price_url="https://store.com.br/fixedprices")
    ]
)

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. after_stock_check - Plugins enrich (e.g., wholesale prices)
  6. filter_products - Filter only products with stock
  7. enrich_products - Plugins add extra data
  8. 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.1.tar.gz (39.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.1-py3-none-any.whl (43.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: weni_utils_tools-0.0.1.tar.gz
  • Upload date:
  • Size: 39.3 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.1.tar.gz
Algorithm Hash digest
SHA256 bd269a6952dfc5628f4baa562e1684ad2fb82a9a7fa694004feee89736910a72
MD5 e8367709aeaa4136b514f07019a9531a
BLAKE2b-256 07f5747aa23bb57aa06ab5149cae6bd2d4567bb56813b93756c90c5b70d2e643

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for weni_utils_tools-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b388fe826aaf832e6369e5c9486ea9925b97474f6bd47c16085f17cb5f41d804
MD5 cbcb9d6db031d34e30bb7fb8e1d2f1e4
BLAKE2b-256 089f159930186e49e95290ce39886708d04b81017e3804e86a46cf8a2b2e7fa6

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