superagentx-examples


Namesuperagentx-examples JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://www.superagentx.ai/
SummaryNone
upload_time2024-10-22 12:58:49
maintainerSuperAgentX AI
docs_urlNone
authorSuperAgentX AI
requires_python<=3.13,>=3.10
licenseNone
keywords superagentx agi agentic ai asi superagentx superagentx-examples agent llm
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">

<img src="https://github.com/superagentxai/superagentX/blob/master/docs/images/fulllogo_transparent.png?raw=True" width="350">


<br/>


**Superagentx-Examples**

[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/release/python-3100/)
[![GitHub Repo stars](https://img.shields.io/github/stars/superagentxai/superagentX-examples)](https://github.com/superagentxai/superagentX-examples)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/superagentxai/superagentX-examples/blob/master/LICENSE)
</div>

### Getting Started

```shell
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:  
```shell
export OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxx
```

Set Rapid API Key <a href="https://rapidapi.com/auth/sign-up" target="_blank">Free Subscription</a> for Amazon, Walmart Search APIs
```shell
export RAPID_API_KEY=XXXXXXXXXXXXXXXXXXXXXXXXX
```

```python 
# 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()

    # 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](https://github.com/superagentxai/superagentX/blob/master/docs/images/examples/ecom-output-console.png?raw=True)

            

Raw data

            {
    "_id": null,
    "home_page": "https://www.superagentx.ai/",
    "name": "superagentx-examples",
    "maintainer": "SuperAgentX AI",
    "docs_url": null,
    "requires_python": "<=3.13,>=3.10",
    "maintainer_email": "support@superagentx.ai",
    "keywords": "superagentX, AGI, Agentic AI, ASI, superagentx, superagentx-examples, agent, LLM",
    "author": "SuperAgentX AI",
    "author_email": "support@superagentx.ai",
    "download_url": "https://files.pythonhosted.org/packages/e9/8d/1a19f885e1355605a62b7ebb96050eb64babec6be625e8c3efa31884272b/superagentx_examples-0.1.1.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\n\n<img src=\"https://github.com/superagentxai/superagentX/blob/master/docs/images/fulllogo_transparent.png?raw=True\" width=\"350\">\n\n\n<br/>\n\n\n**Superagentx-Examples**\n\n[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/release/python-3100/)\n[![GitHub Repo stars](https://img.shields.io/github/stars/superagentxai/superagentX-examples)](https://github.com/superagentxai/superagentX-examples)\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/superagentxai/superagentX-examples/blob/master/LICENSE)\n</div>\n\n### Getting Started\n\n```shell\npip install superagentx-examples\n```\n##### Usage - Example SuperAgentX Code\nThis SuperAgentX example utilizes two handlers, Amazon and Walmart, to search for product items based on user input from the IO Console.\n\n1. It uses Parallel execution of handler in the agent \n2. Memory Context Enabled\n3. LLM configured to OpenAI\n4. Pre-requisites\n\nSet OpenAI Key:  \n```shell\nexport OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxx\n```\n\nSet Rapid API Key <a href=\"https://rapidapi.com/auth/sign-up\" target=\"_blank\">Free Subscription</a> for Amazon, Walmart Search APIs\n```shell\nexport RAPID_API_KEY=XXXXXXXXXXXXXXXXXXXXXXXXX\n```\n\n```python \n# Additional lib needs to install\n# python3 superagentx_examples/ecom_iopipe.py\n\nimport asyncio\n\nfrom rich import print as rprint\nfrom superagentx.agent import Agent\nfrom superagentx.agentxpipe import AgentXPipe\nfrom superagentx.engine import Engine\nfrom superagentx.llm import LLMClient\nfrom superagentx.memory import Memory\nfrom superagentx.pipeimpl.iopipe import IOPipe\nfrom superagentx.prompt import PromptTemplate\n\nfrom superagentx_handlers.ecommerce.amazon import AmazonHandler\nfrom superagentx_handlers.ecommerce.walmart import WalmartHandler\n\n\nasync def main():\n    \"\"\"\n    Launches the e-commerce pipeline console client for processing requests and handling data.\n    \"\"\"\n\n    # LLM Configuration\n    llm_config = {'llm_type': 'openai'}\n    llm_client: LLMClient = LLMClient(llm_config=llm_config)\n\n    # Enable Memory\n    memory = Memory()\n\n    # Add Two Handlers (Tools) - Amazon, Walmart\n    amazon_ecom_handler = AmazonHandler()\n    walmart_ecom_handler = WalmartHandler()\n\n    # Prompt Template\n    prompt_template = PromptTemplate()\n\n    # Amazon & Walmart Engine to execute handlers\n    amazon_engine = Engine(\n        handler=amazon_ecom_handler,\n        llm=llm_client,\n        prompt_template=prompt_template\n    )\n    walmart_engine = Engine(\n        handler=walmart_ecom_handler,\n        llm=llm_client,\n        prompt_template=prompt_template\n    )\n\n    # Create Agent with Amazon, Walmart Engines execute in Parallel - Search Products from user prompts\n    ecom_agent = Agent(\n        name='Ecom Agent',\n        goal=\"Get me the best search results\",\n        role=\"You are the best product searcher\",\n        llm=llm_client,\n        prompt_template=prompt_template,\n        engines=[[amazon_engine, walmart_engine]]\n    )\n\n    # Pipe Interface to send it to public accessible interface (Cli Console / WebSocket / Restful API)\n    pipe = AgentXPipe(\n        agents=[ecom_agent],\n        memory=memory\n    )\n\n    # Create IO Cli Console - Interface\n    io_pipe = IOPipe(\n        search_name='SuperAgentX Ecom',\n        agentx_pipe=pipe,\n        read_prompt=f\"\\n[bold green]Enter your search here\"\n    )\n    await io_pipe.start()\n\n\nif __name__ == '__main__':\n    try:\n        asyncio.run(main())\n    except (KeyboardInterrupt, asyncio.CancelledError):\n        rprint(\"\\nUser canceled the [bold yellow][i]pipe[/i]!\")\n\n```\n##### Usage - Example SuperAgentX Result\nSuperAgentX 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. \n\n![Output](https://github.com/superagentxai/superagentX/blob/master/docs/images/examples/ecom-output-console.png?raw=True)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": null,
    "version": "0.1.1",
    "project_urls": {
        "Documentation": "https://docs.superagentx.ai/",
        "Homepage": "https://www.superagentx.ai/",
        "Repository": "https://github.com/superagentxai/superagentx-examples"
    },
    "split_keywords": [
        "superagentx",
        " agi",
        " agentic ai",
        " asi",
        " superagentx",
        " superagentx-examples",
        " agent",
        " llm"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1f7d1ca5aadd3223e8e6a531ec2d3ebdfb59bee852dc3c73ae677cc49d34e64b",
                "md5": "3fa1bccb4fcfb91c074e0be445afa512",
                "sha256": "785ebd7881cdf294a1d8da5a422a9d5c1a167591a33c1d0afe7eb7ccbe84c308"
            },
            "downloads": -1,
            "filename": "superagentx_examples-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3fa1bccb4fcfb91c074e0be445afa512",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<=3.13,>=3.10",
            "size": 6303,
            "upload_time": "2024-10-22T12:58:47",
            "upload_time_iso_8601": "2024-10-22T12:58:47.894845Z",
            "url": "https://files.pythonhosted.org/packages/1f/7d/1ca5aadd3223e8e6a531ec2d3ebdfb59bee852dc3c73ae677cc49d34e64b/superagentx_examples-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e98d1a19f885e1355605a62b7ebb96050eb64babec6be625e8c3efa31884272b",
                "md5": "ae1cb6d6001a03f65233c93d0c83ec18",
                "sha256": "ca3cd683e1a952407071a7db34fd56f351c8dfc4b45ac5825e6ca5755d020759"
            },
            "downloads": -1,
            "filename": "superagentx_examples-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "ae1cb6d6001a03f65233c93d0c83ec18",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<=3.13,>=3.10",
            "size": 3906,
            "upload_time": "2024-10-22T12:58:49",
            "upload_time_iso_8601": "2024-10-22T12:58:49.003393Z",
            "url": "https://files.pythonhosted.org/packages/e9/8d/1a19f885e1355605a62b7ebb96050eb64babec6be625e8c3efa31884272b/superagentx_examples-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-22 12:58:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "superagentxai",
    "github_project": "superagentx-examples",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "superagentx-examples"
}
        
Elapsed time: 0.40926s