Metadata-Version: 2.5
Name: langchain-asyntai
Version: 0.1.0
Summary: LangChain tools for Asyntai, the AI chat agent for websites
Project-URL: Homepage, https://asyntai.com
Project-URL: Documentation, https://asyntai.com/documentation/integrations/langchain/
Project-URL: Source, https://github.com/asyntai/langchain-asyntai
Author-email: Asyntai <hello@asyntai.com>
License: MIT
License-File: LICENSE
Keywords: agent,asyntai,chatbot,langchain,rag,website
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.9
Requires-Dist: langchain-core>=0.3.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: requests>=2.28.0
Provides-Extra: test
Requires-Dist: pytest>=7.0; extra == 'test'
Requires-Dist: requests-mock>=1.11; extra == 'test'
Description-Content-Type: text/markdown

# langchain-asyntai

LangChain tools for [Asyntai](https://asyntai.com), the AI chat agent for websites.

Point Asyntai at a website. It reads the pages, the product feed and the
documents, and keeps them current. This package hands that knowledge to any
LangChain agent as a set of tools, so your agent answers questions about a real
website without you building and maintaining an index.

## Install

```bash
pip install langchain-asyntai
```

## Set the key

Create an API key in Asyntai under **Settings → API**. The API is available on
the Starter plan and higher.

```bash
export ASYNTAI_API_KEY="your-key"
```

## Ask a website a question

```python
from langchain_asyntai import AsyntaiAskTool

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

## Give an agent every tool

```python
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, and who asked about it this week?"}
]})
```

## The tools

| Tool | What the agent can do |
| --- | --- |
| `asyntai_ask_website` | Answer a question from the website: products, prices, delivery, opening hours, policies, documentation. |
| `asyntai_add_text` | Store a text so the website agent uses it in later answers. |
| `asyntai_add_url` | Read a page into the knowledge base. |
| `asyntai_list_knowledge` | List what the website agent knows. |
| `asyntai_get_leads` | Read the visitors who left an email address or a phone number. |
| `asyntai_get_conversation` | Read the messages of one website chat. |

## Several agents on one account

An Asyntai account can run an agent per website. Name the one you want with
`website_id`, which `AsyntaiClient.websites()` returns.

```python
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.

## Errors

Every failure raises `AsyntaiError` with a message you can show to a user.

```python
from langchain_asyntai import AsyntaiError

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

## Documentation

Full guide: [asyntai.com/documentation/integrations/langchain/](https://asyntai.com/documentation/integrations/langchain/)

## Licence

MIT
