mirror of
https://github.com/hwchase17/langchain
synced 2024-11-10 01:10:59 +00:00
40f6e60e68
Co-authored-by: Ismail Pelaseyed <homanp@gmail.com>
88 lines
2.4 KiB
Plaintext
88 lines
2.4 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Stripe\n",
|
|
"\n",
|
|
"This notebook covers how to load data from the Stripe REST API into a format that can be ingested into LangChain, along with example usage for vectorization."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import os\n",
|
|
"\n",
|
|
"\n",
|
|
"from langchain.document_loaders import StripeLoader\n",
|
|
"from langchain.indexes import VectorstoreIndexCreator"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"The Stripe API requires an access token, which can be found inside of the Stripe dashboard.\n",
|
|
"\n",
|
|
"This document loader also requires a `resource` option which defines what data you want to load.\n",
|
|
"\n",
|
|
"Following resources are available:\n",
|
|
"\n",
|
|
"`balance_transations` (Documentation)[https://stripe.com/docs/api/balance_transactions/list]\n",
|
|
"`charges` (Documentation)[https://stripe.com/docs/api/charges/list]\n",
|
|
"`customers` (Documentation)[https://stripe.com/docs/api/customers/list]\n",
|
|
"`events` (Documentation)[https://stripe.com/docs/api/events/list]\n",
|
|
"`refunds` (Documentation)[https://stripe.com/docs/api/refunds/list]\n",
|
|
"`disputes` (Documentation)[https://stripe.com/docs/api/disputes/list]"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"stripe_loader = StripeLoader(os.environ[\"STRIPE_ACCESS_TOKEN\"], \"charges\")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Create a vectorstore retriver from the loader\n",
|
|
"# see https://python.langchain.com/en/latest/modules/indexes/getting_started.html for more details\n",
|
|
"\n",
|
|
"index = VectorstoreIndexCreator().from_loaders([stripe_loader])\n",
|
|
"stripe_doc_retriever = index.vectorstore.as_retriever()"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3 (ipykernel)",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.9.1"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|