Ionic은 AI Assistant를 위한 플러그 앤 플레이 전자상거래 마켓플레이스입니다. agent에 Ionic Tool을 포함시키면, 사용자가 agent 내에서 직접 쇼핑하고 거래할 수 있는 기능을 손쉽게 제공할 수 있으며, 거래 수수료의 일부를 받을 수 있습니다. 이것은 Ionic Tool을 agent에 통합하는 방법을 보여주는 기본 jupyter notebook입니다. Ionic으로 Agent를 설정하는 방법에 대한 자세한 내용은 Ionic 문서를 참조하세요. 이 Jupyter Notebook은 Agent와 함께 Ionic tool을 사용하는 방법을 보여줍니다. 참고: ionic-langchain package는 LangChain 유지관리자가 아닌 Ionic Commerce 팀에서 유지관리합니다.

Setup

pip install langchain langchain_openai langchainhub
pip install ionic-langchain

Agent 설정

from ionic_langchain.tool import Ionic, IonicTool
from langchain_classic import hub
from langchain.agents import AgentExecutor, Tool, create_agent
from langchain_openai import OpenAI

# Based on ReAct Agent
# https://python.langchain.com/docs/modules/agents/agent_types/react
# See the paper "ReAct: Synergizing Reasoning and Acting in Language Models" (https://arxiv.org/abs/2210.03629)
# Please reach out to [email protected] for help with add'l agent types.

open_ai_key = "YOUR KEY HERE"
model = "gpt-3.5-turbo-instruct"
temperature = 0.6

llm = OpenAI(openai_api_key=open_ai_key, model_name=model, temperature=temperature)


ionic_tool = IonicTool().tool()


# The tool comes with its own prompt,
# but you may also update it directly via the description attribute:

ionic_tool.description = str(
    """
Ionic is an e-commerce shopping tool. Assistant uses the Ionic Commerce Shopping Tool to find, discover, and compare products from thousands of online retailers. Assistant should use the tool when the user is looking for a product recommendation or trying to find a specific product.

The user may specify the number of results, minimum price, and maximum price for which they want to see results.
Ionic Tool input is a comma-separated string of values:
  - query string (required, must not include commas)
  - number of results (default to 4, no more than 10)
  - minimum price in cents ($5 becomes 500)
  - maximum price in cents
For example, if looking for coffee beans between 5 and 10 dollars, the tool input would be `coffee beans, 5, 500, 1000`.

Return them as a markdown formatted list with each recommendation from tool results, being sure to include the full PDP URL. For example:

1. Product 1: [Price] -- link
2. Product 2: [Price] -- link
3. Product 3: [Price] -- link
4. Product 4: [Price] -- link
"""
)

tools = [ionic_tool]

# default prompt for create_agent
prompt = hub.pull("hwchase17/react")

agent = create_agent(
    llm,
    tools,
    prompt=prompt,
)

agent_executor = AgentExecutor(
    agent=agent, tools=tools, handle_parsing_errors=True, verbose=True, max_iterations=5
)

실행

input = (
    "I'm looking for a new 4k monitor can you find me some options for less than $1000"
)
agent_executor.invoke({"input": input})

Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I