Update app.py
Browse files
app.py
CHANGED
|
@@ -124,6 +124,7 @@ def split_biomodels(antimony_file_path):
|
|
| 124 |
file_content = f.read()
|
| 125 |
items = text_splitter.create_documents([file_content])
|
| 126 |
for item in items:
|
|
|
|
| 127 |
final_items.append(item)
|
| 128 |
break
|
| 129 |
except Exception as e:
|
|
@@ -272,12 +273,20 @@ def streamlit_app():
|
|
| 272 |
|
| 273 |
convert_sbml_to_antimony(model_file_path, antimony_file_path)
|
| 274 |
|
| 275 |
-
|
|
|
|
| 276 |
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 280 |
|
|
|
|
| 281 |
@st.cache_resource
|
| 282 |
def get_messages():
|
| 283 |
if "messages" not in st.session_state:
|
|
|
|
| 124 |
file_content = f.read()
|
| 125 |
items = text_splitter.create_documents([file_content])
|
| 126 |
for item in items:
|
| 127 |
+
item = str(item)
|
| 128 |
final_items.append(item)
|
| 129 |
break
|
| 130 |
except Exception as e:
|
|
|
|
| 273 |
|
| 274 |
convert_sbml_to_antimony(model_file_path, antimony_file_path)
|
| 275 |
|
| 276 |
+
# Ensure this returns items and not an empty list
|
| 277 |
+
final_items.extend(split_biomodels(antimony_file_path))
|
| 278 |
|
| 279 |
+
# Ensure final_items is not empty before creating the database
|
| 280 |
+
if final_items:
|
| 281 |
+
db = create_vector_db(final_items)
|
| 282 |
+
st.write("Models have been processed and added to the database.")
|
| 283 |
+
else:
|
| 284 |
+
st.error("No items found in the models. Check if the Antimony files were generated correctly.")
|
| 285 |
+
|
| 286 |
+
st.write("Models have processed and written to the database.")
|
| 287 |
+
|
| 288 |
|
| 289 |
+
# Avoid caching the database initialization, or ensure it's properly updated.
|
| 290 |
@st.cache_resource
|
| 291 |
def get_messages():
|
| 292 |
if "messages" not in st.session_state:
|