Documentation
Feedback
Guides
API Reference

Guides
Guides
Weni by VTEX
Weni by VTEX CLI

Using the Weni by VTEX CLI

Learn how to use Weni by VTEX CLI

This guide will walk you through using the Weni by VTEX CLI to create, deploy, and manage AI-powered agents, enhancing your customer service capabilities. By the end of this guide, you will be able to install the CLI, configure your project, and deploy your first agent.

With the CLI, you can:

  • Create, deploy, and manage multiple AI agents
  • Add custom tools to the agents
  • Update agent configuration and behavior

To use the Weni by VTEX CLI, you must have: a Weni by VTEX Platform account; an account at weni.ai; and at least one project in your account.

The content is organized as follows:

Step 1 - Installing the CLI

There are two installation methods:

Install via pip

To install the CLI using pip, open the terminal and run the following command:


_10
pip install weni-cli

Install via Poetry

To install the CLI manually, follow these steps:

  1. Clone the repository by running the following command:

_10
git clone https://github.com/weni-ai/weni-cli.git
_10
cd weni-cli

  1. Install dependencies and make the CLI executable by running the following command:

_10
poetry shell
_10
poetry install

Step 2 - Verifying Installation

To verify that Weni by VTEX CLI is installed, type the following command in your terminal:


_10
weni

If the installation was successful, your terminal should display something like this:

An error occurred while loading the image https://github.com/vtexdocs/dev-portal-content/main/docs/guides/Weni-by-VTEX/CLI/assets/weni-installation-verification.png

Troubleshooting

If you encounter any issues:

  1. Check our GitHub Issues
  2. Create a new issue with:
    • Your operating system
    • Python version (python --version)
    • Error message
    • Steps to reproduce

Getting started with your project

Step 1 - Log in to your Weni by VTEX account

  1. Open the terminal and run the following command:

_10
weni login

This should open your browser on the login page for authentication. If that does not happen, you can open the URL shown in the terminal.

  1. Log in using your Weni by VTEX account and password.

Step 2 - List your projects

List your projects by running the following command:


_10
weni project list

This will show all projects you have access to and, next to each of them, its universally unique identifier (UUID).

Step 3 - Select a project

Select the project you want to work on by running the following command:


_10
weni project use your-project-uuid

Replace your-project-uuid with the UUID from the project list.

Step 4 - Verify the current project

To verify you're working on the correct project, you can run the following command:


_10
weni project current

You will see the project's UUID in the terminal output.

Step 5 - Initialize a new agent

To create an agent, run the following command:


_10
weni init

This command performs the following actions:

  • Creates the necessary folder structure for your agent.
  • Sets up a pre-built CEP (Complex Event Processing) tool.
  • Creates an agent_definition.yaml file with the initial configuration. You can edit this file to customize your agent's behavior.

_21
agents:
_21
sample_agent:
_21
name: "CEP Agent"
_21
description: "Weni's CEP agent"
_21
instructions:
_21
- "You are an expert in providing addresses to the user based on a postal code provided by the user"
_21
- "The user will send a ZIP code (postal code) and you must provide the address corresponding to this code."
_21
guardrails:
_21
- "Don't talk about politics, religion, or any other sensitive topic. Keep it neutral."
_21
tools:
_21
- get_address:
_21
name: "Get Address"
_21
source:
_21
path: "tools/get_address"
_21
entrypoint: "main.GetAddress"
_21
description: "Function to get the address from the postal code"
_21
parameters:
_21
- cep:
_21
description: "postal code"
_21
type: "string"
_21
required: true

Understanding the source configuration

In the YAML above, there are two fields nested within the source field:

  • path: This field specifies the directory containing your tool implementation.

    • The command automatically creates a tools directory and a folder called get_address nested within it.
    • In this path, you can find the files main.py, requirements.txt, and test_definition.yaml.
  • entrypoint: This field informs the system which class to use.

    • Using main.GetAddress indicates that the system finds the file named main.py, uses the GetAddress class inside the file and that the class must inherit from the Tools base class.

Your project structure should look like this:


_10
my-agent-project/
_10
├── agent_definition.yaml
_10
└── tools/
_10
└── get_address/
_10
├── main.py # Contains GetAddress class
_10
└── requirements.txt # Dependencies

Step 6 - Implement the tool manually (if weni init fails)

If the command doesn't work, you can implement this tool manually following the next steps:

  1. Create the tool directory

_10
mkdir -p tools/get_address
_10
cd tools/get_address

  1. Create the file tools/get_address/main.py and insert the following:

