aiagents4pharma 0.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (336) hide show
  1. aiagents4pharma/__init__.py +11 -0
  2. aiagents4pharma/talk2aiagents4pharma/.dockerignore +13 -0
  3. aiagents4pharma/talk2aiagents4pharma/Dockerfile +133 -0
  4. aiagents4pharma/talk2aiagents4pharma/README.md +1 -0
  5. aiagents4pharma/talk2aiagents4pharma/__init__.py +5 -0
  6. aiagents4pharma/talk2aiagents4pharma/agents/__init__.py +6 -0
  7. aiagents4pharma/talk2aiagents4pharma/agents/main_agent.py +70 -0
  8. aiagents4pharma/talk2aiagents4pharma/configs/__init__.py +5 -0
  9. aiagents4pharma/talk2aiagents4pharma/configs/agents/__init__.py +5 -0
  10. aiagents4pharma/talk2aiagents4pharma/configs/agents/main_agent/default.yaml +29 -0
  11. aiagents4pharma/talk2aiagents4pharma/configs/app/__init__.py +0 -0
  12. aiagents4pharma/talk2aiagents4pharma/configs/app/frontend/__init__.py +0 -0
  13. aiagents4pharma/talk2aiagents4pharma/configs/app/frontend/default.yaml +102 -0
  14. aiagents4pharma/talk2aiagents4pharma/configs/config.yaml +4 -0
  15. aiagents4pharma/talk2aiagents4pharma/docker-compose/cpu/.env.example +23 -0
  16. aiagents4pharma/talk2aiagents4pharma/docker-compose/cpu/docker-compose.yml +93 -0
  17. aiagents4pharma/talk2aiagents4pharma/docker-compose/gpu/.env.example +23 -0
  18. aiagents4pharma/talk2aiagents4pharma/docker-compose/gpu/docker-compose.yml +108 -0
  19. aiagents4pharma/talk2aiagents4pharma/install.md +154 -0
  20. aiagents4pharma/talk2aiagents4pharma/states/__init__.py +5 -0
  21. aiagents4pharma/talk2aiagents4pharma/states/state_talk2aiagents4pharma.py +18 -0
  22. aiagents4pharma/talk2aiagents4pharma/tests/__init__.py +3 -0
  23. aiagents4pharma/talk2aiagents4pharma/tests/test_main_agent.py +312 -0
  24. aiagents4pharma/talk2biomodels/.dockerignore +13 -0
  25. aiagents4pharma/talk2biomodels/Dockerfile +104 -0
  26. aiagents4pharma/talk2biomodels/README.md +1 -0
  27. aiagents4pharma/talk2biomodels/__init__.py +5 -0
  28. aiagents4pharma/talk2biomodels/agents/__init__.py +6 -0
  29. aiagents4pharma/talk2biomodels/agents/t2b_agent.py +104 -0
  30. aiagents4pharma/talk2biomodels/api/__init__.py +5 -0
  31. aiagents4pharma/talk2biomodels/api/ols.py +75 -0
  32. aiagents4pharma/talk2biomodels/api/uniprot.py +36 -0
  33. aiagents4pharma/talk2biomodels/configs/__init__.py +5 -0
  34. aiagents4pharma/talk2biomodels/configs/agents/__init__.py +5 -0
  35. aiagents4pharma/talk2biomodels/configs/agents/t2b_agent/__init__.py +3 -0
  36. aiagents4pharma/talk2biomodels/configs/agents/t2b_agent/default.yaml +14 -0
  37. aiagents4pharma/talk2biomodels/configs/app/__init__.py +0 -0
  38. aiagents4pharma/talk2biomodels/configs/app/frontend/__init__.py +0 -0
  39. aiagents4pharma/talk2biomodels/configs/app/frontend/default.yaml +72 -0
  40. aiagents4pharma/talk2biomodels/configs/config.yaml +7 -0
  41. aiagents4pharma/talk2biomodels/configs/tools/__init__.py +5 -0
  42. aiagents4pharma/talk2biomodels/configs/tools/ask_question/__init__.py +3 -0
  43. aiagents4pharma/talk2biomodels/configs/tools/ask_question/default.yaml +30 -0
  44. aiagents4pharma/talk2biomodels/configs/tools/custom_plotter/__init__.py +3 -0
  45. aiagents4pharma/talk2biomodels/configs/tools/custom_plotter/default.yaml +8 -0
  46. aiagents4pharma/talk2biomodels/configs/tools/get_annotation/__init__.py +3 -0
  47. aiagents4pharma/talk2biomodels/configs/tools/get_annotation/default.yaml +8 -0
  48. aiagents4pharma/talk2biomodels/install.md +63 -0
  49. aiagents4pharma/talk2biomodels/models/__init__.py +5 -0
  50. aiagents4pharma/talk2biomodels/models/basico_model.py +125 -0
  51. aiagents4pharma/talk2biomodels/models/sys_bio_model.py +60 -0
  52. aiagents4pharma/talk2biomodels/states/__init__.py +6 -0
  53. aiagents4pharma/talk2biomodels/states/state_talk2biomodels.py +49 -0
  54. aiagents4pharma/talk2biomodels/tests/BIOMD0000000449_url.xml +1585 -0
  55. aiagents4pharma/talk2biomodels/tests/__init__.py +3 -0
  56. aiagents4pharma/talk2biomodels/tests/article_on_model_537.pdf +0 -0
  57. aiagents4pharma/talk2biomodels/tests/test_api.py +31 -0
  58. aiagents4pharma/talk2biomodels/tests/test_ask_question.py +42 -0
  59. aiagents4pharma/talk2biomodels/tests/test_basico_model.py +67 -0
  60. aiagents4pharma/talk2biomodels/tests/test_get_annotation.py +190 -0
  61. aiagents4pharma/talk2biomodels/tests/test_getmodelinfo.py +92 -0
  62. aiagents4pharma/talk2biomodels/tests/test_integration.py +116 -0
  63. aiagents4pharma/talk2biomodels/tests/test_load_biomodel.py +35 -0
  64. aiagents4pharma/talk2biomodels/tests/test_param_scan.py +71 -0
  65. aiagents4pharma/talk2biomodels/tests/test_query_article.py +184 -0
  66. aiagents4pharma/talk2biomodels/tests/test_save_model.py +47 -0
  67. aiagents4pharma/talk2biomodels/tests/test_search_models.py +35 -0
  68. aiagents4pharma/talk2biomodels/tests/test_simulate_model.py +44 -0
  69. aiagents4pharma/talk2biomodels/tests/test_steady_state.py +86 -0
  70. aiagents4pharma/talk2biomodels/tests/test_sys_bio_model.py +67 -0
  71. aiagents4pharma/talk2biomodels/tools/__init__.py +17 -0
  72. aiagents4pharma/talk2biomodels/tools/ask_question.py +125 -0
  73. aiagents4pharma/talk2biomodels/tools/custom_plotter.py +165 -0
  74. aiagents4pharma/talk2biomodels/tools/get_annotation.py +342 -0
  75. aiagents4pharma/talk2biomodels/tools/get_modelinfo.py +159 -0
  76. aiagents4pharma/talk2biomodels/tools/load_arguments.py +134 -0
  77. aiagents4pharma/talk2biomodels/tools/load_biomodel.py +44 -0
  78. aiagents4pharma/talk2biomodels/tools/parameter_scan.py +310 -0
  79. aiagents4pharma/talk2biomodels/tools/query_article.py +64 -0
  80. aiagents4pharma/talk2biomodels/tools/save_model.py +98 -0
  81. aiagents4pharma/talk2biomodels/tools/search_models.py +96 -0
  82. aiagents4pharma/talk2biomodels/tools/simulate_model.py +137 -0
  83. aiagents4pharma/talk2biomodels/tools/steady_state.py +187 -0
  84. aiagents4pharma/talk2biomodels/tools/utils.py +23 -0
  85. aiagents4pharma/talk2cells/README.md +1 -0
  86. aiagents4pharma/talk2cells/__init__.py +5 -0
  87. aiagents4pharma/talk2cells/agents/__init__.py +6 -0
  88. aiagents4pharma/talk2cells/agents/scp_agent.py +87 -0
  89. aiagents4pharma/talk2cells/states/__init__.py +6 -0
  90. aiagents4pharma/talk2cells/states/state_talk2cells.py +15 -0
  91. aiagents4pharma/talk2cells/tests/scp_agent/test_scp_agent.py +22 -0
  92. aiagents4pharma/talk2cells/tools/__init__.py +6 -0
  93. aiagents4pharma/talk2cells/tools/scp_agent/__init__.py +6 -0
  94. aiagents4pharma/talk2cells/tools/scp_agent/display_studies.py +27 -0
  95. aiagents4pharma/talk2cells/tools/scp_agent/search_studies.py +78 -0
  96. aiagents4pharma/talk2knowledgegraphs/.dockerignore +13 -0
  97. aiagents4pharma/talk2knowledgegraphs/Dockerfile +131 -0
  98. aiagents4pharma/talk2knowledgegraphs/README.md +1 -0
  99. aiagents4pharma/talk2knowledgegraphs/__init__.py +5 -0
  100. aiagents4pharma/talk2knowledgegraphs/agents/__init__.py +5 -0
  101. aiagents4pharma/talk2knowledgegraphs/agents/t2kg_agent.py +99 -0
  102. aiagents4pharma/talk2knowledgegraphs/configs/__init__.py +5 -0
  103. aiagents4pharma/talk2knowledgegraphs/configs/agents/t2kg_agent/__init__.py +3 -0
  104. aiagents4pharma/talk2knowledgegraphs/configs/agents/t2kg_agent/default.yaml +62 -0
  105. aiagents4pharma/talk2knowledgegraphs/configs/app/__init__.py +5 -0
  106. aiagents4pharma/talk2knowledgegraphs/configs/app/frontend/__init__.py +3 -0
  107. aiagents4pharma/talk2knowledgegraphs/configs/app/frontend/default.yaml +79 -0
  108. aiagents4pharma/talk2knowledgegraphs/configs/config.yaml +13 -0
  109. aiagents4pharma/talk2knowledgegraphs/configs/tools/__init__.py +5 -0
  110. aiagents4pharma/talk2knowledgegraphs/configs/tools/graphrag_reasoning/__init__.py +3 -0
  111. aiagents4pharma/talk2knowledgegraphs/configs/tools/graphrag_reasoning/default.yaml +24 -0
  112. aiagents4pharma/talk2knowledgegraphs/configs/tools/multimodal_subgraph_extraction/__init__.py +0 -0
  113. aiagents4pharma/talk2knowledgegraphs/configs/tools/multimodal_subgraph_extraction/default.yaml +33 -0
  114. aiagents4pharma/talk2knowledgegraphs/configs/tools/subgraph_extraction/__init__.py +3 -0
  115. aiagents4pharma/talk2knowledgegraphs/configs/tools/subgraph_extraction/default.yaml +43 -0
  116. aiagents4pharma/talk2knowledgegraphs/configs/tools/subgraph_summarization/__init__.py +3 -0
  117. aiagents4pharma/talk2knowledgegraphs/configs/tools/subgraph_summarization/default.yaml +9 -0
  118. aiagents4pharma/talk2knowledgegraphs/configs/utils/database/milvus/__init__.py +3 -0
  119. aiagents4pharma/talk2knowledgegraphs/configs/utils/database/milvus/default.yaml +61 -0
  120. aiagents4pharma/talk2knowledgegraphs/configs/utils/enrichments/ols_terms/default.yaml +3 -0
  121. aiagents4pharma/talk2knowledgegraphs/configs/utils/enrichments/reactome_pathways/default.yaml +3 -0
  122. aiagents4pharma/talk2knowledgegraphs/configs/utils/enrichments/uniprot_proteins/default.yaml +6 -0
  123. aiagents4pharma/talk2knowledgegraphs/configs/utils/pubchem_utils/default.yaml +5 -0
  124. aiagents4pharma/talk2knowledgegraphs/datasets/__init__.py +5 -0
  125. aiagents4pharma/talk2knowledgegraphs/datasets/biobridge_primekg.py +607 -0
  126. aiagents4pharma/talk2knowledgegraphs/datasets/dataset.py +25 -0
  127. aiagents4pharma/talk2knowledgegraphs/datasets/primekg.py +212 -0
  128. aiagents4pharma/talk2knowledgegraphs/datasets/starkqa_primekg.py +210 -0
  129. aiagents4pharma/talk2knowledgegraphs/docker-compose/cpu/.env.example +23 -0
  130. aiagents4pharma/talk2knowledgegraphs/docker-compose/cpu/docker-compose.yml +93 -0
  131. aiagents4pharma/talk2knowledgegraphs/docker-compose/gpu/.env.example +23 -0
  132. aiagents4pharma/talk2knowledgegraphs/docker-compose/gpu/docker-compose.yml +108 -0
  133. aiagents4pharma/talk2knowledgegraphs/entrypoint.sh +180 -0
  134. aiagents4pharma/talk2knowledgegraphs/install.md +165 -0
  135. aiagents4pharma/talk2knowledgegraphs/milvus_data_dump.py +886 -0
  136. aiagents4pharma/talk2knowledgegraphs/states/__init__.py +5 -0
  137. aiagents4pharma/talk2knowledgegraphs/states/state_talk2knowledgegraphs.py +40 -0
  138. aiagents4pharma/talk2knowledgegraphs/tests/__init__.py +0 -0
  139. aiagents4pharma/talk2knowledgegraphs/tests/test_agents_t2kg_agent.py +318 -0
  140. aiagents4pharma/talk2knowledgegraphs/tests/test_datasets_biobridge_primekg.py +248 -0
  141. aiagents4pharma/talk2knowledgegraphs/tests/test_datasets_dataset.py +33 -0
  142. aiagents4pharma/talk2knowledgegraphs/tests/test_datasets_primekg.py +86 -0
  143. aiagents4pharma/talk2knowledgegraphs/tests/test_datasets_starkqa_primekg.py +125 -0
  144. aiagents4pharma/talk2knowledgegraphs/tests/test_tools_graphrag_reasoning.py +257 -0
  145. aiagents4pharma/talk2knowledgegraphs/tests/test_tools_milvus_multimodal_subgraph_extraction.py +1444 -0
  146. aiagents4pharma/talk2knowledgegraphs/tests/test_tools_multimodal_subgraph_extraction.py +159 -0
  147. aiagents4pharma/talk2knowledgegraphs/tests/test_tools_subgraph_extraction.py +152 -0
  148. aiagents4pharma/talk2knowledgegraphs/tests/test_tools_subgraph_summarization.py +201 -0
  149. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_database_milvus_connection_manager.py +812 -0
  150. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_embeddings_embeddings.py +51 -0
  151. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_embeddings_huggingface.py +49 -0
  152. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_embeddings_nim_molmim.py +59 -0
  153. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_embeddings_ollama.py +63 -0
  154. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_embeddings_sentencetransformer.py +47 -0
  155. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_enrichments_enrichments.py +40 -0
  156. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_enrichments_ollama.py +94 -0
  157. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_enrichments_ols.py +70 -0
  158. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_enrichments_pubchem.py +45 -0
  159. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_enrichments_reactome.py +44 -0
  160. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_enrichments_uniprot.py +48 -0
  161. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_extractions_milvus_multimodal_pcst.py +759 -0
  162. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_kg_utils.py +78 -0
  163. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_pubchem_utils.py +123 -0
  164. aiagents4pharma/talk2knowledgegraphs/tools/__init__.py +11 -0
  165. aiagents4pharma/talk2knowledgegraphs/tools/graphrag_reasoning.py +138 -0
  166. aiagents4pharma/talk2knowledgegraphs/tools/load_arguments.py +22 -0
  167. aiagents4pharma/talk2knowledgegraphs/tools/milvus_multimodal_subgraph_extraction.py +965 -0
  168. aiagents4pharma/talk2knowledgegraphs/tools/multimodal_subgraph_extraction.py +374 -0
  169. aiagents4pharma/talk2knowledgegraphs/tools/subgraph_extraction.py +291 -0
  170. aiagents4pharma/talk2knowledgegraphs/tools/subgraph_summarization.py +123 -0
  171. aiagents4pharma/talk2knowledgegraphs/utils/__init__.py +5 -0
  172. aiagents4pharma/talk2knowledgegraphs/utils/database/__init__.py +5 -0
  173. aiagents4pharma/talk2knowledgegraphs/utils/database/milvus_connection_manager.py +586 -0
  174. aiagents4pharma/talk2knowledgegraphs/utils/embeddings/__init__.py +5 -0
  175. aiagents4pharma/talk2knowledgegraphs/utils/embeddings/embeddings.py +81 -0
  176. aiagents4pharma/talk2knowledgegraphs/utils/embeddings/huggingface.py +111 -0
  177. aiagents4pharma/talk2knowledgegraphs/utils/embeddings/nim_molmim.py +54 -0
  178. aiagents4pharma/talk2knowledgegraphs/utils/embeddings/ollama.py +87 -0
  179. aiagents4pharma/talk2knowledgegraphs/utils/embeddings/sentence_transformer.py +73 -0
  180. aiagents4pharma/talk2knowledgegraphs/utils/enrichments/__init__.py +12 -0
  181. aiagents4pharma/talk2knowledgegraphs/utils/enrichments/enrichments.py +37 -0
  182. aiagents4pharma/talk2knowledgegraphs/utils/enrichments/ollama.py +129 -0
  183. aiagents4pharma/talk2knowledgegraphs/utils/enrichments/ols_terms.py +89 -0
  184. aiagents4pharma/talk2knowledgegraphs/utils/enrichments/pubchem_strings.py +78 -0
  185. aiagents4pharma/talk2knowledgegraphs/utils/enrichments/reactome_pathways.py +71 -0
  186. aiagents4pharma/talk2knowledgegraphs/utils/enrichments/uniprot_proteins.py +98 -0
  187. aiagents4pharma/talk2knowledgegraphs/utils/extractions/__init__.py +5 -0
  188. aiagents4pharma/talk2knowledgegraphs/utils/extractions/milvus_multimodal_pcst.py +762 -0
  189. aiagents4pharma/talk2knowledgegraphs/utils/extractions/multimodal_pcst.py +298 -0
  190. aiagents4pharma/talk2knowledgegraphs/utils/extractions/pcst.py +229 -0
  191. aiagents4pharma/talk2knowledgegraphs/utils/kg_utils.py +67 -0
  192. aiagents4pharma/talk2knowledgegraphs/utils/pubchem_utils.py +104 -0
  193. aiagents4pharma/talk2scholars/.dockerignore +13 -0
  194. aiagents4pharma/talk2scholars/Dockerfile +104 -0
  195. aiagents4pharma/talk2scholars/README.md +1 -0
  196. aiagents4pharma/talk2scholars/__init__.py +7 -0
  197. aiagents4pharma/talk2scholars/agents/__init__.py +13 -0
  198. aiagents4pharma/talk2scholars/agents/main_agent.py +89 -0
  199. aiagents4pharma/talk2scholars/agents/paper_download_agent.py +96 -0
  200. aiagents4pharma/talk2scholars/agents/pdf_agent.py +101 -0
  201. aiagents4pharma/talk2scholars/agents/s2_agent.py +135 -0
  202. aiagents4pharma/talk2scholars/agents/zotero_agent.py +127 -0
  203. aiagents4pharma/talk2scholars/configs/__init__.py +7 -0
  204. aiagents4pharma/talk2scholars/configs/agents/__init__.py +7 -0
  205. aiagents4pharma/talk2scholars/configs/agents/talk2scholars/__init__.py +7 -0
  206. aiagents4pharma/talk2scholars/configs/agents/talk2scholars/main_agent/__init__.py +3 -0
  207. aiagents4pharma/talk2scholars/configs/agents/talk2scholars/main_agent/default.yaml +52 -0
  208. aiagents4pharma/talk2scholars/configs/agents/talk2scholars/paper_download_agent/__init__.py +3 -0
  209. aiagents4pharma/talk2scholars/configs/agents/talk2scholars/paper_download_agent/default.yaml +19 -0
  210. aiagents4pharma/talk2scholars/configs/agents/talk2scholars/pdf_agent/__init__.py +3 -0
  211. aiagents4pharma/talk2scholars/configs/agents/talk2scholars/pdf_agent/default.yaml +19 -0
  212. aiagents4pharma/talk2scholars/configs/agents/talk2scholars/s2_agent/__init__.py +3 -0
  213. aiagents4pharma/talk2scholars/configs/agents/talk2scholars/s2_agent/default.yaml +44 -0
  214. aiagents4pharma/talk2scholars/configs/agents/talk2scholars/zotero_agent/__init__.py +3 -0
  215. aiagents4pharma/talk2scholars/configs/agents/talk2scholars/zotero_agent/default.yaml +19 -0
  216. aiagents4pharma/talk2scholars/configs/app/__init__.py +7 -0
  217. aiagents4pharma/talk2scholars/configs/app/frontend/__init__.py +3 -0
  218. aiagents4pharma/talk2scholars/configs/app/frontend/default.yaml +72 -0
  219. aiagents4pharma/talk2scholars/configs/config.yaml +16 -0
  220. aiagents4pharma/talk2scholars/configs/tools/__init__.py +21 -0
  221. aiagents4pharma/talk2scholars/configs/tools/multi_paper_recommendation/__init__.py +3 -0
  222. aiagents4pharma/talk2scholars/configs/tools/multi_paper_recommendation/default.yaml +26 -0
  223. aiagents4pharma/talk2scholars/configs/tools/paper_download/__init__.py +3 -0
  224. aiagents4pharma/talk2scholars/configs/tools/paper_download/default.yaml +124 -0
  225. aiagents4pharma/talk2scholars/configs/tools/question_and_answer/__init__.py +3 -0
  226. aiagents4pharma/talk2scholars/configs/tools/question_and_answer/default.yaml +62 -0
  227. aiagents4pharma/talk2scholars/configs/tools/retrieve_semantic_scholar_paper_id/__init__.py +3 -0
  228. aiagents4pharma/talk2scholars/configs/tools/retrieve_semantic_scholar_paper_id/default.yaml +12 -0
  229. aiagents4pharma/talk2scholars/configs/tools/search/__init__.py +3 -0
  230. aiagents4pharma/talk2scholars/configs/tools/search/default.yaml +26 -0
  231. aiagents4pharma/talk2scholars/configs/tools/single_paper_recommendation/__init__.py +3 -0
  232. aiagents4pharma/talk2scholars/configs/tools/single_paper_recommendation/default.yaml +26 -0
  233. aiagents4pharma/talk2scholars/configs/tools/zotero_read/__init__.py +3 -0
  234. aiagents4pharma/talk2scholars/configs/tools/zotero_read/default.yaml +57 -0
  235. aiagents4pharma/talk2scholars/configs/tools/zotero_write/__inti__.py +3 -0
  236. aiagents4pharma/talk2scholars/configs/tools/zotero_write/default.yaml +55 -0
  237. aiagents4pharma/talk2scholars/docker-compose/cpu/.env.example +21 -0
  238. aiagents4pharma/talk2scholars/docker-compose/cpu/docker-compose.yml +90 -0
  239. aiagents4pharma/talk2scholars/docker-compose/gpu/.env.example +21 -0
  240. aiagents4pharma/talk2scholars/docker-compose/gpu/docker-compose.yml +105 -0
  241. aiagents4pharma/talk2scholars/install.md +122 -0
  242. aiagents4pharma/talk2scholars/state/__init__.py +7 -0
  243. aiagents4pharma/talk2scholars/state/state_talk2scholars.py +98 -0
  244. aiagents4pharma/talk2scholars/tests/__init__.py +3 -0
  245. aiagents4pharma/talk2scholars/tests/test_agents_main_agent.py +256 -0
  246. aiagents4pharma/talk2scholars/tests/test_agents_paper_agents_download_agent.py +139 -0
  247. aiagents4pharma/talk2scholars/tests/test_agents_pdf_agent.py +114 -0
  248. aiagents4pharma/talk2scholars/tests/test_agents_s2_agent.py +198 -0
  249. aiagents4pharma/talk2scholars/tests/test_agents_zotero_agent.py +160 -0
  250. aiagents4pharma/talk2scholars/tests/test_s2_tools_display_dataframe.py +91 -0
  251. aiagents4pharma/talk2scholars/tests/test_s2_tools_query_dataframe.py +191 -0
  252. aiagents4pharma/talk2scholars/tests/test_states_state.py +38 -0
  253. aiagents4pharma/talk2scholars/tests/test_tools_paper_downloader.py +507 -0
  254. aiagents4pharma/talk2scholars/tests/test_tools_question_and_answer_tool.py +105 -0
  255. aiagents4pharma/talk2scholars/tests/test_tools_s2_multi.py +307 -0
  256. aiagents4pharma/talk2scholars/tests/test_tools_s2_retrieve.py +67 -0
  257. aiagents4pharma/talk2scholars/tests/test_tools_s2_search.py +286 -0
  258. aiagents4pharma/talk2scholars/tests/test_tools_s2_single.py +298 -0
  259. aiagents4pharma/talk2scholars/tests/test_utils_arxiv_downloader.py +469 -0
  260. aiagents4pharma/talk2scholars/tests/test_utils_base_paper_downloader.py +598 -0
  261. aiagents4pharma/talk2scholars/tests/test_utils_biorxiv_downloader.py +669 -0
  262. aiagents4pharma/talk2scholars/tests/test_utils_medrxiv_downloader.py +500 -0
  263. aiagents4pharma/talk2scholars/tests/test_utils_nvidia_nim_reranker.py +117 -0
  264. aiagents4pharma/talk2scholars/tests/test_utils_pdf_answer_formatter.py +67 -0
  265. aiagents4pharma/talk2scholars/tests/test_utils_pdf_batch_processor.py +92 -0
  266. aiagents4pharma/talk2scholars/tests/test_utils_pdf_collection_manager.py +173 -0
  267. aiagents4pharma/talk2scholars/tests/test_utils_pdf_document_processor.py +68 -0
  268. aiagents4pharma/talk2scholars/tests/test_utils_pdf_generate_answer.py +72 -0
  269. aiagents4pharma/talk2scholars/tests/test_utils_pdf_gpu_detection.py +129 -0
  270. aiagents4pharma/talk2scholars/tests/test_utils_pdf_paper_loader.py +116 -0
  271. aiagents4pharma/talk2scholars/tests/test_utils_pdf_rag_pipeline.py +88 -0
  272. aiagents4pharma/talk2scholars/tests/test_utils_pdf_retrieve_chunks.py +190 -0
  273. aiagents4pharma/talk2scholars/tests/test_utils_pdf_singleton_manager.py +159 -0
  274. aiagents4pharma/talk2scholars/tests/test_utils_pdf_vector_normalization.py +121 -0
  275. aiagents4pharma/talk2scholars/tests/test_utils_pdf_vector_store.py +406 -0
  276. aiagents4pharma/talk2scholars/tests/test_utils_pubmed_downloader.py +1007 -0
  277. aiagents4pharma/talk2scholars/tests/test_utils_read_helper_utils.py +106 -0
  278. aiagents4pharma/talk2scholars/tests/test_utils_s2_utils_ext_ids.py +403 -0
  279. aiagents4pharma/talk2scholars/tests/test_utils_tool_helper_utils.py +85 -0
  280. aiagents4pharma/talk2scholars/tests/test_utils_zotero_human_in_the_loop.py +266 -0
  281. aiagents4pharma/talk2scholars/tests/test_utils_zotero_path.py +496 -0
  282. aiagents4pharma/talk2scholars/tests/test_utils_zotero_pdf_downloader_utils.py +46 -0
  283. aiagents4pharma/talk2scholars/tests/test_utils_zotero_read.py +743 -0
  284. aiagents4pharma/talk2scholars/tests/test_utils_zotero_write.py +151 -0
  285. aiagents4pharma/talk2scholars/tools/__init__.py +9 -0
  286. aiagents4pharma/talk2scholars/tools/paper_download/__init__.py +12 -0
  287. aiagents4pharma/talk2scholars/tools/paper_download/paper_downloader.py +442 -0
  288. aiagents4pharma/talk2scholars/tools/paper_download/utils/__init__.py +22 -0
  289. aiagents4pharma/talk2scholars/tools/paper_download/utils/arxiv_downloader.py +207 -0
  290. aiagents4pharma/talk2scholars/tools/paper_download/utils/base_paper_downloader.py +336 -0
  291. aiagents4pharma/talk2scholars/tools/paper_download/utils/biorxiv_downloader.py +313 -0
  292. aiagents4pharma/talk2scholars/tools/paper_download/utils/medrxiv_downloader.py +196 -0
  293. aiagents4pharma/talk2scholars/tools/paper_download/utils/pubmed_downloader.py +323 -0
  294. aiagents4pharma/talk2scholars/tools/pdf/__init__.py +7 -0
  295. aiagents4pharma/talk2scholars/tools/pdf/question_and_answer.py +170 -0
  296. aiagents4pharma/talk2scholars/tools/pdf/utils/__init__.py +37 -0
  297. aiagents4pharma/talk2scholars/tools/pdf/utils/answer_formatter.py +62 -0
  298. aiagents4pharma/talk2scholars/tools/pdf/utils/batch_processor.py +198 -0
  299. aiagents4pharma/talk2scholars/tools/pdf/utils/collection_manager.py +172 -0
  300. aiagents4pharma/talk2scholars/tools/pdf/utils/document_processor.py +76 -0
  301. aiagents4pharma/talk2scholars/tools/pdf/utils/generate_answer.py +97 -0
  302. aiagents4pharma/talk2scholars/tools/pdf/utils/get_vectorstore.py +59 -0
  303. aiagents4pharma/talk2scholars/tools/pdf/utils/gpu_detection.py +150 -0
  304. aiagents4pharma/talk2scholars/tools/pdf/utils/nvidia_nim_reranker.py +97 -0
  305. aiagents4pharma/talk2scholars/tools/pdf/utils/paper_loader.py +123 -0
  306. aiagents4pharma/talk2scholars/tools/pdf/utils/rag_pipeline.py +113 -0
  307. aiagents4pharma/talk2scholars/tools/pdf/utils/retrieve_chunks.py +197 -0
  308. aiagents4pharma/talk2scholars/tools/pdf/utils/singleton_manager.py +140 -0
  309. aiagents4pharma/talk2scholars/tools/pdf/utils/tool_helper.py +86 -0
  310. aiagents4pharma/talk2scholars/tools/pdf/utils/vector_normalization.py +150 -0
  311. aiagents4pharma/talk2scholars/tools/pdf/utils/vector_store.py +327 -0
  312. aiagents4pharma/talk2scholars/tools/s2/__init__.py +21 -0
  313. aiagents4pharma/talk2scholars/tools/s2/display_dataframe.py +110 -0
  314. aiagents4pharma/talk2scholars/tools/s2/multi_paper_rec.py +111 -0
  315. aiagents4pharma/talk2scholars/tools/s2/query_dataframe.py +233 -0
  316. aiagents4pharma/talk2scholars/tools/s2/retrieve_semantic_scholar_paper_id.py +128 -0
  317. aiagents4pharma/talk2scholars/tools/s2/search.py +101 -0
  318. aiagents4pharma/talk2scholars/tools/s2/single_paper_rec.py +102 -0
  319. aiagents4pharma/talk2scholars/tools/s2/utils/__init__.py +5 -0
  320. aiagents4pharma/talk2scholars/tools/s2/utils/multi_helper.py +223 -0
  321. aiagents4pharma/talk2scholars/tools/s2/utils/search_helper.py +205 -0
  322. aiagents4pharma/talk2scholars/tools/s2/utils/single_helper.py +216 -0
  323. aiagents4pharma/talk2scholars/tools/zotero/__init__.py +7 -0
  324. aiagents4pharma/talk2scholars/tools/zotero/utils/__init__.py +7 -0
  325. aiagents4pharma/talk2scholars/tools/zotero/utils/read_helper.py +270 -0
  326. aiagents4pharma/talk2scholars/tools/zotero/utils/review_helper.py +74 -0
  327. aiagents4pharma/talk2scholars/tools/zotero/utils/write_helper.py +194 -0
  328. aiagents4pharma/talk2scholars/tools/zotero/utils/zotero_path.py +180 -0
  329. aiagents4pharma/talk2scholars/tools/zotero/utils/zotero_pdf_downloader.py +133 -0
  330. aiagents4pharma/talk2scholars/tools/zotero/zotero_read.py +105 -0
  331. aiagents4pharma/talk2scholars/tools/zotero/zotero_review.py +162 -0
  332. aiagents4pharma/talk2scholars/tools/zotero/zotero_write.py +91 -0
  333. aiagents4pharma-0.0.0.dist-info/METADATA +335 -0
  334. aiagents4pharma-0.0.0.dist-info/RECORD +336 -0
  335. aiagents4pharma-0.0.0.dist-info/WHEEL +4 -0
  336. aiagents4pharma-0.0.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,104 @@
