Spaces:
Sleeping
Sleeping
pbrenotvinciguerra
commited on
Commit
·
c859ac8
1
Parent(s):
eaeb55d
creating index locally then uploading
Browse files
app.py
CHANGED
@@ -16,15 +16,7 @@ llm = Anyscale(model="mistralai/Mistral-7B-Instruct-v0.1", api_key=os.getenv("AN
|
|
16 |
# query_embed_model = HuggingFaceEmbedding(model_name="BAAI/bge-base-en-v1.5")
|
17 |
embed_model = VoyageEmbedding(model_name="voyage-01", voyage_api_key=os.getenv("VOYAGE_API_KEY"))
|
18 |
service_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)
|
19 |
-
|
20 |
-
if "index" in os.listdir():
|
21 |
-
storage_context = StorageContext.from_defaults(persist_dir=Path("./index"))
|
22 |
-
else:
|
23 |
-
dir_reader = SimpleDirectoryReader(Path('./docs'))
|
24 |
-
documents = dir_reader.load_data()
|
25 |
-
index = VectorStoreIndex.from_documents(documents, service_context=service_context)
|
26 |
-
index.storage_context.persist(Path('./index'))
|
27 |
-
storage_context = StorageContext.from_defaults(persist_dir=Path("./index"))
|
28 |
|
29 |
# Load the vector stores that were created earlier.
|
30 |
index = load_index_from_storage(storage_context=storage_context, service_context=service_context)
|
|
|
16 |
# query_embed_model = HuggingFaceEmbedding(model_name="BAAI/bge-base-en-v1.5")
|
17 |
embed_model = VoyageEmbedding(model_name="voyage-01", voyage_api_key=os.getenv("VOYAGE_API_KEY"))
|
18 |
service_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)
|
19 |
+
storage_context = StorageContext.from_defaults(persist_dir=Path("./custom_index"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
# Load the vector stores that were created earlier.
|
22 |
index = load_index_from_storage(storage_context=storage_context, service_context=service_context)
|