service_context = ServiceContext.from_defaults(embed_model=embed_model, llm_predictor=llm_predictor) index = GPTVectorStoreIndex.from_documents(documents,service_context=service_context) index.storage_context.persist()
加载本地知识向量并提问
1 2 3 4 5
storage_context = StorageContext.from_defaults(persist_dir='./storage') index = load_index_from_storage(storage_context, service_context=service_context) query_engine = index.as_query_engine() response = query_engine.query("<What are the diseases associated with macrophage>?") print(response.response)