Skip to main content

Superagentx-Examples

Python 3.10+ GitHub Repo stars License: MIT

Getting Started

pip install superagentx-examples
Usage - Example SuperAgentX Code

This SuperAgentX example utilizes two handlers, Amazon and Walmart, to search for product items based on user input from the IO Console.

  1. It uses Parallel execution of handler in the agent
  2. Memory Context Enabled
  3. LLM configured to OpenAI
  4. Pre-requisites

Set OpenAI Key:

export OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxx

Set Rapid API Key Free Subscription for Amazon, Walmart Search APIs

export RAPID_API_KEY=XXXXXXXXXXXXXXXXXXXXXXXXX
# Additional lib needs to install
# python3 superagentx_examples/ecom_iopipe.py

import asyncio

from rich import print as rprint
from superagentx.agent import Agent
from superagentx.agentxpipe import AgentXPipe
from superagentx.engine import Engine
from superagentx.llm import LLMClient
from superagentx.memory import Memory
from superagentx.pipeimpl.iopipe import IOPipe
from superagentx.prompt import PromptTemplate

from superagentx_handlers.ecommerce.amazon import AmazonHandler
from superagentx_handlers.ecommerce.walmart import WalmartHandler


async def main():
    """
    Launches the e-commerce pipeline console client for processing requests and handling data.
    """

    # LLM Configuration
    llm_config = {'llm_type': 'openai'}
    llm_client: LLMClient = LLMClient(llm_config=llm_config)

    # Enable Memory
    memory = Memory(memory_config={"llm_client": llm_client})

    # Add Two Handlers (Tools) - Amazon, Walmart
    amazon_ecom_handler = AmazonHandler()
    walmart_ecom_handler = WalmartHandler()

    # Prompt Template
    prompt_template = PromptTemplate()

    # Amazon & Walmart Engine to execute handlers
    amazon_engine = Engine(
        handler=amazon_ecom_handler,
        llm=llm_client,
        prompt_template=prompt_template
    )
    walmart_engine = Engine(
        handler=walmart_ecom_handler,
        llm=llm_client,
        prompt_template=prompt_template
    )

    # Create Agent with Amazon, Walmart Engines execute in Parallel - Search Products from user prompts
    ecom_agent = Agent(
        name='Ecom Agent',
        goal="Get me the best search results",
        role="You are the best product searcher",
        llm=llm_client,
        prompt_template=prompt_template,
        engines=[[amazon_engine, walmart_engine]]
    )

    # Pipe Interface to send it to public accessible interface (Cli Console / WebSocket / Restful API)
    pipe = AgentXPipe(
        agents=[ecom_agent],
        memory=memory
    )

    # Create IO Cli Console - Interface
    io_pipe = IOPipe(
        search_name='SuperAgentX Ecom',
        agentx_pipe=pipe,
        read_prompt=f"\n[bold green]Enter your search here"
    )
    await io_pipe.start()


if __name__ == '__main__':
    try:
        asyncio.run(main())
    except (KeyboardInterrupt, asyncio.CancelledError):
        rprint("\nUser canceled the [bold yellow][i]pipe[/i]!")
Usage - Example SuperAgentX Result

SuperAgentX searches for product items requested by the user in the console, validates them against the set goal, and returns the result. It retains the context, allowing it to respond to the user's next prompt in the IO Console intelligently.

Output

Metadata

Release files for superagentx-examples 0.1.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for superagentx-examples 0.1.3.1
File Size Uploaded Provenance Actions
superagentx_examples-0.1.3.1.tar.gz 4.8 MB Without provenance Details for superagentx_examples-0.1.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for superagentx-examples 0.1.3.1
File Interpreter ABI Platform Actions
superagentx_examples-0.1.3.1-py3-none-any.whl Python 3 none any Details for superagentx_examples-0.1.3.1-py3-none-any.whl

Total release size: 9.6 MB

Release files / superagentx_examples-0.1.3.1.tar.gz

Download URL superagentx_examples-0.1.3.1.tar.gz
Size 4.8 MB
Tags Source
SHA-256 checksum
How to use checksums
0d7d891ca24769a49fc65775dcef5410bef2cc7af7485c387b56365be56a3798
BLAKE2b-256 checksum
How to use checksums
6d7df232ce3a800b6eabfcbb769df3ab7ad139748b52ea4b94011251d3ef1767
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.12.10 Darwin/24.4.0

Release files / superagentx_examples-0.1.3.1-py3-none-any.whl

Download URL superagentx_examples-0.1.3.1-py3-none-any.whl
Size 4.8 MB
Tags Python 3
SHA-256 checksum
How to use checksums
feb2dc301db4d69b0c8dca75fba3eaa5292ed872a6dfdddebe00e0fcb22b3087
BLAKE2b-256 checksum
How to use checksums
241b20db20125ec79e06a94493462b2f35fab66cb28b36932e5f34da435b79b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.12.10 Darwin/24.4.0

Security for superagentx-examples 0.1.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page