some code i used
# define llm with HuggingFaceInferenceAPI
llm = HuggingFaceInferenceAPI(
model_name="HuggingFaceH4/zephyr-7b-beta",
token=os.environ.get("HUGGINGFACE_ACCESS_TOKEN")
)
# create QdrantClient with the location set to ":memory:", which means the vector db will be stored in memory
vectordb_client = qdrant_client.QdrantClient(location=":memory:")
# create QdrantVectorStore using QdrantClient and the collection name "wonderful_life"
vector_store = QdrantVectorStore(
client=vectordb_client, collection_name="wonderful_life"
)
# create StorageContext object using the QdrantVectorStore
storage_context = StorageContext.from_defaults(vector_store=vector_store)
node_parser = SentenceSplitter()
service_context = ServiceContext.from_defaults(
llm=llm,
embed_model="local:WhereIsAI/UAE-Large-V1",
callback_manager=callback_manager
)
# Build agents dictionary
query_engine_tools = []
for idx, wiki_title in enumerate(wiki_titles):
nodes = node_parser.get_nodes_from_documents(city_docs[wiki_title])
if not os.path.exists(f"./data/{wiki_title}"):
# build vector index
vector_index = VectorStoreIndex(
nodes, service_context=service_context, callback_manager=callback_manager,storage_context=storage_context,
)
vector_index.storage_context.persist(persist_dir=f"./data/{wiki_title}")
else:
vector_index = load_index_from_storage(
StorageContext.from_defaults(persist_dir=f"./data/{wiki_title}"),
service_context=service_context,
callback_manager=callback_manager,
)
# define query engines
vector_query_engine = vector_index.as_query_engine()