Google Docs 阅读器¶
演示我们的 Google Docs 数据连接器
如果你在 colab 上打开此 Notebook,你可能需要安装 LlamaIndex 🦙。
输入 [ ]
已复制!
%pip install llama-index-readers-google
%pip install llama-index-readers-google
输入 [ ]
已复制!
!pip install llama-index
!pip install llama-index
输入 [ ]
已复制!
import logging
import sys
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))
import logging import sys logging.basicConfig(stream=sys.stdout, level=logging.INFO) logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))
输入 [ ]
已复制!
from llama_index.core import SummaryIndex
from llama_index.readers.google import GoogleDocsReader
from IPython.display import Markdown, display
import os
from llama_index.core import SummaryIndex from llama_index.readers.google import GoogleDocsReader from IPython.display import Markdown, display import os # 确保 credentials.json 文件存在 document_ids = ["
输入 [ ]
已复制!
# make sure credentials.json file exists
document_ids = ["<document_id>"]
documents = GoogleDocsReader().load_data(document_ids=document_ids)
"]documents = GoogleDocsReader().load_data(document_ids=document_ids)
输入 [ ]
已复制!
index = SummaryIndex.from_documents(documents)
index = SummaryIndex.from_documents(documents)
输入 [ ]
已复制!
# set Logging to DEBUG for more detailed outputs
query_engine = index.as_query_engine()
response = query_engine.query("<query_text>")
# 将日志级别设置为 DEBUG 以获得更详细的输出 query_engine = index.as_query_engine() response = query_engine.query("")
输入 [ ]
已复制!
display(Markdown(f"<b>{response}</b>"))
display(Markdown(f"{response}"))