Metadata-Version: 2.4
Name: fluentc-langchain-tool
Version: 0.2.0
Summary: Modern LangChain-compatible toolkit for FluentC AI Agent Translation API with real-time and batch translation support
Author: FluentC AI Team
Author-email: FluentC AI <support@fluentc.ai>
License: MIT
Project-URL: Homepage, https://www.fluentc.io
Project-URL: Documentation, https://dashboard.fluentc.io/ai_agent/docs
Project-URL: Repository, https://github.com/fluentc-ai/langchain-plugin
Project-URL: Issues, https://github.com/fluentc-ai/langchain-plugin/issues
Keywords: LangChain,Translation,FluentC,batch,realtime,AI,agent,multilingual,plugin
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing :: Linguistic
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
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: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.28.0
Requires-Dist: pydantic>=1.10.0
Requires-Dist: langchain>=0.1.0
Requires-Dist: typing-extensions>=4.0.0; python_version < "3.10"
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"

# FluentC LangChain Tool

Official Python plugin for integrating the [FluentC AI Translation API](https://www.fluentc.io) with [LangChain](https://www.langchain.com). This package enables real-time and batch translation, source language detection, and job result polling — all through LangChain-compatible tools.

---

## 🚀 Features

- ✅ Real-Time Translation (`/translate`)
- ⏳ Batch Translation with Auto Polling (`/translate` + `/results`)
- 🌍 Language Detection (`/checklanguage`)
- 📡 Job Result Retrieval (`/results`)
- 🔐 Secure API Key Authentication

---

## 📦 Installation

```bash
pip install fluentc-langchain-tool
```

---

## 🔐 Authentication

You'll need your FluentC API key (provided after signup and subscription):

```python
tool = FluentCTranslationTool(api_key="your-fluentc-api-key")
```

---

## 🧠 Available Tools

| Tool Class | Purpose |
|------------|---------|
| `FluentCTranslationTool` | Real-time or batch translation submit |
| `FluentCLanguageDetectorTool` | Detect source language from input |
| `FluentCTranslationStatusTool` | Check status of batch translation jobs |
| `FluentCResultsTool` | Poll for batch job translation result (legacy) |
| `FluentCBatchTranslationTool` | One-shot batch submit + polling |

---

## 🛠 Real-Time Translation

```python
from fluentc_langchain_tool import FluentCTranslationTool

tool = FluentCTranslationTool(api_key="your-api-key")
response = tool.run({
    "text": "Hello, world!",
    "target_language": "fr",
    "source_language": "en",
    "mode": "realtime"
})
print(response)  # "Bonjour, le monde !"
```

---

## ⏳ Batch Translation (Async with Auto Polling)

```python
from fluentc_langchain_tool import FluentCBatchTranslationTool

tool = FluentCBatchTranslationTool(api_key="your-api-key")

result = tool.run({
    "text": "<html>Hello, batch world!</html>",
    "target_language": "de",
    "source_language": "en"
})

print(result)  # Final translated output after polling
```

✅ Polling automatically respects FluentC's `estimated_wait_seconds` to avoid overloading the API.

---

## 🌍 Language Detection

```python
from fluentc_langchain_tool import FluentCLanguageDetectorTool

tool = FluentCLanguageDetectorTool(api_key="your-api-key")
response = tool.run({
    "text": "Hola, ¿cómo estás?"
})
print(response)  # Detected language: es (confidence: 0.99)
```

---

## 📡 Check Translation Status

```python
from fluentc_langchain_tool import FluentCTranslationStatusTool

tool = FluentCTranslationStatusTool(api_key="your-api-key")
response = tool.run({
    "job_id": "your-job-id"
})
print(response)
```

---

## 🔗 LangChain Agent Integration

```python
from langchain.agents import initialize_agent, Tool
from langchain.llms import OpenAI
from fluentc_langchain_tool import (
    FluentCTranslationTool,
    FluentCBatchTranslationTool,
    FluentCLanguageDetectorTool,
    FluentCTranslationStatusTool
)

api_key = "your-api-key"

agent = initialize_agent(
    tools=[
        Tool.from_function(FluentCTranslationTool(api_key)),
        Tool.from_function(FluentCBatchTranslationTool(api_key)),
        Tool.from_function(FluentCLanguageDetectorTool(api_key)),
        Tool.from_function(FluentCTranslationStatusTool(api_key))
    ],
    llm=OpenAI(temperature=0),
    agent="zero-shot-react-description"
)

agent.run("Translate 'Hello world' from English to German using FluentC.")
```
