Înapoi la tabloul de bord

Documentație

Aflați cum să utilizați Asyntai

LangChain Integration

Give your LangChain agent the knowledge of a whole website

Create Account

Overview

LangChain is a library for building AI agents in Python. The langchain-asyntai package gives those agents a website to draw on.

Point Asyntai at a domain. Asyntai crawls the site, reads the product feed, and keeps both fresh. Your agent then asks that website a question and gets the answer a visitor would get, built from the real pages and the real prices.

The same package opens the other side of the website: the chats visitors had, and the email addresses and phone numbers they left.

Tools

The package adds six tools:

  • asyntai_ask_website — answers a question from the website's pages, products and knowledge base.
  • asyntai_add_url — reads a page and stores its content.
  • asyntai_add_text — stores a title and a text you write.
  • asyntai_list_knowledge — lists what the website agent knows.
  • asyntai_get_leads — returns visitors who left an email address or a phone number, newest first.
  • asyntai_get_conversation — returns the messages of one website chat.

Requirements

  • Python 3.9 or higher
  • An Asyntai account on the Starter plan or higher, because the package uses the Asyntai API

Installation

Follow these steps to add Asyntai to a LangChain agent:

1

Install the Package

Run pip install langchain-asyntai.

2

Get Your API Key

Sign in to Asyntai, open Settings, then API, and copy your API key.

3

Set the Key

Put the key in the ASYNTAI_API_KEY environment variable, or pass it as api_key= to any tool.

4

Add the Tools

Hand the tools to your agent. The toolkit gives you all six at once.

Ask a Website a Question

from langchain_asyntai import AsyntaiAskTool

ask = AsyntaiAskTool()
print(ask.invoke({"question": "How long does delivery take?"}))

Give an Agent Every Tool

from langchain.agents import create_agent
from langchain_asyntai import AsyntaiToolkit

toolkit = AsyntaiToolkit()
agent = create_agent("openai:gpt-4o-mini", toolkit.get_tools())

agent.invoke({"messages": [
    {"role": "user", "content": "What does the shop sell?"}
]})

Several Agents on One Account

An Asyntai account can run an agent per website. Name the one you want with website_id.

from langchain_asyntai import AsyntaiClient, AsyntaiToolkit

client = AsyntaiClient()
for site in client.websites():
    print(site["id"], site["domain"])

toolkit = AsyntaiToolkit(website_id=42)

Agencies run this pattern across a client book: one Asyntai account, one agent per client site, one website_id per agent.

Tip: The answer quality follows the knowledge base. Add the pages that matter with asyntai_add_url, and check the result with asyntai_list_knowledge.

Errors

Every failure raises AsyntaiError with a message you can show to a user. A wrong key, a plan that is too low, and a reached message limit each have their own message.

from langchain_asyntai import AsyntaiError

try:
    ask.invoke({"question": "..."})
except AsyntaiError as exc:
    print(exc)

Plans & Pricing

The package is free. It uses the Asyntai API, which needs the Starter plan or higher. View pricing.

Need Help?

If you have any questions or run into issues, contact us at [email protected].