Find answers from the community

Home
Members
mark-kh∇
m
mark-kh∇
Offline, last seen 3 months ago
Joined September 25, 2024
After parsing the nodes and persisting a vectorindex (specifically weaviate) I'm unable to load it
Plain Text
# Parse the nodes
docstore = SimpleDocumentStore()
docstore.add_documents(nodes)
storage_context = StorageContext.from_defaults(
    docstore=docstore,
    vector_store=vector_store,
)

# Create vecorstore
index = VectorStoreIndex(
    nodes=nodes,
    service_context=ServiceContext.from_defaults(llm=llm, embed_model=embedding),
    storage_context=storage_context,
)

# Persist
index.storage_context.persist("../index/frcb/")

# Reload
from llama_index.storage import StorageContext
from llama_index.storage.index_store import SimpleIndexStore
from llama_index.storage.docstore import SimpleDocumentStore

storage_context_loaded = StorageContext.from_defaults(
    vector_store=vector_store,
    docstore=SimpleDocumentStore.from_persist_path("../index/frcb/docstore.json"),
    index_store=SimpleIndexStore.from_persist_path("../index/frcb/index_store.json"),
    persist_dir="../index/frcb/",
)

from llama_index.indices.loading import load_index_from_storage

index_loaded = load_index_from_storage(
    storage_context=storage_context_loaded,
    service_context=ServiceContext.from_defaults(llm=llm, embed_model=embedding),
)

I know it's not retrieving properly because I'm getting Empty Response
Plain Text
engine_loaded = index_loaded.as_query_engine(
    similarity_top_k=10,
)
final_engine_loaded = SubQuestionQueryEngine.from_defaults(
    query_engine_tools=[
        QueryEngineTool(
            query_engine=engine_loaded,
            metadata=ToolMetadata(
                name="free_form_question_answer",
                description="financial insights.",
            ),
        )
    ],
    question_gen=question_gen,
    service_context=ServiceContext.from_defaults(llm=llm, embed_model=embedding),
    use_async=True,
)
4 comments
m
L
W