Back to Llama Index

Ionic Shopping Tool

llama-index-integrations/tools/llama-index-tools-ionic-shopping/examples/ionic_shopping.ipynb

0.14.211.5 KB
Original Source

Ionic Shopping Tool

Ionic is a plug and play ecommerce marketplace for AI Assistants. By using Ionic, you are effortlessly providing your users with the ability to shop and transact directly within your agent, and you'll get a cut of the transaction.

This is a basic jupyter notebook demonstrating how to integrate the Ionic Shopping Tool. For more information on setting up your Agent with Ionic, see the Ionic documentation.

This Jupyter Notebook demonstrates how to use the Ionic tool with an Agent.


Setup the Tool

First, let's install our dependencies

python
!pip install llama-index llama-hub ionic-api-sdk

Configure OpenAI

python
import os

os.environ["OPENAI_API_KEY"] = "sk-api-key"

from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI

Import and configure the Ionic Shopping Tool

python
from llama_hub.tools.ionic_shopping.base import IonicShoppingToolSpec

# optionally add you Ionic API Key
# IonicShoppingToolSpec(api_key="<my Ionic API Key>")
ionic_tool = IonicShoppingToolSpec().to_tool_list()

for tool in ionic_tool:
    print(tool.metadata.name)

Use Ionic

python
agent = FunctionAgent(
    tools=ionic_tool,
    llm=OpenAI(model="gpt-4.1"),
)
python
print(
    await agent.run(
        "I'm looking for a 5k monitor can you find me 3 options between $600 and $1000"
    )
)