Skip to main content
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 云控制台 获取您的 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-4.1-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 上的包仓库 联系我们。