跳到主要内容
Tensorlake 是一个 AI 数据云,它能可靠地将非结构化数据转换为可供 AI 应用程序摄取的数据格式。 langchain-tensorlake 包提供了 TensorlakeLangChain 之间的无缝集成,使您能够构建具有增强解析功能(如签名检测)的复杂文档处理代理。

Tensorlake 功能概述

Tensorlake 为您提供以下工具
  • 提取:模式驱动的结构化数据提取,用于从文档中提取特定字段。
  • 解析:将文档转换为 Markdown,以构建 RAG/知识图谱系统。
  • 编排:为文档、文本、音频、视频等的大规模摄取和丰富构建可编程工作流。
请访问 docs.tensorlake.ai 了解更多信息

安装

pip install -U langchain-tensorlake

示例

请遵循完整教程,了解如何使用 langchain-tensorlake 工具检测非结构化文档中的签名。 或者查看这个 colab notebook 以快速入门。

快速入门

1. 设置您的环境

您应该通过设置以下环境变量来配置 Tensorlake 和 OpenAI 的凭据
export TENSORLAKE_API_KEY="your-tensorlake-api-key"
export OPENAI_API_KEY = "your-openai-api-key"
Tensorlake Cloud Console 获取您的 Tensorlake API 密钥。新用户可获得 100 个免费积分。

2. 导入必要的包

from langchain_tensorlake import document_markdown_tool
from langchain.agents import create_agent
import asyncio
import os

3. 构建一个签名检测代理

async def main(question):
    # Create the agent with the Tensorlake tool
    agent = create_agent(
            model="gpt-4o-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. 使用示例

# 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 或直接在 GitHub 上的包仓库 联系我们。
以编程方式连接这些文档到 Claude、VSCode 等,通过 MCP 获取实时答案。
© . This site is unofficial and not affiliated with LangChain, Inc.