1
+ # /usr/bin/env python3
2
+
3
+ """
4
+ This is the agent file for the Talk2BioModels agent.
5
+ """
6
+
7
+ import logging
8
+ from typing import Annotated
9
+
10
+ import hydra
11
+ from langchain_core.language_models.chat_models import BaseChatModel
12
+ from langgraph.checkpoint.memory import MemorySaver
13
+ from langgraph.graph import START, StateGraph
14
+ from langgraph.prebuilt import InjectedState, ToolNode, create_react_agent
15
+
16
+ from ..states.state_talk2biomodels import Talk2Biomodels
17
+ from ..tools.ask_question import AskQuestionTool
18
+ from ..tools.custom_plotter import CustomPlotterTool
19
+ from ..tools.get_annotation import GetAnnotationTool
20
+ from ..tools.get_modelinfo import GetModelInfoTool
21
+ from ..tools.parameter_scan import ParameterScanTool
22
+ from ..tools.query_article import QueryArticle
23
+ from ..tools.save_model import SaveModelTool
24
+ from ..tools.search_models import SearchModelsTool
25
+ from ..tools.simulate_model import SimulateModelTool
26
+ from ..tools.steady_state import SteadyStateTool
27
+
28
+ # Initialize logger
29
+ logging.basicConfig(level=logging.INFO)
30
+ logger = logging.getLogger(__name__)
31
+
32
+
33
+ def get_app(uniq_id, llm_model: BaseChatModel):
34
+ """
35
+ This function returns the langraph app.
36
+ """
37
+
38
+ def agent_t2b_node(state: Annotated[dict, InjectedState]):
39
+ """
40
+ This function calls the model.
41
+ """
42
+ logger.log(logging.INFO, "Calling t2b_agent node with thread_id %s", uniq_id)
43
+ response = model.invoke(state, {"configurable": {"thread_id": uniq_id}})
44
+ return response
45
+
46
+ # Define the tools
47
+ tools = ToolNode(
48
+ [
49
+ SimulateModelTool(),
50
+ AskQuestionTool(),
51
+ CustomPlotterTool(),
52
+ SearchModelsTool(),
53
+ GetModelInfoTool(),
54
+ SteadyStateTool(),
55
+ ParameterScanTool(),
56
+ GetAnnotationTool(),
57
+ QueryArticle(),
58
+ SaveModelTool(),
59
+ ]
60
+ )
61
+
62
+ # Load hydra configuration
63
+ logger.log(logging.INFO, "Load Hydra configuration for Talk2BioModels agent.")
64
+ with hydra.initialize(version_base=None, config_path="../configs"):
65
+ cfg = hydra.compose(config_name="config", overrides=["agents/t2b_agent=default"])
66
+ cfg = cfg.agents.t2b_agent
67
+ logger.log(logging.INFO, "state_modifier: %s", cfg.state_modifier)
68
+ # Create the agent
69
+ model = create_react_agent(
70
+ llm_model,
71
+ tools=tools,
72
+ state_schema=Talk2Biomodels,
73
+ prompt=cfg.state_modifier,
74
+ version="v2",
75
+ checkpointer=MemorySaver(),
76
+ )
77
+
78
+ # Define a new graph
79
+ workflow = StateGraph(Talk2Biomodels)
80
+
81
+ # Define the two nodes we will cycle between
82
+ workflow.add_node("agent_t2b", agent_t2b_node)
83
+
84
+ # Set the entrypoint as the first node
85
+ # This means that this node is the first one called
86
+ workflow.add_edge(START, "agent_t2b")
87
+
88
+ # Initialize memory to persist state between graph runs
89
+ checkpointer = MemorySaver()
90
+
91
+ # Finally, we compile it!
92
+ # This compiles it into a LangChain Runnable,
93
+ # meaning you can use it as you would any other runnable.
94
+ # Note that we're (optionally) passing the memory
95
+ # when compiling the graph
96
+ app = workflow.compile(checkpointer=checkpointer, name="T2B_Agent")
97
+ logger.log(
98
+ logging.INFO,
99
+ "Compiled the graph with thread_id %s and llm_model %s",
100
+ uniq_id,
101
+ llm_model,
102
+ )
103
+
104
+ return app
@@ -0,0 +1,5 @@
1
+ """
2
+ This file is used to import the modules in the package.
3
+ """
4
+
5
+ from . import ols, uniprot
@@ -0,0 +1,75 @@
1
+ """
2
+ This module contains the API for fetching ols database
3
+ """
4
+
5
+ import requests
6
+
7
+
8
+ def fetch_from_ols(term: str) -> str:
9
+ """
10
+ Fetch the label for a single term from OLS.
11
+
12
+ Args:
13
+ term (str): The term in the format "ONTOLOGY:TERM_ID".
14
+
15
+ Returns:
16
+ str: The label for the term or an error message.
17
+ """
18
+ try:
19
+ ontology, _ = term.split(":")
20
+ base_url = f"https://www.ebi.ac.uk/ols4/api/ontologies/{ontology.lower()}/terms"
21
+ params = {"obo_id": term}
22
+ response = requests.get(
23
+ base_url, params=params, headers={"Accept": "application/json"}, timeout=10
24
+ )
25
+ response.raise_for_status()
26
+ data = response.json()
27
+ label = "-"
28
+ # Extract and return the label
29
+ if (
30
+ "_embedded" in data
31
+ and "terms" in data["_embedded"]
32
+ and len(data["_embedded"]["terms"]) > 0
33
+ ):
34
+ label = data["_embedded"]["terms"][0].get("label", "Label not found")
35
+ return label
36
+ except (requests.exceptions.RequestException, KeyError, IndexError) as e:
37
+ return f"Error: {str(e)}"
38
+
39
+
40
+ def fetch_ols_labels(terms: list[str]) -> dict[str, str]:
41
+ """
42
+ Fetch labels for multiple terms from OLS.
43
+
44
+ Args:
45
+ terms (List[str]): A list of terms in the format "ONTOLOGY:TERM_ID".
46
+
47
+ Returns:
48
+ Dict[str, str]: A mapping of term IDs to their labels or error messages.
49
+ """
50
+ results = {}
51
+ for term in terms:
52
+ results[term] = fetch_from_ols(term)
53
+ return results
54
+
55
+
56
+ def search_ols_labels(data: list[dict[str, str]]) -> dict[str, dict[str, str]]:
57
+ """
58
+ Fetch OLS annotations grouped by ontology type.
59
+
60
+ Args:
61
+ data (List[Dict[str, str]]): A list of dictionaries containing 'Id' and 'Database'.
62
+
63
+ Returns:
64
+ Dict[str, Dict[str, str]]: A mapping of ontology type to term labels.
65
+ """
66
+ grouped_data = {}
67
+ for entry in data:
68
+ ontology = entry["Database"].lower()
69
+ grouped_data.setdefault(ontology, []).append(entry["Id"])
70
+
71
+ results = {}
72
+ for ontology, terms in grouped_data.items():
73
+ results[ontology] = fetch_ols_labels(terms)
74
+
75
+ return results
@@ -0,0 +1,36 @@
1
+ """
2
+ This module contains the API for fetching uniprot database
3
+ """
4
+
5
+ import requests
6
+
7
+
8
+ def search_uniprot_labels(identifiers: list[str]) -> dict[str, str]:
9
+ """
10
+ Fetch protein names or labels for a list of UniProt identifiers by making sequential requests.
11
+
12
+ Args:
13
+ identifiers (List[str]): A list of UniProt identifiers.
14
+
15
+ Returns:
16
+ Dict[str, str]: A mapping of UniProt identifiers to their protein names or error messages.
17
+ """
18
+ results = {}
19
+ base_url = "https://www.uniprot.org/uniprot/"
20
+
21
+ for identifier in identifiers:
22
+ url = f"{base_url}{identifier}.json"
23
+ try:
24
+ response = requests.get(url, timeout=10)
25
+ response.raise_for_status()
26
+ data = response.json()
27
+ protein_name = (
28
+ data.get("proteinDescription", {})
29
+ .get("recommendedName", {})
30
+ .get("fullName", {})
31
+ .get("value", "Name not found")
32
+ )
33
+ results[identifier] = protein_name
34
+ except requests.exceptions.RequestException as e:
35
+ results[identifier] = f"Error: {str(e)}"
36
+ return results
@@ -0,0 +1,5 @@
1
+ """
2
+ Import all the modules in the package
3
+ """
4
+
5
+ from . import agents, tools
@@ -0,0 +1,5 @@
1
+ """
2
+ Import all the modules in the package
3
+ """
4
+
5
+ from . import t2b_agent
@@ -0,0 +1,3 @@
1
+ """
2
+ Import all the modules in the package
3
+ """
@@ -0,0 +1,14 @@
1
+ _target_: agents.t2b_agent.get_app
2
+ state_modifier: >
3
+ You are Talk2BioModels agent.
4
+ If the user asks for the uploaded model,
5
+ then pass the use_uploaded_model argument
6
+ as True. If the user asks for simulation
7
+ or param_scan or steady state, suggest a
8
+ value for the `experiment_name` argument.
9
+
10
+ If the user asks question related to the
11
+ uploaded document/pdf/article/document,
12
+ use the tool `query_article` to answer the
13
+ question. Please note that the `experiment_name`
14
+ argument may be unrelated to the question asked.
File without changes
@@ -0,0 +1,72 @@
1
+ _target_: app.frontend.streamlit_app_talk2biomodels
2
+ default_user: "talk2biomodels_user"
3
+
4
+ # File upload configuration
5
+ upload_data_dir: "../files"
6
+ sbml_allowed_file_types:
7
+ - "xml"
8
+ - "sbml"
9
+ article_allowed_file_types:
10
+ - "pdf"
11
+
12
+ # OpenAI configuration - can use custom base_url for enterprise/Azure deployments
13
+ openai_api_key: ${oc.env:OPENAI_API_KEY}
14
+ openai_base_url: ${oc.env:OPENAI_BASE_URL,null} # Optional: custom OpenAI endpoint
15
+ openai_llms:
16
+ - "OpenAI/gpt-4o-mini"
17
+
18
+ # Rate limiting and retry configuration
19
+ llm_max_retries: 5 # Number of retries on rate limit or transient errors
20
+ llm_timeout: 60 # Timeout in seconds for LLM requests
21
+ embedding_max_retries: 3 # Number of retries for embedding requests
22
+ embedding_timeout: 30 # Timeout in seconds for embedding requests
23
+
24
+ # NVIDIA configuration
25
+ nvidia_api_key: ${oc.env:NVIDIA_API_KEY}
26
+ nvidia_llms:
27
+ - "NVIDIA/llama-3.3-70b-instruct"
28
+ - "NVIDIA/llama-3.1-70b-instruct"
29
+ - "NVIDIA/llama-3.1-405b-instruct"
30
+
31
+ # Azure OpenAI configuration
32
+ azure_openai_endpoint: ${oc.env:AZURE_OPENAI_ENDPOINT,null} # Azure OpenAI endpoint
33
+ azure_openai_deployment: ${oc.env:AZURE_OPENAI_DEPLOYMENT,null} # Azure deployment name
34
+ azure_openai_api_version: ${oc.env:AZURE_OPENAI_API_VERSION,"2024-02-01"} # Azure API version
35
+ azure_openai_model_name: ${oc.env:AZURE_OPENAI_MODEL_NAME,null} # Model name for analytics
36
+ azure_openai_model_version: ${oc.env:AZURE_OPENAI_MODEL_VERSION,null} # Model version
37
+ # Azure AD authentication (uses AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET)
38
+ azure_client_id: ${oc.env:AZURE_CLIENT_ID,null}
39
+ azure_tenant_id: ${oc.env:AZURE_TENANT_ID,null}
40
+ azure_client_secret: ${oc.env:AZURE_CLIENT_SECRET,null}
41
+ azure_openai_llms:
42
+ - "Azure/gpt-4o-mini" # Will map to Azure deployment
43
+
44
+ # Text embedding models
45
+ openai_embeddings:
46
+ - "OpenAI/text-embedding-ada-002"
47
+ - "text-embedding-3-small"
48
+ nvidia_embeddings:
49
+ - "NVIDIA/llama-3.2-nv-embedqa-1b-v2"
50
+ azure_openai_embeddings:
51
+ - "Azure/text-embedding-ada-002"
52
+
53
+ # Ollama configuration (for local deployment)
54
+ ollama_llms:
55
+ - "Ollama/llama3.1:8b"
56
+ ollama_embeddings:
57
+ - "nomic-embed-text"
58
+
59
+ # Default models
60
+ default_llm_provider: "openai"
61
+ default_embedding_provider: "nvidia" # Default as per current T2B app
62
+
63
+ # App settings
64
+ temperature: 0
65
+ streaming: true
66
+
67
+ # Logo configuration
68
+ logo_paths:
69
+ container: "/app/docs/assets/VPE.png"
70
+ local: "docs/assets/VPE.png"
71
+ relative: "../../docs/assets/VPE.png"
72
+ logo_link: "https://github.com/VirtualPatientEngine"
@@ -0,0 +1,7 @@
1
+ defaults:
2
+ - _self_
3
+ - agents/t2b_agent: default
4
+ - tools/ask_question: default
5
+ - tools/get_annotation: default
6
+ - tools/custom_plotter: default
7
+ - app/frontend: default
@@ -0,0 +1,5 @@
1
+ """
2
+ Import all the modules in the package
3
+ """
4
+
5
+ from . import ask_question, custom_plotter, get_annotation
@@ -0,0 +1,3 @@
1
+ """
2
+ Import all the modules in the package
3
+ """
@@ -0,0 +1,30 @@
1
+ _target_: tools.ask_question.AskQuestionTool
2
+ steady_state_prompt: >
3
+ Following are header columns of the data:
4
+ `species_name`: Name of the species,
5
+ `compartment`: Compartment of the species,
6
+ `initial_concentration`: Concentration of the species at the start of steady state,
7
+ `steady_state_concentration`: Concentration of the species at steady state,
8
+ `steady_state_transition_time`: Time taken to reach steady state,
9
+ `display_name`: An alias for the species name.
10
+
11
+ Here are some instructions to help you answer questions:
12
+
13
+ 1. If the user wants to know the time taken by the model to reach
14
+ steady state, you should look at the `steady_state_transition_time`
15
+ column of the data for the model species.
16
+
17
+ 2. The highest value in the column `steady_state_transition_time`
18
+ is the time taken by the model to reach steady state.
19
+
20
+ 3. Please use the units provided below to answer the questions.
21
+ simulation_prompt: >
22
+ Following is the information about the data frame:
23
+ 1. First column is the time column, and the rest of the columns
24
+ are the species names.
25
+
26
+ 2. While the time column records the simulation time points, the
27
+ rest of the columns record the concentration of the species at
28
+ each time point.
29
+
30
+ 3. Please use the units provided below to answer the questions.
@@ -0,0 +1,3 @@
1
+ """
2
+ Import all the modules in the package
3
+ """
@@ -0,0 +1,8 @@
1
+ system_prompt_custom_header: >
2
+ You are custom plotter tool. You can extract species from the given
3
+ list of species names based on user question. If no species is relevant,
4
+ set the attribute `relevant_species` to None.
5
+ If the user asks for very specific species (for example, using the
6
+ keyword `only` or `exactly` in the question), set this attribute to
7
+ correspond strictly to the species available in the simulation results,
8
+ otherwise set it to None.
@@ -0,0 +1,3 @@
1
+ """
2
+ Import all the modules in the package
3
+ """
@@ -0,0 +1,8 @@
1
+ _target_: tools.get_annotation.GetAnnotationTool
2
+ prompt: >
3
+ Given the user question, extract the relevant species names.
4
+ If the user aks for a specific species, extract that species.
5
+ If none of the species match the user question, return None.
6
+ If the user asks for all species, return all species.
7
+ If the user does not specify any species or simpley asks for
8
+ model annotations, return all species.
@@ -0,0 +1,63 @@
1
+ # Talk2BioModels
2
+
3
+ ## Installation
4
+
5
+ ### Docker (stable-release)
6
+
7
+ _This agent is available on Docker Hub._
8
+
9
+ ### Run via `docker run`
10
+
11
+ ```sh
12
+ docker run -d \
13
+ --name talk2biomodels \
14
+ -e OPENAI_API_KEY=<your_openai_api_key> \
15
+ -e NVIDIA_API_KEY=<your_nvidia_api_key> \
16
+ -p 8501:8501 \
17
+ virtualpatientengine/talk2biomodels
18
+ ```
19
+
20
+ ### Access the Web UI
21
+
22
+ Once started, open:
23
+
24
+ ```
25
+ http://localhost:8501
26
+ ```
27
+
28
+ ---
29
+
30
+ ## Environment Variables
31
+
32
+ - `OPENAI_API_KEY` – required
33
+ - `NVIDIA_API_KEY` – required
34
+
35
+ ---
36
+
37
+ ## Get Key
38
+
39
+ - `NVIDIA_API_KEY` – required (obtain a free key at [https://build.nvidia.com/explore/discover](https://build.nvidia.com/explore/discover))
40
+
41
+ **LangSmith** support is optional. To enable it, create an API key [here](https://docs.smith.langchain.com/administration/how_to_guides/organization_management/create_account_api_key).
42
+
43
+ _Please note that this will create a new tracing project in your Langsmith
44
+ account with the name `T2X-xxxx`, where `X` can be `B` (Biomodels).
45
+ If you skip the previous step, it will default to the name `default`.
46
+ `xxxx` will be the 4-digit ID created for the session._
47
+
48
+ ---
49
+
50
+ ## Running Multiple Agents
51
+
52
+ By default, this agent listens on port `8501`. To run another agent on a different port, map a different host port:
53
+
54
+ ```sh
55
+ docker run -d \
56
+ --name talk2biomodels \
57
+ -e OPENAI_API_KEY=<your_openai_api_key> \
58
+ -e NVIDIA_API_KEY=<your_nvidia_api_key> \
59
+ -p 8502:8501 \
60
+ virtualpatientengine/talk2biomodels
61
+ ```
62
+
63
+ Then visit: [http://localhost:8502](http://localhost:8502)
@@ -0,0 +1,5 @@
1
+ """
2
+ This file is used to import all the models in the package.
3
+ """
4
+
5
+ from . import basico_model, sys_bio_model
@@ -0,0 +1,125 @@
1
+ #!/usr/bin/env python3
2
+
3
+ """
4
+ BasicoModel class for loading and simulating SBML models
5
+ using the basico package.
6
+ """
7
+
8
+ import logging
9
+
10
+ import basico
11
+ import pandas as pd
12
+ from pydantic import Field, model_validator
13
+
14
+ from .sys_bio_model import SysBioModel
15
+
16
+ # Initialize logger
17
+ logging.basicConfig(level=logging.INFO)
18
+ logger = logging.getLogger(__name__)
19
+
20
+
21
+ class BasicoModel(SysBioModel):
22
+ """
23
+ Model that loads and simulates SBML models using the basico package.
24
+ Can load models from an SBML file or download them using a BioModels biomodel_id.
25
+ """
26
+
27
+ biomodel_id: int | str | None = Field(
28
+ None, description="BioModels model ID to download and load"
29
+ )
30
+ sbml_file_path: str | None = Field(None, description="Path to an SBML file to load")
31
+ simulation_results: str | None = None
32
+ name: str | None = Field("", description="Name of the model")
33
+ description: str | None = Field("", description="Description of the model")
34
+
35
+ # Additional attribute not included in the schema
36
+ copasi_model: object | None = None # Holds the loaded Copasi model
37
+
38
+ @model_validator(mode="after")
39
+ def check_biomodel_id_or_sbml_file_path(self):
40
+ """
41
+ Validate that either biomodel_id or sbml_file_path is provided.
42
+ """
43
+ if not self.biomodel_id and not self.sbml_file_path:
44
+ logger.error("Either biomodel_id or sbml_file_path must be provided.")
45
+ raise ValueError("Either biomodel_id or sbml_file_path must be provided.")
46
+ if self.biomodel_id:
47
+ self.copasi_model = basico.load_biomodel(self.biomodel_id)
48
+ self.description = basico.biomodels.get_model_info(self.biomodel_id)["description"]
49
+ self.name = basico.model_info.get_model_name(model=self.copasi_model)
50
+ elif self.sbml_file_path:
51
+ self.copasi_model = basico.load_model(self.sbml_file_path)
52
+ self.description = basico.model_info.get_notes(model=self.copasi_model)
53
+ self.name = basico.model_info.get_model_name(model=self.copasi_model)
54
+ return self
55
+
56
+ def update_parameters(self, parameters: dict[str, float | int]) -> None:
57
+ """
58
+ Update model parameters with new values.
59
+ """
60
+ # Update parameters in the model
61
+ for param_name, param_value in parameters.items():
62
+ # check if the param_name is not None
63
+ if param_name is None:
64
+ continue
65
+ # Extract all parameters and species from the model
66
+ df_all_params = basico.model_info.get_parameters(model=self.copasi_model)
67
+ df_all_species = basico.model_info.get_species(model=self.copasi_model)
68
+ # if param is a kinetic parameter
69
+ if param_name in df_all_params.index.tolist():
70
+ basico.model_info.set_parameters(
71
+ name=param_name,
72
+ exact=True,
73
+ initial_value=param_value,
74
+ model=self.copasi_model,
75
+ )
76
+ # if param is a species
77
+ elif param_name in df_all_species.index.tolist():
78
+ basico.model_info.set_species(
79
+ name=param_name,
80
+ exact=True,
81
+ initial_concentration=param_value,
82
+ model=self.copasi_model,
83
+ )
84
+ else:
85
+ logger.error("Parameter/Species %s not found in the model.", param_name)
86
+ raise ValueError(f"Parameter/Species {param_name} not found in the model.")
87
+
88
+ def simulate(self, duration: int | float = 10, interval: int = 10) -> pd.DataFrame:
89
+ """
90
+ Simulate the COPASI model over a specified range of time points.
91
+
92
+ Args:
93
+ duration: Duration of the simulation in time units.
94
+ interval: Interval between time points in the simulation.
95
+
96
+ Returns:
97
+ Pandas DataFrame with time-course simulation results.
98
+ """
99
+ # Run the simulation and return results
100
+ df_result = basico.run_time_course(
101
+ model=self.copasi_model, intervals=interval, duration=duration
102
+ )
103
+ # # Replace curly braces in column headers with square brackets
104
+ # # Because curly braces in the world of LLMS are used for
105
+ # # structured output
106
+ # df_result.columns = df_result.columns.str.replace('{', '[', regex=False).\
107
+ # str.replace('}', ']', regex=False)
108
+ # Reset the index
109
+ df_result.reset_index(inplace=True)
110
+ # Store the simulation results
111
+ self.simulation_results = df_result
112
+ # Return copy of the simulation results
113
+ return df_result.copy()
114
+
115
+ def get_model_metadata(self) -> dict[str, str | int]:
116
+ """
117
+ Retrieve metadata specific to the COPASI model.
118
+
119
+ Returns:
120
+ Dictionary of model metadata.
121
+ """
122
+ return {
123
+ "Model Type": "SBML Model (COPASI)",
124
+ "Parameter Count": len(basico.get_parameters()),
125
+ }
@@ -0,0 +1,60 @@
1
+ """
2
+ An abstract base class for BioModels in the BioModels repository.
3
+ """
4
+
5
+ from abc import ABC, abstractmethod
6
+
7
+ from pydantic import BaseModel, Field, model_validator
8
+
9
+
10
+ class SysBioModel(ABC, BaseModel):
11
+ """
12
+ Abstract base class for BioModels in the BioModels repository.
13
+ This class serves as a general structure for models, allowing
14
+ different mathematical approaches to be implemented in subclasses.
15
+ """
16
+
17
+ biomodel_id: int | None = Field(None, description="BioModel ID of the model")
18
+ sbml_file_path: str | None = Field(None, description="Path to an SBML file")
19
+ name: str | None = Field(..., description="Name of the model")
20
+ description: str | None = Field("", description="Description of the model")
21
+
22
+ @model_validator(mode="after")
23
+ def check_biomodel_id_or_sbml_file_path(self):
24
+ """
25
+ Validate that either biomodel_id or sbml_file_path is provided.
26
+ """
27
+ if not self.biomodel_id and not self.sbml_file_path:
28
+ raise ValueError("Either biomodel_id or sbml_file_path must be provided.")
29
+ return self
30
+
31
+ @abstractmethod
32
+ def get_model_metadata(self) -> dict[str, str | int]:
33
+ """
34
+ Abstract method to retrieve metadata of the model.
35
+ This method should return a dictionary containing model metadata.
36
+
37
+ Returns:
38
+ dict: Dictionary with model metadata
39
+ """
40
+
41
+ @abstractmethod
42
+ def update_parameters(self, parameters: dict[str, float | int]) -> None:
43
+ """
44
+ Abstract method to update model parameters.
45
+
46
+ Args:
47
+ parameters: Dictionary of parameter values.
48
+ """
49
+
50
+ @abstractmethod
51
+ def simulate(self, duration: int | float) -> list[float]:
52
+ """
53
+ Abstract method to run a simulation of the model.
54
+
55
+ Args:
56
+ duration: Duration of the simulation.
57
+
58
+ Returns:
59
+ list: List of simulation results.
60
+ """