Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docs): Add docs for stripe toolkit #7212

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions docs/core_docs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ docs/tutorials/classification.md
docs/tutorials/classification.mdx
docs/tutorials/chatbot.md
docs/tutorials/chatbot.mdx
docs/concepts/t.md
docs/concepts/t.mdx
docs/how_to/trim_messages.md
docs/how_to/trim_messages.mdx
docs/how_to/tools_prompting.md
Expand Down Expand Up @@ -216,8 +218,6 @@ docs/how_to/assign.md
docs/how_to/assign.mdx
docs/how_to/agent_executor.md
docs/how_to/agent_executor.mdx
docs/concepts/t.md
docs/concepts/t.mdx
docs/versions/migrating_memory/conversation_summary_memory.md
docs/versions/migrating_memory/conversation_summary_memory.mdx
docs/versions/migrating_memory/conversation_buffer_window_memory.md
Expand Down Expand Up @@ -254,6 +254,8 @@ docs/integrations/vectorstores/chroma.md
docs/integrations/vectorstores/chroma.mdx
docs/integrations/tools/tavily_search.md
docs/integrations/tools/tavily_search.mdx
docs/integrations/tools/stripe.md
docs/integrations/tools/stripe.mdx
docs/integrations/tools/serpapi.md
docs/integrations/tools/serpapi.mdx
docs/integrations/tools/exa_search.md
Expand Down Expand Up @@ -328,6 +330,8 @@ docs/integrations/llms/azure.md
docs/integrations/llms/azure.mdx
docs/integrations/llms/arcjet.md
docs/integrations/llms/arcjet.mdx
docs/integrations/chat/xai.md
docs/integrations/chat/xai.mdx
docs/integrations/chat/togetherai.md
docs/integrations/chat/togetherai.mdx
docs/integrations/chat/openai.md
Expand Down Expand Up @@ -376,6 +380,16 @@ docs/integrations/retrievers/self_query/hnswlib.md
docs/integrations/retrievers/self_query/hnswlib.mdx
docs/integrations/retrievers/self_query/chroma.md
docs/integrations/retrievers/self_query/chroma.mdx
docs/integrations/document_loaders/file_loaders/unstructured.md
docs/integrations/document_loaders/file_loaders/unstructured.mdx
docs/integrations/document_loaders/file_loaders/text.md
docs/integrations/document_loaders/file_loaders/text.mdx
docs/integrations/document_loaders/file_loaders/pdf.md
docs/integrations/document_loaders/file_loaders/pdf.mdx
docs/integrations/document_loaders/file_loaders/directory.md
docs/integrations/document_loaders/file_loaders/directory.mdx
docs/integrations/document_loaders/file_loaders/csv.md
docs/integrations/document_loaders/file_loaders/csv.mdx
docs/integrations/document_loaders/web_loaders/web_puppeteer.md
docs/integrations/document_loaders/web_loaders/web_puppeteer.mdx
docs/integrations/document_loaders/web_loaders/web_cheerio.md
Expand All @@ -387,14 +401,4 @@ docs/integrations/document_loaders/web_loaders/pdf.mdx
docs/integrations/document_loaders/web_loaders/langsmith.md
docs/integrations/document_loaders/web_loaders/langsmith.mdx
docs/integrations/document_loaders/web_loaders/firecrawl.md
docs/integrations/document_loaders/web_loaders/firecrawl.mdx
docs/integrations/document_loaders/file_loaders/unstructured.md
docs/integrations/document_loaders/file_loaders/unstructured.mdx
docs/integrations/document_loaders/file_loaders/text.md
docs/integrations/document_loaders/file_loaders/text.mdx
docs/integrations/document_loaders/file_loaders/pdf.md
docs/integrations/document_loaders/file_loaders/pdf.mdx
docs/integrations/document_loaders/file_loaders/directory.md
docs/integrations/document_loaders/file_loaders/directory.mdx
docs/integrations/document_loaders/file_loaders/csv.md
docs/integrations/document_loaders/file_loaders/csv.mdx
docs/integrations/document_loaders/web_loaders/firecrawl.mdx
202 changes: 202 additions & 0 deletions docs/core_docs/docs/integrations/tools/stripe.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
{
"cells": [
{
"cell_type": "raw",
"id": "10238e62-3465-4973-9279-606cbb7ccf16",
"metadata": {
"vscode": {
"languageId": "raw"
}
},
"source": [
"---\n",
"sidebar_label: Stripe Agent Toolkit\n",
"---"
]
},
{
"cell_type": "markdown",
"id": "a6f91f20",
"metadata": {},
"source": [
"# Stripe Agent Toolkit\n",
"\n",
"The [Stripe Agent Toolkit](https://github.com/stripe/agent-toolkit?tab=readme-ov-file#typescript) enables integrating LangChain with Stripe APIs through function calling.\n",
"\n",
"## Overview\n",
"\n",
"## Setup\n",
"\n",
"The integration requires installing `@stripe/agent-toolkit` (exposes the Stripe API tools) and `@langchain/core` (for packaging as a LangChain tool). We'll be using LangGraph's `createReactAgent` prebuilt ReAct agent function in this example, so you'll need to install `@langchain/langgraph` as well.\n",
"\n",
"```{=mdx}\n",
"import IntegrationInstallTooltip from \"@mdx_components/integration_install_tooltip.mdx\";\n",
"import Npm2Yarn from \"@theme/Npm2Yarn\";\n",
"\n",
"<IntegrationInstallTooltip></IntegrationInstallTooltip>\n",
"\n",
"<Npm2Yarn>\n",
" @stripe/agent-toolkit @langchain/core @langchain/langgraph\n",
"</Npm2Yarn>\n",
"```\n",
"\n",
"### Credentials\n",
"\n",
"Create a Stripe secret key on your [Stripe Dashboard](https://dashboard.stripe.com/account/apikeys) and set it as an environment variable:\n",
"\n",
"```typescript\n",
"process.env.STRIPE_SECRET_KEY = \"YOUR_SECRET_KEY\"\n",
"```\n",
"\n",
"It's also helpful (but not needed) to set up [LangSmith](https://smith.langchain.com/) for best-in-class observability:\n",
"\n",
"```typescript\n",
"process.env.LANGCHAIN_TRACING_V2=\"true\"\n",
"process.env.LANGCHAIN_API_KEY=\"your-api-key\"\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "1c97218f-f366-479d-8bf7-fe9f2f6df73f",
"metadata": {},
"source": [
"## Instantiation\n",
"\n",
"You can import and instantiate an instance of the Stripe Agent Toolkit as follows:\n",
"\n",
"First, select an LLM to use in the agent:\n",
"\n",
"```{=mdx}\n",
"import ChatModelTabs from \"@theme/ChatModelTabs\";\n",
"\n",
"<ChatModelTabs openaiParams={`{ model: \"gpt-4o\" }`} />\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "14189d34",
"metadata": {},
"outputs": [],
"source": [
"// @lc-docs-hide-cell\n",
"\n",
"import { ChatOpenAI } from \"@langchain/openai\";\n",
"\n",
"const model = new ChatOpenAI({ model: \"gpt-4o\", temperature: 0 })"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "8b3ddfe9-ca79-494c-a7ab-1f56d9407a64",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"16:7 - Property '_callWithConfig' of exported class expression may not be private or protected.\n",
"16:7 - Property '_getOptionsList' of exported class expression may not be private or protected.\n",
"16:7 - Property '_separateRunnableConfigFromCallOptions' of exported class expression may not be private or protected.\n",
"16:7 - Property '_streamEventsV1' of exported class expression may not be private or protected.\n",
"16:7 - Property '_streamEventsV2' of exported class expression may not be private or protected.\n",
"16:7 - Property '_streamLog' of exported class expression may not be private or protected.\n",
"16:7 - Property '_transformStreamWithConfig' of exported class expression may not be private or protected.\n",
"16:7 - Property 'lc_runnable' of exported class expression may not be private or protected.\n"
]
}
],
"source": [
"import { createReactAgent } from \"@langchain/langgraph/prebuilt\";\n",
"import { StripeAgentToolkit } from \"@stripe/agent-toolkit/langchain\";\n",
"\n",
"console.log(\"Before toolkit\")\n",
"const stripeAgentToolkit = new StripeAgentToolkit({\n",
" secretKey: process.env.STRIPE_SECRET_KEY!,\n",
" configuration: {\n",
" actions: {\n",
" paymentLinks: {\n",
" create: true,\n",
" },\n",
" },\n",
" },\n",
"});\n",
"console.log(\"Before tools\")\n",
"const tools = stripeAgentToolkit.tools;\n",
"// console.log(tools)\n",
"// const agent = createReactAgent({\n",
"// llm: model,\n",
"// tools,\n",
"// });"
]
},
{
"cell_type": "markdown",
"id": "74147a1a",
"metadata": {},
"source": [
"## Invocation\n",
"\n",
"### [Invoke directly with args](/docs/concepts/tools)\n",
"\n",
"You can invoke the agent with tools directly like this:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "65310a8b-eb0c-4d9e-a618-4f4abe2414fc",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[{\"title\":\"San Francisco, CA Current Weather | AccuWeather\",\"url\":\"https://www.accuweather.com/en/us/san-francisco/94103/current-weather/347629\",\"content\":\"Current weather in San Francisco, CA. Check current conditions in San Francisco, CA with radar, hourly, and more.\",\"score\":0.9428234,\"raw_content\":null},{\"title\":\"National Weather Service\",\"url\":\"https://forecast.weather.gov/zipcity.php?inputstring=San+Francisco,CA\",\"content\":\"NOAA National Weather Service. Current conditions at SAN FRANCISCO DOWNTOWN (SFOC1) Lat: 37.77056°NLon: 122.42694°WElev: 150.0ft.\",\"score\":0.94261247,\"raw_content\":null}]\n"
]
}
],
"source": [
"await agent.invoke({\n",
" messages: [{\n",
" role: \"user\",\n",
" content: \"Can you create a payment link for my 'test' product?\"\n",
" }]\n",
"})"
]
},
{
"cell_type": "markdown",
"id": "573fb391",
"metadata": {},
"source": [
"## Agents\n",
"\n",
"For guides on how to use LangChain tools in agents, see the [LangGraph.js](https://langchain-ai.github.io/langgraphjs/) docs."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "TypeScript",
"language": "typescript",
"name": "tslab"
},
"language_info": {
"codemirror_mode": {
"mode": "typescript",
"name": "javascript",
"typescript": true
},
"file_extension": ".ts",
"mimetype": "text/typescript",
"name": "typescript",
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
1 change: 1 addition & 0 deletions docs/core_docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"@langchain/langgraph": "0.2.3",
"@langchain/scripts": "workspace:*",
"@microsoft/fetch-event-source": "^2.0.1",
"@stripe/agent-toolkit": "^0.1.20",
"@swc/core": "^1.3.62",
"@types/cookie": "^0",
"docusaurus-plugin-typedoc": "1.0.0-next.5",
Expand Down
44 changes: 43 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18039,6 +18039,19 @@ __metadata:
languageName: node
linkType: hard

"@stripe/agent-toolkit@npm:^0.1.20":
version: 0.1.20
resolution: "@stripe/agent-toolkit@npm:0.1.20"
dependencies:
stripe: ^17.0.0
zod: ^3.23.8
peerDependencies:
"@langchain/core": ^0.3.6
ai: ^3.4.7
checksum: a46efa49bbef9a495c0dfe829361620636a76c72be99bc0c080c8d787bcfc5fc8e22d4fc84a0e0e7f0caf020098476a616b19a17b65b8bf13a4f266316d77a0f
languageName: node
linkType: hard

"@supabase/auth-js@npm:2.64.4":
version: 2.64.4
resolution: "@supabase/auth-js@npm:2.64.4"
Expand Down Expand Up @@ -19329,6 +19342,15 @@ __metadata:
languageName: node
linkType: hard

"@types/node@npm:>=8.1.0":
version: 22.9.0
resolution: "@types/node@npm:22.9.0"
dependencies:
undici-types: ~6.19.8
checksum: c014eb3b8a110f1b87b614a40ef288d13e6b08ae9d5dafbd38951a2eebc24d352dc55330ed9d00c97ee9e64483c3cc14c4aa914c5df7ca7b9eaa1a30b2340dbd
languageName: node
linkType: hard

"@types/node@npm:^12.0.8":
version: 12.20.55
resolution: "@types/node@npm:12.20.55"
Expand Down Expand Up @@ -23825,6 +23847,7 @@ __metadata:
"@langchain/scripts": "workspace:*"
"@mdx-js/react": ^1.6.22
"@microsoft/fetch-event-source": ^2.0.1
"@stripe/agent-toolkit": ^0.1.20
"@supabase/supabase-js": ^2.45.0
"@swc/core": ^1.3.62
"@types/cookie": ^0
Expand Down Expand Up @@ -38186,6 +38209,15 @@ __metadata:
languageName: node
linkType: hard

"qs@npm:^6.11.0":
version: 6.13.0
resolution: "qs@npm:6.13.0"
dependencies:
side-channel: ^1.0.6
checksum: e9404dc0fc2849245107108ce9ec2766cde3be1b271de0bf1021d049dc5b98d1a2901e67b431ac5509f865420a7ed80b7acb3980099fe1c118a1c5d2e1432ad8
languageName: node
linkType: hard

"querystringify@npm:^2.1.1":
version: 2.2.0
resolution: "querystringify@npm:2.2.0"
Expand Down Expand Up @@ -40963,6 +40995,16 @@ __metadata:
languageName: node
linkType: hard

"stripe@npm:^17.0.0":
version: 17.3.1
resolution: "stripe@npm:17.3.1"
dependencies:
"@types/node": ">=8.1.0"
qs: ^6.11.0
checksum: 89446bc2a8112151e2dfde42e16d1949c41b06d2a5eb9e5b6e0fc77cdb7c6a719ddbab9b001d3a6c3b477e53a0a45d08e207739ecab44cad2e6332ec31a65ace
languageName: node
linkType: hard

"strnum@npm:^1.0.5":
version: 1.0.5
resolution: "strnum@npm:1.0.5"
Expand Down Expand Up @@ -42533,7 +42575,7 @@ __metadata:
languageName: node
linkType: hard

"undici-types@npm:~6.19.2":
"undici-types@npm:~6.19.2, undici-types@npm:~6.19.8":
version: 6.19.8
resolution: "undici-types@npm:6.19.8"
checksum: de51f1b447d22571cf155dfe14ff6d12c5bdaec237c765085b439c38ca8518fc360e88c70f99469162bf2e14188a7b0bcb06e1ed2dc031042b984b0bb9544017
Expand Down
Loading