Google Chat 读取器测试¶
演示了我们的 Google Chat 数据连接器。
如果您在 colab 上打开此 Notebook,您可能需要安装 LlamaIndex 🦙。
%pip install llama-index llama-index-readers-google
Requirement already satisfied: llama-index in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (0.10.47) Requirement already satisfied: llama-index-readers-google in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (0.2.8) Requirement already satisfied: llama-index-agent-openai<0.3.0,>=0.1.4 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index) (0.2.7) Requirement already satisfied: llama-index-cli<0.2.0,>=0.1.2 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index) (0.1.12) Requirement already satisfied: llama-index-core==0.10.47 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index) (0.10.47) Requirement already satisfied: llama-index-embeddings-openai<0.2.0,>=0.1.5 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index) (0.1.10) Requirement already satisfied: llama-index-indices-managed-llama-cloud<0.2.0,>=0.1.2 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index) (0.1.6) Requirement already satisfied: llama-index-legacy<0.10.0,>=0.9.48 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index) (0.9.48) Requirement already satisfied: llama-index-llms-openai<0.2.0,>=0.1.13 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index) (0.1.22) Requirement already satisfied: llama-index-multi-modal-llms-openai<0.2.0,>=0.1.3 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index) (0.1.6) Requirement already satisfied: llama-index-program-openai<0.2.0,>=0.1.3 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index) (0.1.6) Requirement already satisfied: llama-index-question-gen-openai<0.2.0,>=0.1.2 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index) (0.1.3) Requirement already satisfied: llama-index-readers-file<0.2.0,>=0.1.4 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index) (0.1.25) Requirement already satisfied: llama-index-readers-llama-parse<0.2.0,>=0.1.2 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index) (0.1.4) Requirement already satisfied: PyYAML>=6.0.1 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-core==0.10.47->llama-index) (6.0.1) Requirement already satisfied: SQLAlchemy>=1.4.49 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from SQLAlchemy[asyncio]>=1.4.49->llama-index-core==0.10.47->llama-index) (2.0.31) Requirement already satisfied: aiohttp<4.0.0,>=3.8.6 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-core==0.10.47->llama-index) (3.9.5) Requirement already satisfied: dataclasses-json in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-core==0.10.47->llama-index) (0.6.7) Requirement already satisfied: deprecated>=1.2.9.3 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-core==0.10.47->llama-index) (1.2.14) Requirement already satisfied: dirtyjson<2.0.0,>=1.0.8 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-core==0.10.47->llama-index) (1.0.8) Requirement already satisfied: fsspec>=2023.5.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-core==0.10.47->llama-index) (2024.6.0) Requirement already satisfied: httpx in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-core==0.10.47->llama-index) (0.27.0) Requirement already satisfied: llamaindex-py-client<0.2.0,>=0.1.18 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-core==0.10.47->llama-index) (0.1.19) Requirement already satisfied: nest-asyncio<2.0.0,>=1.5.8 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-core==0.10.47->llama-index) (1.6.0) Requirement already satisfied: networkx>=3.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-core==0.10.47->llama-index) (3.3) Requirement already satisfied: nltk<4.0.0,>=3.8.1 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-core==0.10.47->llama-index) (3.8.1) Requirement already satisfied: numpy<2.0.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-core==0.10.47->llama-index) (1.26.4) Requirement already satisfied: openai>=1.1.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-core==0.10.47->llama-index) (1.35.3) Requirement already satisfied: pandas in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-core==0.10.47->llama-index) (2.2.2) Requirement already satisfied: pillow>=9.0.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-core==0.10.47->llama-index) (10.3.0) Requirement already satisfied: requests>=2.31.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-core==0.10.47->llama-index) (2.32.3) Requirement already satisfied: tenacity!=8.4.0,<9.0.0,>=8.2.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-core==0.10.47->llama-index) (8.4.1) Requirement already satisfied: tiktoken>=0.3.3 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-core==0.10.47->llama-index) (0.7.0) Requirement already satisfied: tqdm<5.0.0,>=4.66.1 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-core==0.10.47->llama-index) (4.66.4) Requirement already satisfied: typing-extensions>=4.5.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-core==0.10.47->llama-index) (4.12.2) Requirement already satisfied: typing-inspect>=0.8.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-core==0.10.47->llama-index) (0.9.0) Requirement already satisfied: wrapt in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-core==0.10.47->llama-index) (1.16.0) Requirement already satisfied: gkeepapi<0.16.0,>=0.15.1 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-readers-google) (0.15.1) Requirement already satisfied: google-api-python-client<3.0.0,>=2.115.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-readers-google) (2.134.0) Requirement already satisfied: google-auth-httplib2<0.3.0,>=0.2.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-readers-google) (0.2.0) Requirement already satisfied: google-auth-oauthlib<2.0.0,>=1.2.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-readers-google) (1.2.0) Requirement already satisfied: pydrive<2.0.0,>=1.3.1 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-readers-google) (1.3.1) Requirement already satisfied: gpsoauth>=1.0.3 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from gkeepapi<0.16.0,>=0.15.1->llama-index-readers-google) (1.1.1) Requirement already satisfied: future>=0.16.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from gkeepapi<0.16.0,>=0.15.1->llama-index-readers-google) (1.0.0) Requirement already satisfied: httplib2<1.dev0,>=0.19.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from google-api-python-client<3.0.0,>=2.115.0->llama-index-readers-google) (0.22.0) Requirement already satisfied: google-auth!=2.24.0,!=2.25.0,<3.0.0.dev0,>=1.32.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from google-api-python-client<3.0.0,>=2.115.0->llama-index-readers-google) (2.30.0) Requirement already satisfied: google-api-core!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0.dev0,>=1.31.5 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from google-api-python-client<3.0.0,>=2.115.0->llama-index-readers-google) (2.19.0) Requirement already satisfied: uritemplate<5,>=3.0.1 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from google-api-python-client<3.0.0,>=2.115.0->llama-index-readers-google) (4.1.1) Requirement already satisfied: requests-oauthlib>=0.7.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from google-auth-oauthlib<2.0.0,>=1.2.0->llama-index-readers-google) (2.0.0) Requirement already satisfied: beautifulsoup4<5.0.0,>=4.12.3 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-readers-file<0.2.0,>=0.1.4->llama-index) (4.12.3) Requirement already satisfied: pypdf<5.0.0,>=4.0.1 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-readers-file<0.2.0,>=0.1.4->llama-index) (4.2.0) Requirement already satisfied: striprtf<0.0.27,>=0.0.26 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-readers-file<0.2.0,>=0.1.4->llama-index) (0.0.26) Requirement already satisfied: llama-parse<0.5.0,>=0.4.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llama-index-readers-llama-parse<0.2.0,>=0.1.2->llama-index) (0.4.4) Requirement already satisfied: oauth2client>=4.0.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from pydrive<2.0.0,>=1.3.1->llama-index-readers-google) (4.1.3) Requirement already satisfied: aiosignal>=1.1.2 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core==0.10.47->llama-index) (1.3.1) Requirement already satisfied: attrs>=17.3.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core==0.10.47->llama-index) (23.2.0) Requirement already satisfied: frozenlist>=1.1.1 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core==0.10.47->llama-index) (1.4.1) Requirement already satisfied: multidict<7.0,>=4.5 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core==0.10.47->llama-index) (6.0.5) Requirement already satisfied: yarl<2.0,>=1.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core==0.10.47->llama-index) (1.9.4) Requirement already satisfied: soupsieve>1.2 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from beautifulsoup4<5.0.0,>=4.12.3->llama-index-readers-file<0.2.0,>=0.1.4->llama-index) (2.5) Requirement already satisfied: googleapis-common-protos<2.0.dev0,>=1.56.2 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from google-api-core!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0.dev0,>=1.31.5->google-api-python-client<3.0.0,>=2.115.0->llama-index-readers-google) (1.63.1) Requirement already satisfied: protobuf!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0.dev0,>=3.19.5 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from google-api-core!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0.dev0,>=1.31.5->google-api-python-client<3.0.0,>=2.115.0->llama-index-readers-google) (4.25.3) Requirement already satisfied: proto-plus<2.0.0dev,>=1.22.3 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from google-api-core!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0.dev0,>=1.31.5->google-api-python-client<3.0.0,>=2.115.0->llama-index-readers-google) (1.24.0) Requirement already satisfied: cachetools<6.0,>=2.0.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from google-auth!=2.24.0,!=2.25.0,<3.0.0.dev0,>=1.32.0->google-api-python-client<3.0.0,>=2.115.0->llama-index-readers-google) (5.3.3) Requirement already satisfied: pyasn1-modules>=0.2.1 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from google-auth!=2.24.0,!=2.25.0,<3.0.0.dev0,>=1.32.0->google-api-python-client<3.0.0,>=2.115.0->llama-index-readers-google) (0.4.0) Requirement already satisfied: rsa<5,>=3.1.4 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from google-auth!=2.24.0,!=2.25.0,<3.0.0.dev0,>=1.32.0->google-api-python-client<3.0.0,>=2.115.0->llama-index-readers-google) (4.9) Requirement already satisfied: pycryptodomex>=3.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from gpsoauth>=1.0.3->gkeepapi<0.16.0,>=0.15.1->llama-index-readers-google) (3.20.0) Requirement already satisfied: urllib3<2.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from gpsoauth>=1.0.3->gkeepapi<0.16.0,>=0.15.1->llama-index-readers-google) (1.26.19) Requirement already satisfied: pyparsing!=3.0.0,!=3.0.1,!=3.0.2,!=3.0.3,<4,>=2.4.2 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from httplib2<1.dev0,>=0.19.0->google-api-python-client<3.0.0,>=2.115.0->llama-index-readers-google) (3.1.2) Requirement already satisfied: pydantic>=1.10 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from llamaindex-py-client<0.2.0,>=0.1.18->llama-index-core==0.10.47->llama-index) (2.7.4) Requirement already satisfied: anyio in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from httpx->llama-index-core==0.10.47->llama-index) (4.4.0) Requirement already satisfied: certifi in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from httpx->llama-index-core==0.10.47->llama-index) (2024.6.2) Requirement already satisfied: httpcore==1.* in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from httpx->llama-index-core==0.10.47->llama-index) (1.0.5) Requirement already satisfied: idna in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from httpx->llama-index-core==0.10.47->llama-index) (3.7) Requirement already satisfied: sniffio in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from httpx->llama-index-core==0.10.47->llama-index) (1.3.1) Requirement already satisfied: h11<0.15,>=0.13 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from httpcore==1.*->httpx->llama-index-core==0.10.47->llama-index) (0.14.0) Requirement already satisfied: click in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from nltk<4.0.0,>=3.8.1->llama-index-core==0.10.47->llama-index) (8.1.7) Requirement already satisfied: joblib in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from nltk<4.0.0,>=3.8.1->llama-index-core==0.10.47->llama-index) (1.4.2) Requirement already satisfied: regex>=2021.8.3 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from nltk<4.0.0,>=3.8.1->llama-index-core==0.10.47->llama-index) (2024.5.15) Requirement already satisfied: pyasn1>=0.1.7 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from oauth2client>=4.0.0->pydrive<2.0.0,>=1.3.1->llama-index-readers-google) (0.6.0) Requirement already satisfied: six>=1.6.1 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from oauth2client>=4.0.0->pydrive<2.0.0,>=1.3.1->llama-index-readers-google) (1.16.0) Requirement already satisfied: distro<2,>=1.7.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from openai>=1.1.0->llama-index-core==0.10.47->llama-index) (1.9.0) Requirement already satisfied: charset-normalizer<4,>=2 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from requests>=2.31.0->llama-index-core==0.10.47->llama-index) (3.3.2) Requirement already satisfied: oauthlib>=3.0.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<2.0.0,>=1.2.0->llama-index-readers-google) (3.2.2) Requirement already satisfied: greenlet!=0.4.17 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from SQLAlchemy>=1.4.49->SQLAlchemy[asyncio]>=1.4.49->llama-index-core==0.10.47->llama-index) (3.0.3) Requirement already satisfied: mypy-extensions>=0.3.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from typing-inspect>=0.8.0->llama-index-core==0.10.47->llama-index) (1.0.0) Requirement already satisfied: marshmallow<4.0.0,>=3.18.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from dataclasses-json->llama-index-core==0.10.47->llama-index) (3.21.3) Requirement already satisfied: python-dateutil>=2.8.2 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from pandas->llama-index-core==0.10.47->llama-index) (2.9.0.post0) Requirement already satisfied: pytz>=2020.1 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from pandas->llama-index-core==0.10.47->llama-index) (2024.1) Requirement already satisfied: tzdata>=2022.7 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from pandas->llama-index-core==0.10.47->llama-index) (2024.1) Requirement already satisfied: packaging>=17.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from marshmallow<4.0.0,>=3.18.0->dataclasses-json->llama-index-core==0.10.47->llama-index) (24.1) Requirement already satisfied: annotated-types>=0.4.0 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from pydantic>=1.10->llamaindex-py-client<0.2.0,>=0.1.18->llama-index-core==0.10.47->llama-index) (0.7.0) Requirement already satisfied: pydantic-core==2.18.4 in /Users/jonathanliu/Library/Caches/pypoetry/virtualenvs/llama-index-RvIdVF4_-py3.11/lib/python3.11/site-packages (from pydantic>=1.10->llamaindex-py-client<0.2.0,>=0.1.18->llama-index-core==0.10.47->llama-index) (2.18.4) [notice] A new release of pip is available: 24.0 -> 24.1 [notice] To update, run: pip install --upgrade pip Note: you may need to restart the kernel to use updated packages.
此加载器接受 Google Chat 空间或消息的 ID,并将聊天记录解析为 Document
对象。空间/消息 ID 可以在 URL 中找到,如下所示
- mail.google.com/chat/u/0/#chat/space/<CHAT_ID>
在使用此加载器之前,您需要创建一个具有 Google Workspace 帐户的 Google Cloud Platform (GCP) 项目。然后,您需要使用用户凭据授权该应用。请按照此指南中的先决条件以及步骤 1 和 2 进行操作。下载客户端密钥 JSON 文件后,将其重命名为 credentials.json
并保存到您的项目文件夹中。
此示例解析了两个用户之间的聊天。他们先讨论了数学作业,然后在某个线程中规划了旧金山之旅。最后,他们讨论了完成一篇论文。查看完整线程此处。
基本用法¶
下面的示例将整个聊天记录加载到 SummaryIndex
中。
from llama_index.core import SummaryIndex
from llama_index.readers.google import GoogleChatReader
space_ids = [
"AAAAtTPwdzg"
] # The Google account you authenticated with must have access to this space
reader = GoogleChatReader()
docs = reader.load_data(space_names=space_ids)
index = SummaryIndex.from_documents(docs)
query_engine = index.as_query_engine()
response = query_engine.query("What was the overall conversation about?")
from IPython.display import Markdown, display
display(Markdown(f"{response}"))
整体对话是关于讨论和规划旧金山之旅,包括参观各种地标以及使用公共交通在城市中穿梭。此外,还简要提到了在旅行前完成作业和论文。
过滤和排序¶
排序¶
您可以按升序或降序排列聊天记录。
docs = reader.load_data(space_names=space_ids, order_asc=False)
index = SummaryIndex.from_documents(docs)
query_engine = index.as_query_engine()
response = query_engine.query(
"List the things that the users discussed in the order they were discussed in. Make the list short."
)
display(Markdown(f"{response}"))
- 参观旧金山
- 规划旧金山旅行行程
- 乘坐公共交通前往旧金山
- 讨论旧金山的交通选择
- 一起做数学题
尽管消息是按倒序检索的,但列表仍然是正确的顺序,因为消息在其元数据中包含时间戳。
消息限制¶
可以使用 num_messages
参数将消息限制在一定数量。但是,加载的消息数量可能不完全等于此数字。如果 order_asc
为 True,则获取给定时间范围内的前 num_messages
条消息。如果 order_desc
为 True,则获取给定时间范围内的后 num_messages
条消息。
docs = reader.load_data(
space_names=space_ids, num_messages=10
) # in ascending order, only contains messages about math HW
index = SummaryIndex.from_documents(docs)
query_engine = index.as_query_engine()
response = query_engine.query("What was discussed in this conversation?")
display(Markdown(f"{response}"))
对话围绕着一个学生寻求数学作业帮助展开,特别是理解和应用微积分中的链式法则来求解包含余弦函数的导数。该学生在问题 4b 上遇到了困难,需要帮助求解 cos(2x) 的导数。另一位参与者逐步解释了链式法则的应用,得出了正确的导数 -2sin(2x)。寻求帮助的学生对解释表示感谢,并表示现在可以继续解决剩余的问题了。
注意,此摘要仅包含前 10 条消息,这些消息仅涉及数学作业方面的帮助。下面是检索最后 16 条消息的示例,这些消息仅涉及论文。“旅行费用”指的是在讨论论文期间,在旧金山旅行线程中的一条回复。
docs = reader.load_data(
space_names=space_ids, num_messages=16, order_asc=False
) # in descending order, only contains messages about essay
index = SummaryIndex.from_documents(docs)
query_engine = index.as_query_engine()
response = query_engine.query("What was discussed in this conversation?")
display(Markdown(f"{response}"))
对话围绕着一篇论文的完成展开,特别关注旧钱和新钱之间的对比,而不是美国梦和《了不起的盖茨比》。对话中提到了拖延、开始写论文以及对旅行费用的担忧。
时间范围¶
还可以指定 before
和 after
时间范围。这些参数接受 datetime
对象。
import datetime
date1 = datetime.datetime.fromisoformat(
"2024-06-25 14:27:00-07:00"
) # when they start talking about trip
docs = reader.load_data(space_names=space_ids, before=date1)
index = SummaryIndex.from_documents(docs)
query_engine = index.as_query_engine()
response = query_engine.query(
"What was discussed in this conversation?"
) # should only be about math HW
display(Markdown(f"{response}"))
对话围绕着一个学生寻求帮助理解微积分中的链式法则展开,特别是如何求解 cos(2x) 的导数。该学生在问题 4b 上遇到了困难并请求帮助,另一位学生逐步解释了链式法则的应用。解释清楚地说明了如何使用链式法则对 cos(2x) 进行微分,最终导数为 -2sin(2x)。寻求帮助的学生表达了感谢,并表示现在可以继续解决剩余的问题了。
date2 = datetime.datetime.fromisoformat(
"2024-06-25 14:51:00-07:00"
) # when they start talking about essay
docs = reader.load_data(space_names=space_ids, after=date2)
index = SummaryIndex.from_documents(docs)
query_engine = index.as_query_engine()
response = query_engine.query(
"What was discussed in this conversation?"
) # should only be about essay + cost of trip (in thread)
display(Markdown(f"{response}"))
对话围绕着完成一篇关于旧钱和新钱对比的论文、对旅行费用的担忧以及关于交通费用会很经济实惠的保证展开。
docs = reader.load_data(space_names=space_ids, after=date1, before=date2)
index = SummaryIndex.from_documents(docs)
query_engine = index.as_query_engine()
response = query_engine.query(
"What was discussed in this conversation?"
) # should only be about trip
display(Markdown(f"{response}"))
对话围绕着规划一个周末旧金山之旅展开。他们讨论了参观各种地标,如金门大桥、渔人码头和渡轮大厦,如果时间允许,还可能去恶魔岛或双子峰。他们还讨论了交通选择,如乘坐 Caltrain 或 BART,租用滑板车或 BayWheels 自行车,以及使用公共交通在城市中移动。此外,他们还提到了探索唐人街以及乘坐巴士路线返回市中心以增加灵活性。