Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,8 @@ from llama_index.core import Settings
|
|
| 7 |
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
|
| 8 |
from llama_index.llms.gemini import Gemini
|
| 9 |
from llama_index.core.postprocessor import SimilarityPostprocessor
|
|
|
|
|
|
|
| 10 |
|
| 11 |
HF_TOKEN=os.environ['token_r']
|
| 12 |
API_KEY=os.environ["GOOGLE_API_KEY"]
|
|
@@ -50,7 +52,11 @@ embed_model = HuggingFaceEmbedding(model_name=embed_model_name)
|
|
| 50 |
Settings.llm = llm
|
| 51 |
Settings.embed_model = embed_model
|
| 52 |
|
| 53 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
async def run_function_on_text(top_k,study_obj,study_type,phase,purpose,allocation,intervention_model,Masking,conditions,interventions,location_countries,removed_location_countries):
|
| 56 |
|
|
|
|
| 7 |
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
|
| 8 |
from llama_index.llms.gemini import Gemini
|
| 9 |
from llama_index.core.postprocessor import SimilarityPostprocessor
|
| 10 |
+
from llama_index.core.storage.docstore import SimpleDocumentStore
|
| 11 |
+
from llama_index.core import StorageContext, load_index_from_storage
|
| 12 |
|
| 13 |
HF_TOKEN=os.environ['token_r']
|
| 14 |
API_KEY=os.environ["GOOGLE_API_KEY"]
|
|
|
|
| 52 |
Settings.llm = llm
|
| 53 |
Settings.embed_model = embed_model
|
| 54 |
|
| 55 |
+
# rebuild storage context
|
| 56 |
+
storage_context = StorageContext.from_defaults(persist_dir="VectorStore")
|
| 57 |
+
# load index
|
| 58 |
+
index_persisted = load_index_from_storage(storage_context, index_id="vector_index")
|
| 59 |
+
|
| 60 |
|
| 61 |
async def run_function_on_text(top_k,study_obj,study_type,phase,purpose,allocation,intervention_model,Masking,conditions,interventions,location_countries,removed_location_countries):
|
| 62 |
|