_16
from weni import Tool
_16
from weni.context import Context
_16
from weni.responses import TextResponse
_16
import requests
_16
_16
_16
class GetAddress(Tool):
_16
def execute(self, context: Context) -> TextResponse:
_16
cep = context.parameters.get("cep", "")
_16
address_response = self.get_address_by_cep(cep=cep)
_16
return TextResponse(data=address_response)
_16
_16
def get_address_by_cep(self, cep):
_16
url = f"https://viacep.com.br/ws/{cep}/json/"
_16
response = requests.get(url)
_16
return response.json()

  • The class name GetAddress must match the class name in the entrypoint
  • The file name main.py must match the file name in the entrypoint
  • The class must inherit from Tool and implement the execute method
  1. Create the requirements.txt file

_10
requests==2.32.3

Step 7 - Add credentials and global files (optional)

If you have credentials and global files, place these files in tools/get_address during local runs:


_10
# .env
_10
api_key=your-development-api-key


_10
# .globals
_10
BASE_URL=https://api.example.com

Step 7 - Deploy the agent

Deploy your agent by running the following command:


_10
weni project push agent_definition.yaml

Advanced Configuration

Custom Parameters

You can add more parameters to your tools:


_10
parameters:
_10
- format:
_10
description: "Response format (json or text)"
_10
type: "string"
_10
required: false
_10
default: "json"

Multiple Tools

Agents can have multiple tools:


_10
tools:
_10
- get_address:
_10
# tool definition
_10
- validate_cep:
_10
# another tool definition

Contributing to Weni by VTEX CLI

This guide will help you get started with contributing to the project.

Development Setup

Prerequisites

  • Python >= 3.12
  • Poetry >= 1.8.5
  • Git

Setting Up Development Environment

  1. Fork the repository on GitHub

  2. Clone your fork:


    _10
    git clone https://github.com/YOUR_USERNAME/weni-cli.git
    _10
    cd weni-cli

  3. Install dependencies:


    _10
    poetry install

  4. Create a new branch:


    _10
    git checkout -b feature/your-feature-name

Development Guidelines

Code Style

  • Follow PEP 8 guidelines
  • Use meaningful variable and function names
  • Add docstrings to functions and classes
  • Keep functions focused and concise

Testing

  1. Write tests for new features:


    _10
    def test_your_feature():
    _10
    # Your test code here
    _10
    assert expected == actual

  2. Run tests:


    _10
    poetry run pytest

  3. Check coverage:


    _10
    poetry run pytest --cov

Documentation

  1. Update documentation for new features
  2. Add docstrings to new functions
  3. Update README.md if needed
  4. Add examples when relevant

Making Changes

Workflow

  1. Create a feature branch
  2. Make your changes
  3. Write or update tests
  4. Update documentation
  5. Run tests locally
  6. Commit your changes
  7. Push to your fork
  8. Create a Pull Request

Commit Messages

Follow conventional commits:

  • feat: New features
  • fix: Bug fixes
  • docs: Documentation changes
  • test: Adding or updating tests
  • chore: Maintenance tasks

Example:


_10
git commit -m "feat: add support for custom headers in requests"

Pull Requests

PR Guidelines

  1. Create one PR per feature/fix
  2. Include tests
  3. Update documentation
  4. Reference issues if applicable
  5. Keep changes focused and minimal

PR Template


_14
### Description
_14
Brief description of changes
_14
_14
### Type of Change
_14
- [ ] Bug fix
_14
- [ ] New feature
_14
- [ ] Documentation update
_14
- [ ] Other (specify)
_14
_14
### Testing
_14
Describe testing done
_14
_14
### Documentation
_14
List documentation updates

Review Process

  1. Automated checks must pass
  2. Code review by maintainers
  3. Documentation review
  4. Changes requested if needed
  5. Approval and merge

Getting Help

  • Create an issue for bugs
  • Ask questions in discussions
  • Join our community channels

Development Tools

Recommended VSCode Extensions

  • Python
  • YAML
  • markdownlint
  • GitLens

Useful Commands


_11
# Format code
_11
poetry run black .
_11
_11
# Run linter
_11
poetry run flake8
_11
_11
# Run tests
_11
poetry run pytest
_11
_11
# Build documentation
_11
poetry run mkdocs serve

Release Process

  1. Version bump
  2. Update CHANGELOG
  3. Create release PR
  4. Tag release
  5. Deploy to PyPI

Community

  • Be respectful and inclusive
  • Help others when possible
  • Share knowledge
  • Follow our Code of Conduct
Contributors
1
Photo of the contributor
Was this helpful?
Yes
No
Suggest Edits (GitHub)
See also
Contributors
1
Photo of the contributor
Was this helpful?
Suggest edits (GitHub)
On this page