TheBobBob commited on
Commit
10b33fb
·
verified ·
1 Parent(s): a335204

Upload main.py

Browse files
Files changed (1) hide show
  1. main.py +47 -0
main.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from biomodelcache import BioModelCacheRetrieval
2
+ from convert_sbml_to_antimony import convert_sbml_to_antimony
3
+ from split_biomodels import split_biomodels
4
+ from create_vector_db import create_vector_db
5
+ from generate_response import generate_response
6
+ import os
7
+ import tempfile
8
+
9
+ LOCAL_DOWNLOAD_DIR = tempfile.mkdtemp()
10
+
11
+ def main():
12
+ retriever = BioModelCacheRetrieval(search_str)
13
+ models = retriever.search_models()
14
+
15
+ if models:
16
+ all_final_items = []
17
+
18
+ for model_id, model_data in models.items():
19
+ print(f"Processing model: {model_data['name']}")
20
+
21
+ model_url = model_data['url']
22
+ model_file_path = retriever.download_model_files(model_url, model_id)
23
+
24
+ if model_file_path:
25
+ antimony_file_path = os.path.join(LOCAL_DOWNLOAD_DIR, f"{model_id}.txt")
26
+ convert_sbml_to_antimony(model_file_path, antimony_file_path)
27
+
28
+ final_items = split_biomodels(antimony_file_path)
29
+ all_final_items.extend(final_items)
30
+
31
+ if all_final_items:
32
+ db = create_vector_db(all_final_items)
33
+
34
+ query_text = input("Enter your question about the model(s): ")
35
+ response = generate_response(db, query_text)
36
+ print(f"Response: {response}")
37
+ else:
38
+ return ValueError("No models were processed successfully.")
39
+ else:
40
+ return ValueError("No models found matching your search query.")
41
+
42
+ if __name__ == "__main__":
43
+ search_str = input("Enter search query: ")
44
+ main(search_str)
45
+
46
+
47
+ #nosetests