Last active
November 3, 2023 02:07
-
-
Save igaiga/9a38e557aef1e0f1925a48958ef2ec44 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# $ pip install openai llama_index pypdf | |
from llama_index import GPTVectorStoreIndex, SimpleDirectoryReader | |
import openai | |
# APIキーを取得: https://platform.openai.com/account/api-keys | |
openai.api_key = "API KEYを書く" | |
# dataフォルダ以下のPDFファイルの読み込み | |
documents = SimpleDirectoryReader("data").load_data() | |
index = GPTVectorStoreIndex.from_documents(documents) | |
query_engine = index.as_query_engine() | |
question = "〇〇について教えてください" | |
response = query_engine.query(question) | |
print(response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment