> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-docs-zh.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Tensorlake 集成

> 使用 LangChain Python 集成 Tensorlake。

Tensorlake是AI数据云，可靠地将非结构化数据源的数据转换为AI应用程序可摄入的格式。

The `langchain-tensorlake` package提供了与[Tensorlake](https://tensorlake.ai)和[LangChain](https://langchain.com)的无缝集成，
使您能够使用增强的解析功能构建复杂的文档处理智能体，例如签名检测。

## Tensorlake功能概览

Tensorlake为您提供以下工具：

* Extract：基于模式的结构化数据抽取，从文档中提取特定字段
* Parse：将文档转换为Markdown格式，用于构建RAG/Knowledge Graph系统
* Orchestrate：构建可编程工作流，对文档、文本、音频、视频等数据进行大规模摄入和增强

更多详情请访问[docs.tensorlake.ai](https://docs.tensorlake.ai/introduction)

***

## 安装

```bash pip theme={null}
pip install -U langchain-tensorlake
```

```bash uv theme={null}
uv add langchain-tensorlake
```

***

## 示例

请参考[完整教程](https://docs.tensorlake.ai/examples/tutorials/real-estate-agent-with-langgraph-cli)，了解如何使用`langchain-tensorlake`工具检测非结构化文档中的签名。

或查看这个[Colab笔记本](https://colab.research.google.com/drive/1VRWIPCWYnjcRtQL864Bqm9CJ6g4EpRqs?usp=sharing)获取快速入门指南。

***

## 快速开始

### 1. 配置环境

您需要为Tensorlake和OpenAI配置凭据，设置以下环境变量：

```
export TENSORLAKE_API_KEY="your-tensorlake-api-key"
export OPENAI_API_KEY = "your-openai-api-key"
```

从[Tensorlake云控制台](https://cloud.tensorlake.ai/)获取Tensorlake API密钥。新用户可获赠100个免费信用额度。

### 2. 导入必要包

```python theme={null}
from langchain_tensorlake import document_markdown_tool
from langchain.agents import create_agent
import asyncio
import os
```

### 3. 构建签名检测智能体

```python theme={null}
async def main(question):
    # Create the agent with the Tensorlake tool
    agent = create_agent(
            model="gpt-5.4-mini",
            tools=[document_markdown_tool],
            prompt=(
                """
                I have a document that needs to be parsed. \n\nPlease parse this document and answer the question about it.
                """
            ),
            name="real-estate-agent",
        )

    # Run the agent
    result = await agent.ainvoke({"messages": [{"role": "user", "content": question}]})

    # Print the result
    print(result["messages"][-1].content)
```

\*注意：我们强烈建议使用`openai`作为智能体模型，以确保智能体正确设置解析参数

### 4. 示例用法

```python theme={null}
# Define the path to the document to be parsed
path = "path/to/your/document.pdf"

# Define the question to be asked and create the agent
question = f"What contextual information can you extract about the signatures in my document found at {path}?"

if __name__ == "__main__":
    asyncio.run(main(question))
```

## 需要帮助？

可通过[Slack](https://join.slack.com/t/tensorlakecloud/shared_invite/zt-32fq4nmib-gO0OM5RIar3zLOBm~ZGqKg)与我们联系，或直接访问[GitHub仓库](https://github.com/tensorlakeai/langchain-tensorlake)获取支持。

***

> 官方原文：[src/oss/python/integrations/providers/tensorlake.mdx](https://github.com/langchain-ai/docs/blob/main/src/oss/python/integrations/providers/tensorlake.mdx) · 非官方翻译，译文由 AI 生成，以英文原文为准。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.