Skip to main content

No project description provided

Project description


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

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

superagentx_examples-0.1.3.tar.gz (4.8 MB view details)

Uploaded Source

Built Distribution

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

superagentx_examples-0.1.3-py3-none-any.whl (4.8 MB view details)

Uploaded Python 3

File details

Details for the file superagentx_examples-0.1.3.tar.gz.

File metadata

  • Download URL: superagentx_examples-0.1.3.tar.gz
  • Upload date:
  • Size: 4.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.8 Darwin/24.3.0

File hashes

Hashes for superagentx_examples-0.1.3.tar.gz
Algorithm Hash digest
SHA256 006e035a446702f810bd196091f4fefa3f481f8b8d266b46b65e4feb303b8cb0
MD5 5b4a268bbce3b404a2d2b775a00c972c
BLAKE2b-256 0cf5fbc6efbcba0f36e59f89410b3cc0ad86931e78e7d7cc92f8979197cce37b

See more details on using hashes here.

File details

Details for the file superagentx_examples-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for superagentx_examples-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3f4f23ff352ebf80f1d3a84d1de7b8e7184953d070915ec8c46759dd7eaf3681
MD5 cb52a8c1cc7c024b1e8069d21cdf7649
BLAKE2b-256 4aafb5c676d72750baec54a75c20eeb2ed79d2dd858995599c464e3d14afc447

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