跳到主要内容
本指南提供了 Stripe 智能体工具包的快速入门概览。 您可以在Stripe 的发布博客或项目PyPi 页面上了解更多关于 StripeAgentToolkit 的信息。

概览

集成详情

类别可序列化JS 支持版本
StripeAgentToolkitstripe-agent-toolkitPyPI - Version

设置

这个外部管理的软件包托管在 stripe-agent-toolkit 项目中,由 Stripe 团队管理。 您可以使用 pip 安装它以及用于以下示例的 langgraph:
pip install --quiet -U langgraph stripe-agent-toolkit
[notice] A new release of pip is available: 24.2 -> 24.3.1
[notice] To update, run: pip install -U pip
Note: you may need to restart the kernel to use updated packages.

凭据

除了安装软件包,您还需要使用 Stripe 账户的密钥配置集成,该密钥可在您的Stripe 控制面板中获取。
import getpass
import os

if not os.environ.get("STRIPE_SECRET_KEY"):
    os.environ["STRIPE_SECRET_KEY"] = getpass.getpass("STRIPE API key:\n")
设置 LangSmith 以获得一流的可观察性也很有帮助(但不是必需的)
os.environ["LANGSMITH_TRACING"] = "true"
# os.environ["LANGSMITH_API_KEY"] = getpass.getpass()

实例化

此处展示了如何创建 Stripe 工具包实例
from stripe_agent_toolkit.langchain.toolkit import StripeAgentToolkit

stripe_agent_toolkit = StripeAgentToolkit(
    secret_key=os.getenv("STRIPE_SECRET_KEY"),
    configuration={
        "actions": {
            "payment_links": {
                "create": True,
            },
        }
    },
)

代理

以下是如何使用该工具包在 langgraph 中创建基本智能体
from langchain_anthropic import ChatAnthropic
from langchain.agents import create_agent


model = ChatAnthropic(
    model="claude-3-5-sonnet-20240620",
)

langgraph_agent_executor = create_agent(model, stripe_agent_toolkit.get_tools())

input_state = {
    "messages": """
        Create a payment link for a new product called 'test' with a price
        of $100. Come up with a funny description about buy bots,
        maybe a haiku.
    """,
}

output_state = langgraph_agent_executor.invoke(input_state)

print(output_state["messages"][-1].content)

以编程方式连接这些文档到 Claude、VSCode 等,通过 MCP 获取实时答案。
© . This site is unofficial and not affiliated with LangChain, Inc.