Skip to main content

No project description provided

Project description

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.

You can install the package from GitHub using pip:

python3 -m pip install git+https://github.com/ioniccommerce/ionic_langchain.git#v0.1.2

or poetry:

poetry add git+https://github.com/ioniccommerce/ionic_langchain.git#v0.1.2

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
from langchain.memory import ConversationBufferWindowMemory, RedisChatMessageHistory


tools: List[Tool] =  [
    IonicTool().tool(),
    # others,
]
redis_memory = RedisChatMessageHistory(url=os.environ.get("REDIS_URL"),session_id="chatId"),
memory = ConversationBufferWindowMemory(
    k=12,
    return_messages=True,
    chat_memory=redis_memory,
    memory_key="chat_history",
)

agent = initialize_agent(
    tools=tools,
    llm=ChatOpenAI(openai_api_key=os.environ.get("OPENAI_API_KEY"),temperature=0.5),
    agent=AgentType.CHAT_CONVERSATIONAL_REACT_DESCRIPTION,
    memory=memory,
    handle_parsing_errors=True,
    verbose=True,
)

agent.run(input="Roadhouse VHS")

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

Ionic Langchain is not currently accepting external contributions. Contact us via this form if you would like to contribute.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ionic_langchain-0.1.8.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ionic_langchain-0.1.8-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file ionic_langchain-0.1.8.tar.gz.

File metadata

  • Download URL: ionic_langchain-0.1.8.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.12.0 Linux/6.2.0-1018-azure

File hashes

Hashes for ionic_langchain-0.1.8.tar.gz
Algorithm Hash digest
SHA256 5c3f4bdbf9b3bc0bd64ca48eff14008c243294917a02a8e0b8656993fe8c46c3
MD5 4aca77d7f96a58def4a44e1357d4531b
BLAKE2b-256 0fd6b37285c9d7eb9b23d108c377ed53c23ed6cc0b5ee79bb34bc7e15532e300

See more details on using hashes here.

File details

Details for the file ionic_langchain-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: ionic_langchain-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.12.0 Linux/6.2.0-1018-azure

File hashes

Hashes for ionic_langchain-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 40ae7263d5c2e63d2c99dd07a7f48495a4a2fbf5f9a04d4fed6b94d88fa2e63d
MD5 368d5524372f9509a55937c6581f50cb
BLAKE2b-256 35b6bc1ea28d09ff126f8471e4771c98ba905bc78402192bb92e7a3be6398aab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page