Files
wehub-resource-sync a0c8464e58
Build Package / build (ubuntu-latest) (push) Failing after 1s
CodeQL / Analyze (python) (push) Failing after 1s
Core Typecheck / core-typecheck (push) Failing after 1s
Linting / lint (push) Failing after 1s
llama-dev tests / test-llama-dev (push) Failing after 1s
Publish Sub-Package to PyPI if Needed / publish_subpackage_if_needed (push) Has been skipped
Sync Docs to Developer Hub / sync-docs (push) Failing after 0s
Build Package / build (windows-latest) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:26:52 +08:00

143 lines
3.3 KiB
Plaintext

{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"id": "e9c676c0",
"metadata": {},
"source": [
"<a href=\"https://colab.research.google.com/github/run-llama/llama_index/blob/main/docs/examples/data_connectors/GoogleDocsDemo.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"id": "88141371-de4c-4c02-9e8f-10d2491b5a33",
"metadata": {},
"source": [
"# Google Docs Reader\n",
"Demonstrates our Google Docs data connector"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "018d3fd6",
"metadata": {},
"source": [
"If you're opening this Notebook on colab, you will probably need to install LlamaIndex 🦙."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ea0e003b",
"metadata": {},
"outputs": [],
"source": [
"%pip install llama-index-readers-google"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6eb0af7b",
"metadata": {},
"outputs": [],
"source": [
"!pip install llama-index"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f6b62adf",
"metadata": {},
"outputs": [],
"source": [
"import logging\n",
"import sys\n",
"\n",
"logging.basicConfig(stream=sys.stdout, level=logging.INFO)\n",
"logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fafc701d-5a10-4503-9dae-22698fb1aee9",
"metadata": {},
"outputs": [],
"source": [
"from llama_index.core import SummaryIndex\n",
"from llama_index.readers.google import GoogleDocsReader\n",
"from IPython.display import Markdown, display\n",
"import os"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b8f0a9f2-c6a9-4840-a38a-0b2f8e433063",
"metadata": {},
"outputs": [],
"source": [
"# make sure credentials.json file exists\n",
"document_ids = [\"<document_id>\"]\n",
"documents = GoogleDocsReader().load_data(document_ids=document_ids)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "89ef1fac-aa36-4a5f-b5cf-bc4dfa0bd332",
"metadata": {},
"outputs": [],
"source": [
"index = SummaryIndex.from_documents(documents)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c2c1573f-2e49-49e8-8daf-19e6f1777eaa",
"metadata": {},
"outputs": [],
"source": [
"# set Logging to DEBUG for more detailed outputs\n",
"query_engine = index.as_query_engine()\n",
"response = query_engine.query(\"<query_text>\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6d4533c9-9020-4f50-837c-316ec2c454f2",
"metadata": {},
"outputs": [],
"source": [
"display(Markdown(f\"<b>{response}</b>\"))"
]
}
],
"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"
}
},
"nbformat": 4,
"nbformat_minor": 5
}