Ionic Langchain
Ionic Langchain provides a wrapper around the Ionic Commerce's SDK for use as a Tool in a custom Langchain agent. This tool will enable e-commerce for your agent, allowing your users to ask for product recommendations and purchase products through the agent chat interface.
Installation
This tool requires at least langchain@0.0.350 and can work with any greater patch release the 0.0.x series.
We currently support python 3.8.10 and above, but if you need support for a lower version, please open an issue and we will add support.
You can install the package from PyPI using pip:
python3 -m pip install ionic-langchain
or poetry:
poetry add ionic-langchain
Usage
import os
from typing import List
from ionic_langchain.tool import IonicTool
from langchain.agents import AgentType, Tool
from langchain.agents import initialize_agent
from langchain.chat_models import ChatOpenAI
tools = [
IonicTool().tool(),
# your other tools,
]
agent = initialize_agent(
tools=tools,
llm=ChatOpenAI(openai_api_key="your_key_here", temperature=0.7),
agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION,
handle_parsing_errors=True,
verbose=True,
)
input = "Where can I get tide pods"
agent.run(input=input)
Please see the langchain agent docs for more details on how to build and run agents
Customizing the SDK
ionic_langchain.tool.IonicTool's constructor accepts an instance of ionic_langchain.tool.Ionic, a wrapper around our SDK. ionic_langchain.tool.Ionic, in turn accepts an instance of that SDK, so you can provide the tool with a custom configuration:
import os
from ionic.sdk import Ionic as IonicSDK
from ionic_langchain.tool import Ionic, IonicTool
sdk = IonicSDK(api_key_header=os.environ.get("IONIC_API_KEY"))
ionic = Ionic(sdk=sdk)
tool = IonicTool(ionic=ionic).tool()
Development
Coming soon. Please feel free to open an issue.
Release files for ionic-langchain 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ionic_langchain-0.2.3.tar.gz | 3.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ionic_langchain-0.2.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.1 kB
Release files / ionic_langchain-0.2.3.tar.gz
| Download URL | ionic_langchain-0.2.3.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d7c8c400c329e2b0f8155d5bd8ff16d553d1a3500b884d535d1c188f5fcf79ce
|
|
BLAKE2b-256 checksum How to use checksums |
e4074b1d1969d3d1f23600589ce8a636fe98d79be7207ac4590654e376036315
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.8.12 Linux/6.2.0-1018-azure
|
Release files / ionic_langchain-0.2.3-py3-none-any.whl
| Download URL | ionic_langchain-0.2.3-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e0a3822ce92f29ce91ce589cd872f021ea9ad6b6b2761f6f6aec84d3efaf7b09
|
|
BLAKE2b-256 checksum How to use checksums |
d944aecc3c12e45b56993317a0ecc995bddf480cce9a161d9433a8578b594e82
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.8.12 Linux/6.2.0-1018-azure
|