Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修改 10|AI连接外部资料库,让Llama Index带你阅读一本书 #4

Open
oxygen172 opened this issue May 8, 2023 · 0 comments

Comments

@oxygen172
Copy link

@xuwenhao 最新的llama-index 不再支持GPTSimpleVectorIndex

https://github.com/xuwenhao/geektime-ai-course/blob/main/10_llama_index_to_read_a_book.ipynb


import openai, os
from llama_index import GPTSimpleVectorIndex, SimpleDirectoryReader

openai.api_key = os.environ.get("OPENAI_API_KEY")

documents = SimpleDirectoryReader('./data/mr_fujino').load_data()
index = GPTSimpleVectorIndex.from_documents(documents)

index.save_to_disk('index_mr_fujino.json')

上面的代码会报错,GPTSimpleVectorIndex要改成GPTVectorStoreIndex

需要改成下面的代码


import openai, os
from llama_index import GPTVectorStoreIndex, SimpleDirectoryReader

openai.api_key = os.environ.get("OPENAI_API_KEY")

documents = SimpleDirectoryReader('./data/mr_fujino').load_data()
index = GPTVectorStoreIndex.from_documents(documents)
index.storage_context.persist('index_mr_fujino.json')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant