Mbox Reader¶
如果您在 colab 上打开此 Notebook,您可能需要安装 LlamaIndex 🦙。
In [ ]
已复制!
%pip install llama-index-readers-mbox
%pip install llama-index-readers-mbox
In [ ]
已复制!
!pip install llama-index
!pip install llama-index
In [ ]
已复制!
%env OPENAI_API_KEY=sk-************
%env OPENAI_API_KEY=sk-************
In [ ]
已复制!
from llama_index.readers.mbox import MboxReader
from llama_index.core import VectorStoreIndex
from llama_index.readers.mbox import MboxReader from llama_index.core import VectorStoreIndex
In [ ]
已复制!
documents = MboxReader().load_data(
"mbox_data_dir", max_count=1000
) # Returns list of documents
documents = MboxReader().load_data( "mbox_data_dir", max_count=1000 ) # 返回文档列表
In [ ]
已复制!
index = VectorStoreIndex.from_documents(
documents
) # Initialize index with documents
index = VectorStoreIndex.from_documents( documents ) # 使用文档初始化索引
In [ ]
已复制!
query_engine = index.as_query_engine()
res = query_engine.query("When did i have that call with the London office?")
query_engine = index.as_query_engine() res = query_engine.query("When did i have that call with the London office?")
> [query] Total LLM token usage: 100 tokens > [query] Total embedding token usage: 10 tokens
In [ ]
已复制!
res.response
res.response
> There is a call scheduled with the London office at 12am GMT on the 10th of February.