No project description provided
Project description
Getting Started
pip install superagentx-handlers
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.
- It uses Parallel execution of handler in the agent
- Memory Context Enabled
- LLM configured to OpenAI
- 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
# pip install superagentx
# 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()
# 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file superagentx_handlers-0.1.1.tar.gz
.
File metadata
- Download URL: superagentx_handlers-0.1.1.tar.gz
- Upload date:
- Size: 26.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.6 Darwin/24.0.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff8a55cb1e9de0055f13454f018f812e5e761f469f9774a7df5b77fdfc956937 |
|
MD5 | 47d253d242ce3b67f4efe349a106af8f |
|
BLAKE2b-256 | 2b706f98d32c0083292d43f38469d9c4e81072ebc1d2d3896beaf1a6a7b4a6b6 |
File details
Details for the file superagentx_handlers-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: superagentx_handlers-0.1.1-py3-none-any.whl
- Upload date:
- Size: 36.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.6 Darwin/24.0.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 121969ab2f838d60d4313a0655c32668ed9d18d946bc2e2c6aeee96f6ad97acd |
|
MD5 | b3aa075d5f4575bb8eef2fdf8a8153ce |
|
BLAKE2b-256 | 9074f8dc12084d244c1e62721ff50b74780a2462702f1578ea0d6869f6dd3cbf |