You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
langchain/docs/modules/indexes/document_loaders/examples/trello.ipynb

185 lines
5.6 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Trello\n",
"\n",
">[Trello](https://www.atlassian.com/software/trello) is a web-based project management and collaboration tool that allows individuals and teams to organize and track their tasks and projects. It provides a visual interface known as a \"board\" where users can create lists and cards to represent their tasks and activities.\n",
"\n",
"The TrelloLoader allows you to load cards from a Trello board and is implemented on top of [py-trello](https://pypi.org/project/py-trello/)\n",
"\n",
"This currently supports `api_key/token` only.\n",
"\n",
"1. Credentials generation: https://trello.com/power-ups/admin/\n",
"\n",
"2. Click in the manual token generation link to get the token.\n",
"\n",
"To specify the API key and token you can either set the environment variables ``TRELLO_API_KEY`` and ``TRELLO_TOKEN`` or you can pass ``api_key`` and ``token`` directly into the `from_credentials` convenience constructor method.\n",
"\n",
"This loader allows you to provide the board name to pull in the corresponding cards into Document objects.\n",
"\n",
"Notice that the board \"name\" is also called \"title\" in oficial documentation:\n",
"\n",
"https://support.atlassian.com/trello/docs/changing-a-boards-title-and-description/\n",
"\n",
"You can also specify several load parameters to include / remove different fields both from the document page_content properties and metadata.\n",
"\n",
"## Features\n",
"- Load cards from a Trello board.\n",
"- Filter cards based on their status (open or closed).\n",
"- Include card names, comments, and checklists in the loaded documents.\n",
"- Customize the additional metadata fields to include in the document.\n",
"\n",
"By default all card fields are included for the full text page_content and metadata accordinly.\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"#!pip install py-trello beautifulsoup4"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"········\n",
"········\n"
]
}
],
"source": [
"# If you have already set the API key and token using environment variables,\n",
"# you can skip this cell and comment out the `api_key` and `token` named arguments\n",
"# in the initialization steps below.\n",
"from getpass import getpass\n",
"\n",
"API_KEY = getpass()\n",
"TOKEN = getpass()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Review Tech partner pages\n",
"Comments:\n",
"{'title': 'Review Tech partner pages', 'id': '6475357890dc8d17f73f2dcc', 'url': 'https://trello.com/c/b0OTZwkZ/1-review-tech-partner-pages', 'labels': ['Demand Marketing'], 'list': 'Done', 'closed': False, 'due_date': ''}\n"
]
}
],
"source": [
"from langchain.document_loaders import TrelloLoader\n",
"\n",
"# Get the open cards from \"Awesome Board\"\n",
"loader = TrelloLoader.from_credentials(\n",
" \"Awesome Board\",\n",
" api_key=API_KEY,\n",
" token=TOKEN,\n",
" card_filter=\"open\",\n",
" )\n",
"documents = loader.load()\n",
"\n",
"print(documents[0].page_content)\n",
"print(documents[0].metadata)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Review Tech partner pages\n",
"Comments:\n",
"{'title': 'Review Tech partner pages', 'id': '6475357890dc8d17f73f2dcc', 'url': 'https://trello.com/c/b0OTZwkZ/1-review-tech-partner-pages', 'list': 'Done'}\n"
]
}
],
"source": [
"# Get all the cards from \"Awesome Board\" but only include the\n",
"# card list(column) as extra metadata.\n",
"loader = TrelloLoader.from_credentials(\n",
" \"Awesome Board\",\n",
" api_key=API_KEY,\n",
" token=TOKEN,\n",
" extra_metadata=(\"list\"),\n",
")\n",
"documents = loader.load()\n",
"\n",
"print(documents[0].page_content)\n",
"print(documents[0].metadata)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Get the cards from \"Another Board\" and exclude the card name,\n",
"# checklist and comments from the Document page_content text.\n",
"loader = TrelloLoader.from_credentials(\n",
" \"test\",\n",
" api_key=API_KEY,\n",
" token=TOKEN,\n",
" include_card_name= False,\n",
" include_checklist= False,\n",
" include_comments= False,\n",
")\n",
"documents = loader.load()\n",
"\n",
"print(\"Document: \" + documents[0].page_content)\n",
"print(documents[0].metadata)"
]
}
],
"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.11.3"
},
"vscode": {
"interpreter": {
"hash": "cc99336516f23363341912c6723b01ace86f02e26b4290be1efc0677e2e2ec24"
}
}
},
"nbformat": 4,
"nbformat_minor": 4
}