aiagents4pharma 1.44.0__py3-none-any.whl → 1.45.1__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 (289) hide show
  1. aiagents4pharma/__init__.py +2 -2
  2. aiagents4pharma/talk2aiagents4pharma/.dockerignore +13 -0
  3. aiagents4pharma/talk2aiagents4pharma/Dockerfile +105 -0
  4. aiagents4pharma/talk2aiagents4pharma/README.md +1 -0
  5. aiagents4pharma/talk2aiagents4pharma/__init__.py +4 -5
  6. aiagents4pharma/talk2aiagents4pharma/agents/__init__.py +3 -2
  7. aiagents4pharma/talk2aiagents4pharma/agents/main_agent.py +24 -23
  8. aiagents4pharma/talk2aiagents4pharma/configs/__init__.py +2 -2
  9. aiagents4pharma/talk2aiagents4pharma/configs/agents/__init__.py +2 -2
  10. aiagents4pharma/talk2aiagents4pharma/configs/agents/main_agent/default.yaml +2 -2
  11. aiagents4pharma/talk2aiagents4pharma/configs/config.yaml +1 -1
  12. aiagents4pharma/talk2aiagents4pharma/docker-compose/cpu/.env.example +23 -0
  13. aiagents4pharma/talk2aiagents4pharma/docker-compose/cpu/docker-compose.yml +93 -0
  14. aiagents4pharma/talk2aiagents4pharma/docker-compose/gpu/.env.example +23 -0
  15. aiagents4pharma/talk2aiagents4pharma/docker-compose/gpu/docker-compose.yml +108 -0
  16. aiagents4pharma/talk2aiagents4pharma/install.md +127 -0
  17. aiagents4pharma/talk2aiagents4pharma/states/__init__.py +3 -2
  18. aiagents4pharma/talk2aiagents4pharma/states/state_talk2aiagents4pharma.py +5 -3
  19. aiagents4pharma/talk2aiagents4pharma/tests/__init__.py +2 -2
  20. aiagents4pharma/talk2aiagents4pharma/tests/test_main_agent.py +72 -50
  21. aiagents4pharma/talk2biomodels/.dockerignore +13 -0
  22. aiagents4pharma/talk2biomodels/Dockerfile +104 -0
  23. aiagents4pharma/talk2biomodels/README.md +1 -0
  24. aiagents4pharma/talk2biomodels/__init__.py +4 -8
  25. aiagents4pharma/talk2biomodels/agents/__init__.py +3 -2
  26. aiagents4pharma/talk2biomodels/agents/t2b_agent.py +47 -42
  27. aiagents4pharma/talk2biomodels/api/__init__.py +4 -5
  28. aiagents4pharma/talk2biomodels/api/kegg.py +14 -10
  29. aiagents4pharma/talk2biomodels/api/ols.py +13 -10
  30. aiagents4pharma/talk2biomodels/api/uniprot.py +7 -6
  31. aiagents4pharma/talk2biomodels/configs/__init__.py +3 -4
  32. aiagents4pharma/talk2biomodels/configs/agents/__init__.py +2 -2
  33. aiagents4pharma/talk2biomodels/configs/agents/t2b_agent/__init__.py +2 -2
  34. aiagents4pharma/talk2biomodels/configs/agents/t2b_agent/default.yaml +1 -1
  35. aiagents4pharma/talk2biomodels/configs/config.yaml +1 -1
  36. aiagents4pharma/talk2biomodels/configs/tools/__init__.py +4 -5
  37. aiagents4pharma/talk2biomodels/configs/tools/ask_question/__init__.py +2 -2
  38. aiagents4pharma/talk2biomodels/configs/tools/ask_question/default.yaml +1 -2
  39. aiagents4pharma/talk2biomodels/configs/tools/custom_plotter/__init__.py +2 -2
  40. aiagents4pharma/talk2biomodels/configs/tools/custom_plotter/default.yaml +1 -1
  41. aiagents4pharma/talk2biomodels/configs/tools/get_annotation/__init__.py +2 -2
  42. aiagents4pharma/talk2biomodels/configs/tools/get_annotation/default.yaml +1 -1
  43. aiagents4pharma/talk2biomodels/install.md +63 -0
  44. aiagents4pharma/talk2biomodels/models/__init__.py +4 -4
  45. aiagents4pharma/talk2biomodels/models/basico_model.py +36 -28
  46. aiagents4pharma/talk2biomodels/models/sys_bio_model.py +13 -10
  47. aiagents4pharma/talk2biomodels/states/__init__.py +3 -2
  48. aiagents4pharma/talk2biomodels/states/state_talk2biomodels.py +12 -8
  49. aiagents4pharma/talk2biomodels/tests/BIOMD0000000449_url.xml +1585 -0
  50. aiagents4pharma/talk2biomodels/tests/__init__.py +2 -2
  51. aiagents4pharma/talk2biomodels/tests/article_on_model_537.pdf +0 -0
  52. aiagents4pharma/talk2biomodels/tests/test_api.py +18 -14
  53. aiagents4pharma/talk2biomodels/tests/test_ask_question.py +8 -9
  54. aiagents4pharma/talk2biomodels/tests/test_basico_model.py +15 -9
  55. aiagents4pharma/talk2biomodels/tests/test_get_annotation.py +54 -55
  56. aiagents4pharma/talk2biomodels/tests/test_getmodelinfo.py +28 -27
  57. aiagents4pharma/talk2biomodels/tests/test_integration.py +21 -33
  58. aiagents4pharma/talk2biomodels/tests/test_load_biomodel.py +14 -11
  59. aiagents4pharma/talk2biomodels/tests/test_param_scan.py +21 -20
  60. aiagents4pharma/talk2biomodels/tests/test_query_article.py +129 -29
  61. aiagents4pharma/talk2biomodels/tests/test_search_models.py +9 -13
  62. aiagents4pharma/talk2biomodels/tests/test_simulate_model.py +16 -15
  63. aiagents4pharma/talk2biomodels/tests/test_steady_state.py +12 -22
  64. aiagents4pharma/talk2biomodels/tests/test_sys_bio_model.py +33 -29
  65. aiagents4pharma/talk2biomodels/tools/__init__.py +15 -12
  66. aiagents4pharma/talk2biomodels/tools/ask_question.py +42 -32
  67. aiagents4pharma/talk2biomodels/tools/custom_plotter.py +51 -43
  68. aiagents4pharma/talk2biomodels/tools/get_annotation.py +99 -75
  69. aiagents4pharma/talk2biomodels/tools/get_modelinfo.py +57 -51
  70. aiagents4pharma/talk2biomodels/tools/load_arguments.py +52 -32
  71. aiagents4pharma/talk2biomodels/tools/load_biomodel.py +8 -2
  72. aiagents4pharma/talk2biomodels/tools/parameter_scan.py +107 -90
  73. aiagents4pharma/talk2biomodels/tools/query_article.py +14 -13
  74. aiagents4pharma/talk2biomodels/tools/search_models.py +37 -26
  75. aiagents4pharma/talk2biomodels/tools/simulate_model.py +47 -37
  76. aiagents4pharma/talk2biomodels/tools/steady_state.py +76 -58
  77. aiagents4pharma/talk2biomodels/tools/utils.py +4 -3
  78. aiagents4pharma/talk2cells/README.md +1 -0
  79. aiagents4pharma/talk2cells/__init__.py +4 -5
  80. aiagents4pharma/talk2cells/agents/__init__.py +3 -2
  81. aiagents4pharma/talk2cells/agents/scp_agent.py +21 -19
  82. aiagents4pharma/talk2cells/states/__init__.py +3 -2
  83. aiagents4pharma/talk2cells/states/state_talk2cells.py +4 -2
  84. aiagents4pharma/talk2cells/tests/scp_agent/test_scp_agent.py +8 -9
  85. aiagents4pharma/talk2cells/tools/__init__.py +3 -2
  86. aiagents4pharma/talk2cells/tools/scp_agent/__init__.py +4 -4
  87. aiagents4pharma/talk2cells/tools/scp_agent/display_studies.py +5 -3
  88. aiagents4pharma/talk2cells/tools/scp_agent/search_studies.py +21 -22
  89. aiagents4pharma/talk2knowledgegraphs/.dockerignore +13 -0
  90. aiagents4pharma/talk2knowledgegraphs/Dockerfile +103 -0
  91. aiagents4pharma/talk2knowledgegraphs/README.md +1 -0
  92. aiagents4pharma/talk2knowledgegraphs/__init__.py +4 -7
  93. aiagents4pharma/talk2knowledgegraphs/agents/__init__.py +3 -2
  94. aiagents4pharma/talk2knowledgegraphs/agents/t2kg_agent.py +40 -30
  95. aiagents4pharma/talk2knowledgegraphs/configs/__init__.py +3 -6
  96. aiagents4pharma/talk2knowledgegraphs/configs/agents/t2kg_agent/__init__.py +2 -2
  97. aiagents4pharma/talk2knowledgegraphs/configs/agents/t2kg_agent/default.yaml +8 -8
  98. aiagents4pharma/talk2knowledgegraphs/configs/app/__init__.py +3 -2
  99. aiagents4pharma/talk2knowledgegraphs/configs/app/frontend/__init__.py +2 -2
  100. aiagents4pharma/talk2knowledgegraphs/configs/app/frontend/default.yaml +1 -1
  101. aiagents4pharma/talk2knowledgegraphs/configs/config.yaml +1 -1
  102. aiagents4pharma/talk2knowledgegraphs/configs/tools/__init__.py +4 -5
  103. aiagents4pharma/talk2knowledgegraphs/configs/tools/graphrag_reasoning/__init__.py +2 -2
  104. aiagents4pharma/talk2knowledgegraphs/configs/tools/graphrag_reasoning/default.yaml +1 -1
  105. aiagents4pharma/talk2knowledgegraphs/configs/tools/subgraph_extraction/__init__.py +2 -2
  106. aiagents4pharma/talk2knowledgegraphs/configs/tools/subgraph_extraction/default.yaml +1 -1
  107. aiagents4pharma/talk2knowledgegraphs/configs/tools/subgraph_summarization/__init__.py +2 -2
  108. aiagents4pharma/talk2knowledgegraphs/configs/tools/subgraph_summarization/default.yaml +1 -1
  109. aiagents4pharma/talk2knowledgegraphs/configs/utils/enrichments/ols_terms/default.yaml +1 -1
  110. aiagents4pharma/talk2knowledgegraphs/configs/utils/enrichments/reactome_pathways/default.yaml +1 -1
  111. aiagents4pharma/talk2knowledgegraphs/configs/utils/enrichments/uniprot_proteins/default.yaml +1 -1
  112. aiagents4pharma/talk2knowledgegraphs/configs/utils/pubchem_utils/default.yaml +1 -1
  113. aiagents4pharma/talk2knowledgegraphs/datasets/__init__.py +4 -6
  114. aiagents4pharma/talk2knowledgegraphs/datasets/biobridge_primekg.py +115 -67
  115. aiagents4pharma/talk2knowledgegraphs/datasets/dataset.py +2 -0
  116. aiagents4pharma/talk2knowledgegraphs/datasets/primekg.py +35 -24
  117. aiagents4pharma/talk2knowledgegraphs/datasets/starkqa_primekg.py +29 -21
  118. aiagents4pharma/talk2knowledgegraphs/docker-compose/cpu/.env.example +23 -0
  119. aiagents4pharma/talk2knowledgegraphs/docker-compose/cpu/docker-compose.yml +93 -0
  120. aiagents4pharma/talk2knowledgegraphs/docker-compose/gpu/.env.example +23 -0
  121. aiagents4pharma/talk2knowledgegraphs/docker-compose/gpu/docker-compose.yml +108 -0
  122. aiagents4pharma/talk2knowledgegraphs/entrypoint.sh +190 -0
  123. aiagents4pharma/talk2knowledgegraphs/install.md +140 -0
  124. aiagents4pharma/talk2knowledgegraphs/milvus_data_dump.py +31 -65
  125. aiagents4pharma/talk2knowledgegraphs/states/__init__.py +3 -2
  126. aiagents4pharma/talk2knowledgegraphs/states/state_talk2knowledgegraphs.py +1 -0
  127. aiagents4pharma/talk2knowledgegraphs/tests/test_agents_t2kg_agent.py +65 -40
  128. aiagents4pharma/talk2knowledgegraphs/tests/test_datasets_biobridge_primekg.py +54 -48
  129. aiagents4pharma/talk2knowledgegraphs/tests/test_datasets_dataset.py +4 -0
  130. aiagents4pharma/talk2knowledgegraphs/tests/test_datasets_primekg.py +17 -4
  131. aiagents4pharma/talk2knowledgegraphs/tests/test_datasets_starkqa_primekg.py +33 -24
  132. aiagents4pharma/talk2knowledgegraphs/tests/test_tools_graphrag_reasoning.py +116 -69
  133. aiagents4pharma/talk2knowledgegraphs/tests/test_tools_milvus_multimodal_subgraph_extraction.py +334 -216
  134. aiagents4pharma/talk2knowledgegraphs/tests/test_tools_multimodal_subgraph_extraction.py +22 -15
  135. aiagents4pharma/talk2knowledgegraphs/tests/test_tools_subgraph_extraction.py +19 -12
  136. aiagents4pharma/talk2knowledgegraphs/tests/test_tools_subgraph_summarization.py +95 -48
  137. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_embeddings_embeddings.py +4 -0
  138. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_embeddings_huggingface.py +5 -0
  139. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_embeddings_nim_molmim.py +13 -18
  140. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_embeddings_ollama.py +10 -3
  141. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_enrichments_enrichments.py +4 -3
  142. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_enrichments_ollama.py +3 -2
  143. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_enrichments_ols.py +1 -0
  144. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_enrichments_pubchem.py +9 -4
  145. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_enrichments_reactome.py +6 -6
  146. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_enrichments_uniprot.py +4 -0
  147. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_extractions_milvus_multimodal_pcst.py +160 -97
  148. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_kg_utils.py +3 -4
  149. aiagents4pharma/talk2knowledgegraphs/tests/test_utils_pubchem_utils.py +87 -13
  150. aiagents4pharma/talk2knowledgegraphs/tools/__init__.py +10 -7
  151. aiagents4pharma/talk2knowledgegraphs/tools/graphrag_reasoning.py +15 -20
  152. aiagents4pharma/talk2knowledgegraphs/tools/milvus_multimodal_subgraph_extraction.py +145 -142
  153. aiagents4pharma/talk2knowledgegraphs/tools/multimodal_subgraph_extraction.py +92 -90
  154. aiagents4pharma/talk2knowledgegraphs/tools/subgraph_extraction.py +25 -37
  155. aiagents4pharma/talk2knowledgegraphs/tools/subgraph_summarization.py +10 -13
  156. aiagents4pharma/talk2knowledgegraphs/utils/__init__.py +4 -7
  157. aiagents4pharma/talk2knowledgegraphs/utils/embeddings/__init__.py +4 -7
  158. aiagents4pharma/talk2knowledgegraphs/utils/embeddings/embeddings.py +4 -0
  159. aiagents4pharma/talk2knowledgegraphs/utils/embeddings/huggingface.py +11 -14
  160. aiagents4pharma/talk2knowledgegraphs/utils/embeddings/nim_molmim.py +7 -7
  161. aiagents4pharma/talk2knowledgegraphs/utils/embeddings/ollama.py +12 -6
  162. aiagents4pharma/talk2knowledgegraphs/utils/embeddings/sentence_transformer.py +8 -6
  163. aiagents4pharma/talk2knowledgegraphs/utils/enrichments/__init__.py +9 -6
  164. aiagents4pharma/talk2knowledgegraphs/utils/enrichments/enrichments.py +1 -0
  165. aiagents4pharma/talk2knowledgegraphs/utils/enrichments/ollama.py +15 -9
  166. aiagents4pharma/talk2knowledgegraphs/utils/enrichments/ols_terms.py +23 -20
  167. aiagents4pharma/talk2knowledgegraphs/utils/enrichments/pubchem_strings.py +12 -10
  168. aiagents4pharma/talk2knowledgegraphs/utils/enrichments/reactome_pathways.py +16 -10
  169. aiagents4pharma/talk2knowledgegraphs/utils/enrichments/uniprot_proteins.py +26 -18
  170. aiagents4pharma/talk2knowledgegraphs/utils/extractions/__init__.py +4 -5
  171. aiagents4pharma/talk2knowledgegraphs/utils/extractions/milvus_multimodal_pcst.py +14 -34
  172. aiagents4pharma/talk2knowledgegraphs/utils/extractions/multimodal_pcst.py +53 -47
  173. aiagents4pharma/talk2knowledgegraphs/utils/extractions/pcst.py +18 -14
  174. aiagents4pharma/talk2knowledgegraphs/utils/kg_utils.py +22 -23
  175. aiagents4pharma/talk2knowledgegraphs/utils/pubchem_utils.py +11 -10
  176. aiagents4pharma/talk2scholars/.dockerignore +13 -0
  177. aiagents4pharma/talk2scholars/Dockerfile +104 -0
  178. aiagents4pharma/talk2scholars/README.md +1 -0
  179. aiagents4pharma/talk2scholars/agents/__init__.py +1 -5
  180. aiagents4pharma/talk2scholars/agents/main_agent.py +6 -4
  181. aiagents4pharma/talk2scholars/agents/paper_download_agent.py +5 -4
  182. aiagents4pharma/talk2scholars/agents/pdf_agent.py +4 -2
  183. aiagents4pharma/talk2scholars/agents/s2_agent.py +2 -2
  184. aiagents4pharma/talk2scholars/agents/zotero_agent.py +10 -11
  185. aiagents4pharma/talk2scholars/configs/__init__.py +1 -3
  186. aiagents4pharma/talk2scholars/configs/agents/talk2scholars/__init__.py +1 -4
  187. aiagents4pharma/talk2scholars/configs/agents/talk2scholars/main_agent/default.yaml +1 -1
  188. aiagents4pharma/talk2scholars/configs/agents/talk2scholars/pdf_agent/default.yaml +1 -1
  189. aiagents4pharma/talk2scholars/configs/agents/talk2scholars/s2_agent/default.yaml +8 -8
  190. aiagents4pharma/talk2scholars/configs/agents/talk2scholars/zotero_agent/default.yaml +7 -7
  191. aiagents4pharma/talk2scholars/configs/tools/__init__.py +8 -6
  192. aiagents4pharma/talk2scholars/docker-compose/cpu/.env.example +21 -0
  193. aiagents4pharma/talk2scholars/docker-compose/cpu/docker-compose.yml +90 -0
  194. aiagents4pharma/talk2scholars/docker-compose/gpu/.env.example +21 -0
  195. aiagents4pharma/talk2scholars/docker-compose/gpu/docker-compose.yml +105 -0
  196. aiagents4pharma/talk2scholars/install.md +122 -0
  197. aiagents4pharma/talk2scholars/state/state_talk2scholars.py +8 -8
  198. aiagents4pharma/talk2scholars/tests/{test_main_agent.py → test_agents_main_agent.py} +41 -23
  199. aiagents4pharma/talk2scholars/tests/{test_paper_download_agent.py → test_agents_paper_agents_download_agent.py} +10 -16
  200. aiagents4pharma/talk2scholars/tests/{test_pdf_agent.py → test_agents_pdf_agent.py} +6 -10
  201. aiagents4pharma/talk2scholars/tests/{test_s2_agent.py → test_agents_s2_agent.py} +8 -16
  202. aiagents4pharma/talk2scholars/tests/{test_zotero_agent.py → test_agents_zotero_agent.py} +5 -7
  203. aiagents4pharma/talk2scholars/tests/{test_s2_display_dataframe.py → test_s2_tools_display_dataframe.py} +6 -7
  204. aiagents4pharma/talk2scholars/tests/{test_s2_query_dataframe.py → test_s2_tools_query_dataframe.py} +5 -15
  205. aiagents4pharma/talk2scholars/tests/{test_paper_downloader.py → test_tools_paper_downloader.py} +25 -63
  206. aiagents4pharma/talk2scholars/tests/{test_question_and_answer_tool.py → test_tools_question_and_answer_tool.py} +2 -6
  207. aiagents4pharma/talk2scholars/tests/{test_s2_multi.py → test_tools_s2_multi.py} +5 -5
  208. aiagents4pharma/talk2scholars/tests/{test_s2_retrieve.py → test_tools_s2_retrieve.py} +2 -1
  209. aiagents4pharma/talk2scholars/tests/{test_s2_search.py → test_tools_s2_search.py} +5 -5
  210. aiagents4pharma/talk2scholars/tests/{test_s2_single.py → test_tools_s2_single.py} +5 -5
  211. aiagents4pharma/talk2scholars/tests/{test_arxiv_downloader.py → test_utils_arxiv_downloader.py} +16 -25
  212. aiagents4pharma/talk2scholars/tests/{test_base_paper_downloader.py → test_utils_base_paper_downloader.py} +25 -47
  213. aiagents4pharma/talk2scholars/tests/{test_biorxiv_downloader.py → test_utils_biorxiv_downloader.py} +14 -42
  214. aiagents4pharma/talk2scholars/tests/{test_medrxiv_downloader.py → test_utils_medrxiv_downloader.py} +15 -49
  215. aiagents4pharma/talk2scholars/tests/{test_nvidia_nim_reranker.py → test_utils_nvidia_nim_reranker.py} +6 -16
  216. aiagents4pharma/talk2scholars/tests/{test_pdf_answer_formatter.py → test_utils_pdf_answer_formatter.py} +1 -0
  217. aiagents4pharma/talk2scholars/tests/{test_pdf_batch_processor.py → test_utils_pdf_batch_processor.py} +6 -15
  218. aiagents4pharma/talk2scholars/tests/{test_pdf_collection_manager.py → test_utils_pdf_collection_manager.py} +34 -11
  219. aiagents4pharma/talk2scholars/tests/{test_pdf_document_processor.py → test_utils_pdf_document_processor.py} +2 -3
  220. aiagents4pharma/talk2scholars/tests/{test_pdf_generate_answer.py → test_utils_pdf_generate_answer.py} +3 -6
  221. aiagents4pharma/talk2scholars/tests/{test_pdf_gpu_detection.py → test_utils_pdf_gpu_detection.py} +5 -16
  222. aiagents4pharma/talk2scholars/tests/{test_pdf_rag_pipeline.py → test_utils_pdf_rag_pipeline.py} +7 -17
  223. aiagents4pharma/talk2scholars/tests/{test_pdf_retrieve_chunks.py → test_utils_pdf_retrieve_chunks.py} +4 -11
  224. aiagents4pharma/talk2scholars/tests/{test_pdf_singleton_manager.py → test_utils_pdf_singleton_manager.py} +26 -23
  225. aiagents4pharma/talk2scholars/tests/{test_pdf_vector_normalization.py → test_utils_pdf_vector_normalization.py} +1 -1
  226. aiagents4pharma/talk2scholars/tests/{test_pdf_vector_store.py → test_utils_pdf_vector_store.py} +27 -55
  227. aiagents4pharma/talk2scholars/tests/{test_pubmed_downloader.py → test_utils_pubmed_downloader.py} +31 -91
  228. aiagents4pharma/talk2scholars/tests/{test_read_helper_utils.py → test_utils_read_helper_utils.py} +2 -6
  229. aiagents4pharma/talk2scholars/tests/{test_s2_utils_ext_ids.py → test_utils_s2_utils_ext_ids.py} +5 -15
  230. aiagents4pharma/talk2scholars/tests/{test_zotero_human_in_the_loop.py → test_utils_zotero_human_in_the_loop.py} +6 -13
  231. aiagents4pharma/talk2scholars/tests/{test_zotero_path.py → test_utils_zotero_path.py} +53 -45
  232. aiagents4pharma/talk2scholars/tests/{test_zotero_read.py → test_utils_zotero_read.py} +30 -91
  233. aiagents4pharma/talk2scholars/tests/{test_zotero_write.py → test_utils_zotero_write.py} +6 -16
  234. aiagents4pharma/talk2scholars/tools/__init__.py +1 -4
  235. aiagents4pharma/talk2scholars/tools/paper_download/paper_downloader.py +20 -35
  236. aiagents4pharma/talk2scholars/tools/paper_download/utils/__init__.py +7 -5
  237. aiagents4pharma/talk2scholars/tools/paper_download/utils/arxiv_downloader.py +9 -11
  238. aiagents4pharma/talk2scholars/tools/paper_download/utils/base_paper_downloader.py +14 -21
  239. aiagents4pharma/talk2scholars/tools/paper_download/utils/biorxiv_downloader.py +14 -22
  240. aiagents4pharma/talk2scholars/tools/paper_download/utils/medrxiv_downloader.py +11 -13
  241. aiagents4pharma/talk2scholars/tools/paper_download/utils/pubmed_downloader.py +14 -28
  242. aiagents4pharma/talk2scholars/tools/pdf/question_and_answer.py +4 -8
  243. aiagents4pharma/talk2scholars/tools/pdf/utils/__init__.py +16 -14
  244. aiagents4pharma/talk2scholars/tools/pdf/utils/answer_formatter.py +4 -4
  245. aiagents4pharma/talk2scholars/tools/pdf/utils/batch_processor.py +15 -17
  246. aiagents4pharma/talk2scholars/tools/pdf/utils/collection_manager.py +2 -2
  247. aiagents4pharma/talk2scholars/tools/pdf/utils/document_processor.py +5 -5
  248. aiagents4pharma/talk2scholars/tools/pdf/utils/generate_answer.py +4 -4
  249. aiagents4pharma/talk2scholars/tools/pdf/utils/get_vectorstore.py +2 -6
  250. aiagents4pharma/talk2scholars/tools/pdf/utils/gpu_detection.py +5 -9
  251. aiagents4pharma/talk2scholars/tools/pdf/utils/nvidia_nim_reranker.py +4 -4
  252. aiagents4pharma/talk2scholars/tools/pdf/utils/paper_loader.py +2 -2
  253. aiagents4pharma/talk2scholars/tools/pdf/utils/rag_pipeline.py +6 -15
  254. aiagents4pharma/talk2scholars/tools/pdf/utils/retrieve_chunks.py +7 -15
  255. aiagents4pharma/talk2scholars/tools/pdf/utils/singleton_manager.py +2 -2
  256. aiagents4pharma/talk2scholars/tools/pdf/utils/tool_helper.py +3 -4
  257. aiagents4pharma/talk2scholars/tools/pdf/utils/vector_normalization.py +8 -17
  258. aiagents4pharma/talk2scholars/tools/pdf/utils/vector_store.py +17 -33
  259. aiagents4pharma/talk2scholars/tools/s2/__init__.py +8 -6
  260. aiagents4pharma/talk2scholars/tools/s2/display_dataframe.py +3 -7
  261. aiagents4pharma/talk2scholars/tools/s2/multi_paper_rec.py +7 -6
  262. aiagents4pharma/talk2scholars/tools/s2/query_dataframe.py +5 -12
  263. aiagents4pharma/talk2scholars/tools/s2/retrieve_semantic_scholar_paper_id.py +2 -4
  264. aiagents4pharma/talk2scholars/tools/s2/search.py +6 -6
  265. aiagents4pharma/talk2scholars/tools/s2/single_paper_rec.py +5 -3
  266. aiagents4pharma/talk2scholars/tools/s2/utils/__init__.py +1 -3
  267. aiagents4pharma/talk2scholars/tools/s2/utils/multi_helper.py +12 -18
  268. aiagents4pharma/talk2scholars/tools/s2/utils/search_helper.py +11 -18
  269. aiagents4pharma/talk2scholars/tools/s2/utils/single_helper.py +11 -16
  270. aiagents4pharma/talk2scholars/tools/zotero/__init__.py +1 -4
  271. aiagents4pharma/talk2scholars/tools/zotero/utils/__init__.py +1 -4
  272. aiagents4pharma/talk2scholars/tools/zotero/utils/read_helper.py +21 -39
  273. aiagents4pharma/talk2scholars/tools/zotero/utils/review_helper.py +2 -6
  274. aiagents4pharma/talk2scholars/tools/zotero/utils/write_helper.py +8 -11
  275. aiagents4pharma/talk2scholars/tools/zotero/utils/zotero_path.py +4 -12
  276. aiagents4pharma/talk2scholars/tools/zotero/utils/zotero_pdf_downloader.py +13 -27
  277. aiagents4pharma/talk2scholars/tools/zotero/zotero_read.py +4 -7
  278. aiagents4pharma/talk2scholars/tools/zotero/zotero_review.py +8 -10
  279. aiagents4pharma/talk2scholars/tools/zotero/zotero_write.py +3 -2
  280. {aiagents4pharma-1.44.0.dist-info → aiagents4pharma-1.45.1.dist-info}/METADATA +115 -51
  281. aiagents4pharma-1.45.1.dist-info/RECORD +324 -0
  282. {aiagents4pharma-1.44.0.dist-info → aiagents4pharma-1.45.1.dist-info}/WHEEL +1 -2
  283. aiagents4pharma-1.44.0.dist-info/RECORD +0 -293
  284. aiagents4pharma-1.44.0.dist-info/top_level.txt +0 -1
  285. /aiagents4pharma/talk2scholars/tests/{test_state.py → test_states_state.py} +0 -0
  286. /aiagents4pharma/talk2scholars/tests/{test_pdf_paper_loader.py → test_utils_pdf_paper_loader.py} +0 -0
  287. /aiagents4pharma/talk2scholars/tests/{test_tool_helper_utils.py → test_utils_tool_helper_utils.py} +0 -0
  288. /aiagents4pharma/talk2scholars/tests/{test_zotero_pdf_downloader_utils.py → test_utils_zotero_pdf_downloader_utils.py} +0 -0
  289. {aiagents4pharma-1.44.0.dist-info → aiagents4pharma-1.45.1.dist-info}/licenses/LICENSE +0 -0
@@ -3,6 +3,7 @@ Test cases for tools/subgraph_extraction.py
3
3
  """
4
4
 
5
5
  import pytest
6
+
6
7
  # from langchain_openai import ChatOpenAI, OpenAIEmbeddings
7
8
  from ..tools.multimodal_subgraph_extraction import MultimodalSubgraphExtractionTool
8
9
 
@@ -24,7 +25,7 @@ def agent_state_fixture():
24
25
  "cellular_component": [],
25
26
  "biological_process": [],
26
27
  "drug": [],
27
- "disease": []
28
+ "disease": [],
28
29
  },
29
30
  "uploaded_files": [],
30
31
  "topk_nodes": 3,
@@ -59,13 +60,16 @@ def test_extract_multimodal_subgraph_wo_doc(agent_state):
59
60
 
60
61
  # Invoking the subgraph_extraction_tool
61
62
  response = subgraph_extraction_tool.invoke(
62
- input={"prompt": prompt,
63
- "tool_call_id": "subgraph_extraction_tool",
64
- "state": agent_state,
65
- "arg_data": {"extraction_name": "subkg_12345"}})
63
+ input={
64
+ "prompt": prompt,
65
+ "tool_call_id": "subgraph_extraction_tool",
66
+ "state": agent_state,
67
+ "arg_data": {"extraction_name": "subkg_12345"},
68
+ }
69
+ )
66
70
 
67
71
  # Check tool message
68
- assert response.update["messages"][-1].tool_call_id == "subgraph_extraction_tool"
72
+ assert response.update["messages"][-1].tool_call_id == "subgraph_extraction_tool"
69
73
 
70
74
  # Check extracted subgraph dictionary
71
75
  dic_extracted_graph = response.update["dic_extracted_graph"][0]
@@ -80,13 +84,13 @@ def test_extract_multimodal_subgraph_wo_doc(agent_state):
80
84
  assert isinstance(dic_extracted_graph["graph_text"], str)
81
85
  # Check if the nodes are in the graph_text
82
86
  assert all(
83
- n[0] in dic_extracted_graph["graph_text"].replace('"', '')
87
+ n[0] in dic_extracted_graph["graph_text"].replace('"', "")
84
88
  for n in dic_extracted_graph["graph_dict"]["nodes"]
85
89
  )
86
90
  # Check if the edges are in the graph_text
87
91
  assert all(
88
92
  ",".join([e[0], str(tuple(e[2]["relation"])), e[1]])
89
- in dic_extracted_graph["graph_text"].replace('"', '')
93
+ in dic_extracted_graph["graph_text"].replace('"', "")
90
94
  for e in dic_extracted_graph["graph_dict"]["edges"]
91
95
  )
92
96
 
@@ -120,13 +124,16 @@ def test_extract_multimodal_subgraph_w_doc(agent_state):
120
124
 
121
125
  # Invoking the subgraph_extraction_tool
122
126
  response = subgraph_extraction_tool.invoke(
123
- input={"prompt": prompt,
124
- "tool_call_id": "subgraph_extraction_tool",
125
- "state": agent_state,
126
- "arg_data": {"extraction_name": "subkg_12345"}})
127
+ input={
128
+ "prompt": prompt,
129
+ "tool_call_id": "subgraph_extraction_tool",
130
+ "state": agent_state,
131
+ "arg_data": {"extraction_name": "subkg_12345"},
132
+ }
133
+ )
127
134
 
128
135
  # Check tool message
129
- assert response.update["messages"][-1].tool_call_id == "subgraph_extraction_tool"
136
+ assert response.update["messages"][-1].tool_call_id == "subgraph_extraction_tool"
130
137
 
131
138
  # Check extracted subgraph dictionary
132
139
  dic_extracted_graph = response.update["dic_extracted_graph"][0]
@@ -141,12 +148,12 @@ def test_extract_multimodal_subgraph_w_doc(agent_state):
141
148
  assert isinstance(dic_extracted_graph["graph_text"], str)
142
149
  # Check if the nodes are in the graph_text
143
150
  assert all(
144
- n[0] in dic_extracted_graph["graph_text"].replace('"', '')
151
+ n[0] in dic_extracted_graph["graph_text"].replace('"', "")
145
152
  for n in dic_extracted_graph["graph_dict"]["nodes"]
146
153
  )
147
154
  # Check if the edges are in the graph_text
148
155
  assert all(
149
156
  ",".join([e[0], str(tuple(e[2]["relation"])), e[1]])
150
- in dic_extracted_graph["graph_text"].replace('"', '')
157
+ in dic_extracted_graph["graph_text"].replace('"', "")
151
158
  for e in dic_extracted_graph["graph_dict"]["edges"]
152
159
  )
@@ -4,6 +4,7 @@ Test cases for tools/subgraph_extraction.py
4
4
 
5
5
  import pytest
6
6
  from langchain_openai import ChatOpenAI, OpenAIEmbeddings
7
+
7
8
  from ..tools.subgraph_extraction import SubgraphExtractionTool
8
9
 
9
10
  # Define the data path
@@ -41,7 +42,7 @@ def test_extract_subgraph_wo_docs(agent_state):
41
42
  agent_state: Agent state in the form of a dictionary.
42
43
  """
43
44
  prompt = """
44
- Extract all relevant information related to nodes of genes related to inflammatory bowel disease
45
+ Extract all relevant information related to nodes of genes related to inflammatory bowel disease
45
46
  (IBD) that existed in the knowledge graph.
46
47
  Please set the extraction name for this process as `subkg_12345`.
47
48
  """
@@ -51,13 +52,16 @@ def test_extract_subgraph_wo_docs(agent_state):
51
52
 
52
53
  # Invoking the subgraph_extraction_tool
53
54
  response = subgraph_extraction_tool.invoke(
54
- input={"prompt": prompt,
55
- "tool_call_id": "subgraph_extraction_tool",
56
- "state": agent_state,
57
- "arg_data": {"extraction_name": "subkg_12345"}})
55
+ input={
56
+ "prompt": prompt,
57
+ "tool_call_id": "subgraph_extraction_tool",
58
+ "state": agent_state,
59
+ "arg_data": {"extraction_name": "subkg_12345"},
60
+ }
61
+ )
58
62
 
59
63
  # Check tool message
60
- assert response.update["messages"][-1].tool_call_id == "subgraph_extraction_tool"
64
+ assert response.update["messages"][-1].tool_call_id == "subgraph_extraction_tool"
61
65
 
62
66
  # Check extracted subgraph dictionary
63
67
  dic_extracted_graph = response.update["dic_extracted_graph"][0]
@@ -103,7 +107,7 @@ def test_extract_subgraph_w_docs(agent_state):
103
107
  ]
104
108
 
105
109
  prompt = """
106
- Extract all relevant information related to nodes of genes related to inflammatory bowel disease
110
+ Extract all relevant information related to nodes of genes related to inflammatory bowel disease
107
111
  (IBD) that existed in the knowledge graph.
108
112
  Please set the extraction name for this process as `subkg_12345`.
109
113
  """
@@ -113,13 +117,16 @@ def test_extract_subgraph_w_docs(agent_state):
113
117
 
114
118
  # Invoking the subgraph_extraction_tool
115
119
  response = subgraph_extraction_tool.invoke(
116
- input={"prompt": prompt,
117
- "tool_call_id": "subgraph_extraction_tool",
118
- "state": agent_state,
119
- "arg_data": {"extraction_name": "subkg_12345"}})
120
+ input={
121
+ "prompt": prompt,
122
+ "tool_call_id": "subgraph_extraction_tool",
123
+ "state": agent_state,
124
+ "arg_data": {"extraction_name": "subkg_12345"},
125
+ }
126
+ )
120
127
 
121
128
  # Check tool message
122
- assert response.update["messages"][-1].tool_call_id == "subgraph_extraction_tool"
129
+ assert response.update["messages"][-1].tool_call_id == "subgraph_extraction_tool"
123
130
 
124
131
  # Check extracted subgraph dictionary
125
132
  dic_extracted_graph = response.update["dic_extracted_graph"][0]
@@ -5,6 +5,7 @@ Test cases for tools/subgraph_summarization.py
5
5
  import pytest
6
6
  from langchain_core.messages import HumanMessage
7
7
  from langchain_openai import ChatOpenAI, OpenAIEmbeddings
8
+
8
9
  from ..agents.t2kg_agent import get_app
9
10
 
10
11
  # Define the data path
@@ -37,58 +38,104 @@ def input_dict_fixture():
37
38
  "topk_nodes": 3,
38
39
  "topk_edges": 3,
39
40
  "graph_dict": {
40
- 'nodes': [('IFNG_(3495)', {}),
41
- ('IKBKG_(3672)', {}),
42
- ('ATG16L1_(6661)', {}),
43
- ('inflammatory bowel disease_(28158)', {}),
44
- ('Crohn ileitis and jejunitis_(35814)', {}),
45
- ("Crohn's colitis_(83770)", {})],
46
- 'edges': [('IFNG_(3495)', 'inflammatory bowel disease_(28158)',
47
- {'relation': ['gene/protein', 'associated with', 'disease'],
48
- 'label': ['gene/protein', 'associated with', 'disease']}),
49
- ('IFNG_(3495)', "Crohn's colitis_(83770)",
50
- {'relation': ['gene/protein', 'associated with', 'disease'],
51
- 'label': ['gene/protein', 'associated with', 'disease']}),
52
- ('IFNG_(3495)', 'Crohn ileitis and jejunitis_(35814)',
53
- {'relation': ['gene/protein', 'associated with', 'disease'],
54
- 'label': ['gene/protein', 'associated with', 'disease']}),
55
- ('ATG16L1_(6661)', 'IKBKG_(3672)',
56
- {'relation': ['gene/protein', 'ppi', 'gene/protein'],
57
- 'label': ['gene/protein', 'ppi', 'gene/protein']}),
58
- ("Crohn's colitis_(83770)", 'ATG16L1_(6661)',
59
- {'relation': ['disease', 'associated with', 'gene/protein'],
60
- 'label': ['disease', 'associated with', 'gene/protein']})]},
41
+ "nodes": [
42
+ ("IFNG_(3495)", {}),
43
+ ("IKBKG_(3672)", {}),
44
+ ("ATG16L1_(6661)", {}),
45
+ ("inflammatory bowel disease_(28158)", {}),
46
+ ("Crohn ileitis and jejunitis_(35814)", {}),
47
+ ("Crohn's colitis_(83770)", {}),
48
+ ],
49
+ "edges": [
50
+ (
51
+ "IFNG_(3495)",
52
+ "inflammatory bowel disease_(28158)",
53
+ {
54
+ "relation": [
55
+ "gene/protein",
56
+ "associated with",
57
+ "disease",
58
+ ],
59
+ "label": ["gene/protein", "associated with", "disease"],
60
+ },
61
+ ),
62
+ (
63
+ "IFNG_(3495)",
64
+ "Crohn's colitis_(83770)",
65
+ {
66
+ "relation": [
67
+ "gene/protein",
68
+ "associated with",
69
+ "disease",
70
+ ],
71
+ "label": ["gene/protein", "associated with", "disease"],
72
+ },
73
+ ),
74
+ (
75
+ "IFNG_(3495)",
76
+ "Crohn ileitis and jejunitis_(35814)",
77
+ {
78
+ "relation": [
79
+ "gene/protein",
80
+ "associated with",
81
+ "disease",
82
+ ],
83
+ "label": ["gene/protein", "associated with", "disease"],
84
+ },
85
+ ),
86
+ (
87
+ "ATG16L1_(6661)",
88
+ "IKBKG_(3672)",
89
+ {
90
+ "relation": ["gene/protein", "ppi", "gene/protein"],
91
+ "label": ["gene/protein", "ppi", "gene/protein"],
92
+ },
93
+ ),
94
+ (
95
+ "Crohn's colitis_(83770)",
96
+ "ATG16L1_(6661)",
97
+ {
98
+ "relation": [
99
+ "disease",
100
+ "associated with",
101
+ "gene/protein",
102
+ ],
103
+ "label": ["disease", "associated with", "gene/protein"],
104
+ },
105
+ ),
106
+ ],
107
+ },
61
108
  "graph_text": """
62
109
  node_id,node_attr
63
- IFNG_(3495),"IFNG belongs to gene/protein category.
64
- This gene encodes a soluble cytokine that is a member of the type II interferon class.
65
- The encoded protein is secreted by cells of both the innate and adaptive immune systems.
66
- The active protein is a homodimer that binds to the interferon gamma receptor
67
- which triggers a cellular response to viral and microbial infections.
68
- Mutations in this gene are associated with an increased susceptibility to viral,
69
- bacterial and parasitic infections and to several autoimmune diseases.
110
+ IFNG_(3495),"IFNG belongs to gene/protein category.
111
+ This gene encodes a soluble cytokine that is a member of the type II interferon class.
112
+ The encoded protein is secreted by cells of both the innate and adaptive immune systems.
113
+ The active protein is a homodimer that binds to the interferon gamma receptor
114
+ which triggers a cellular response to viral and microbial infections.
115
+ Mutations in this gene are associated with an increased susceptibility to viral,
116
+ bacterial and parasitic infections and to several autoimmune diseases.
70
117
  [provided by RefSeq, Dec 2015]."
71
- IKBKG_(3672),"IKBKG belongs to gene/protein category. This gene encodes the regulatory
72
- subunit of the inhibitor of kappaB kinase (IKK) complex, which activates NF-kappaB
73
- resulting in activation of genes involved in inflammation, immunity, cell survival,
74
- and other pathways. Mutations in this gene result in incontinentia pigmenti,
75
- hypohidrotic ectodermal dysplasia, and several other types of immunodeficiencies.
76
- A pseudogene highly similar to this locus is located in an adjacent region of the
118
+ IKBKG_(3672),"IKBKG belongs to gene/protein category. This gene encodes the regulatory
119
+ subunit of the inhibitor of kappaB kinase (IKK) complex, which activates NF-kappaB
120
+ resulting in activation of genes involved in inflammation, immunity, cell survival,
121
+ and other pathways. Mutations in this gene result in incontinentia pigmenti,
122
+ hypohidrotic ectodermal dysplasia, and several other types of immunodeficiencies.
123
+ A pseudogene highly similar to this locus is located in an adjacent region of the
77
124
  X chromosome. [provided by RefSeq, Mar 2016]."
78
- ATG16L1_(6661),"ATG16L1 belongs to gene/protein category. The protein encoded
79
- by this gene is part of a large protein complex that is necessary for autophagy,
80
- the major process by which intracellular components are targeted to lysosomes
81
- for degradation. Defects in this gene are a cause of susceptibility to inflammatory
82
- bowel disease type 10 (IBD10). Several transcript variants encoding different
125
+ ATG16L1_(6661),"ATG16L1 belongs to gene/protein category. The protein encoded
126
+ by this gene is part of a large protein complex that is necessary for autophagy,
127
+ the major process by which intracellular components are targeted to lysosomes
128
+ for degradation. Defects in this gene are a cause of susceptibility to inflammatory
129
+ bowel disease type 10 (IBD10). Several transcript variants encoding different
83
130
  isoforms have been found for this gene.[provided by RefSeq, Jun 2010]."
84
- inflammatory bowel disease_(28158),inflammatory bowel disease belongs to disease
85
- category. Any inflammatory bowel disease in which the cause of the disease
86
- is a mutation in the NOD2 gene.
87
- Crohn ileitis and jejunitis_(35814),Crohn ileitis and jejunitis belongs to
88
- disease category. An Crohn disease involving a pathogenic inflammatory
89
- response in the ileum.
90
- Crohn's colitis_(83770),Crohn's colitis belongs to disease category.
91
- Crohn's disease affecting the colon.
131
+ inflammatory bowel disease_(28158),inflammatory bowel disease belongs to disease
132
+ category. Any inflammatory bowel disease in which the cause of the disease
133
+ is a mutation in the NOD2 gene.
134
+ Crohn ileitis and jejunitis_(35814),Crohn ileitis and jejunitis belongs to
135
+ disease category. An Crohn disease involving a pathogenic inflammatory
136
+ response in the ileum.
137
+ Crohn's colitis_(83770),Crohn's colitis belongs to disease category.
138
+ Crohn's disease affecting the colon.
92
139
 
93
140
  head_id,edge_type,tail_id
94
141
  Crohn's colitis_(83770),"('disease', 'associated with', 'gene/protein')",
@@ -129,7 +176,7 @@ def test_summarize_subgraph(input_dict):
129
176
  input_dict,
130
177
  )
131
178
  prompt = """
132
- Please directly invoke `subgraph_summarization` tool without calling any other tools
179
+ Please directly invoke `subgraph_summarization` tool without calling any other tools
133
180
  to respond to the following prompt:
134
181
 
135
182
  You are given a subgraph in the forms of textualized subgraph representing
@@ -3,8 +3,10 @@ Test cases for utils/embeddings/embeddings.py
3
3
  """
4
4
 
5
5
  import pytest
6
+
6
7
  from ..utils.embeddings.embeddings import Embeddings
7
8
 
9
+
8
10
  class TestEmbeddings(Embeddings):
9
11
  """Test implementation of the Embeddings interface for testing purposes."""
10
12
 
@@ -14,6 +16,7 @@ class TestEmbeddings(Embeddings):
14
16
  def embed_query(self, text: str) -> list[float]:
15
17
  return [0.1, 0.2, 0.3]
16
18
 
19
+
17
20
  def test_embed_documents():
18
21
  """Test embedding documents using the Embeddings interface."""
19
22
  embeddings = TestEmbeddings()
@@ -29,6 +32,7 @@ def test_embed_query():
29
32
  result = embeddings.embed_query(text)
30
33
  assert result == [0.1, 0.2, 0.3]
31
34
 
35
+
32
36
  @pytest.mark.asyncio
33
37
  async def test_aembed_documents():
34
38
  """Test asynchronous embedding of documents using the Embeddings interface."""
@@ -3,8 +3,10 @@ Test cases for utils/embeddings/huggingface.py
3
3
  """
4
4
 
5
5
  import pytest
6
+
6
7
  from ..utils.embeddings.huggingface import EmbeddingWithHuggingFace
7
8
 
9
+
8
10
  @pytest.fixture(name="embedding_model")
9
11
  def embedding_model_fixture():
10
12
  """Return the configuration object for the HuggingFace embedding model and model object"""
@@ -14,6 +16,7 @@ def embedding_model_fixture():
14
16
  truncation=True,
15
17
  )
16
18
 
19
+
17
20
  def test_embedding_with_huggingface_embed_documents(embedding_model):
18
21
  """Test embedding documents using the EmbeddingWithHuggingFace class."""
19
22
  # Perform embedding
@@ -23,6 +26,7 @@ def test_embedding_with_huggingface_embed_documents(embedding_model):
23
26
  assert len(result) == 3
24
27
  assert len(result[0]) == 768
25
28
 
29
+
26
30
  def test_embedding_with_huggingface_embed_query(embedding_model):
27
31
  """Test embedding a query using the EmbeddingWithHuggingFace class."""
28
32
  # Perform embedding
@@ -31,6 +35,7 @@ def test_embedding_with_huggingface_embed_query(embedding_model):
31
35
  # Check the result
32
36
  assert len(result) == 768
33
37
 
38
+
34
39
  def test_embedding_with_huggingface_failed():
35
40
  """Test embedding documents using the EmbeddingWithHuggingFace class."""
36
41
  # Check if the model is available on HuggingFace Hub
@@ -5,27 +5,28 @@ Test cases for utils/embeddings/nim_molmim.py
5
5
  """
6
6
 
7
7
  import unittest
8
- from unittest.mock import patch, MagicMock
8
+ from unittest.mock import MagicMock, patch
9
+
9
10
  from ..utils.embeddings.nim_molmim import EmbeddingWithMOLMIM
10
11
 
12
+
11
13
  class TestEmbeddingWithMOLMIM(unittest.TestCase):
12
14
  """
13
15
  Test cases for EmbeddingWithMOLMIM class.
14
16
  """
17
+
15
18
  def setUp(self):
16
19
  self.base_url = "https://fake-nim-api.com/embeddings"
17
20
  self.embeddings_model = EmbeddingWithMOLMIM(self.base_url)
18
21
  self.test_texts = ["CCO", "CCC", "C=O"]
19
22
  self.test_query = "CCO"
20
- self.mock_response = {
21
- "embeddings": [[0.1, 0.2, 0.3], [0.4, 0.5, 0.6], [0.7, 0.8, 0.9]]
22
- }
23
+ self.mock_response = {"embeddings": [[0.1, 0.2, 0.3], [0.4, 0.5, 0.6], [0.7, 0.8, 0.9]]}
23
24
 
24
25
  @patch("requests.post")
25
26
  def test_embed_documents(self, mock_post):
26
- '''
27
+ """
27
28
  Test the embed_documents method.
28
- '''
29
+ """
29
30
  # Mock the response from requests.post
30
31
  mock_post.return_value = MagicMock()
31
32
  mock_post.return_value.json.return_value = self.mock_response
@@ -34,19 +35,16 @@ class TestEmbeddingWithMOLMIM(unittest.TestCase):
34
35
  self.assertEqual(embeddings, self.mock_response["embeddings"])
35
36
  mock_post.assert_called_once_with(
36
37
  self.base_url,
37
- headers={
38
- 'accept': 'application/json',
39
- 'Content-Type': 'application/json'
40
- },
38
+ headers={"accept": "application/json", "Content-Type": "application/json"},
41
39
  data='{"sequences": ["CCO", "CCC", "C=O"]}',
42
- timeout=60
40
+ timeout=60,
43
41
  )
44
42
 
45
43
  @patch("requests.post")
46
44
  def test_embed_query(self, mock_post):
47
- '''
45
+ """
48
46
  Test the embed_query method.
49
- '''
47
+ """
50
48
  # Mock the response from requests.post
51
49
  mock_post.return_value = MagicMock()
52
50
  mock_post.return_value.json.return_value = {"embeddings": [[0.1, 0.2, 0.3]]}
@@ -55,10 +53,7 @@ class TestEmbeddingWithMOLMIM(unittest.TestCase):
55
53
  self.assertEqual(embedding, [[0.1, 0.2, 0.3]])
56
54
  mock_post.assert_called_once_with(
57
55
  self.base_url,
58
- headers={
59
- 'accept': 'application/json',
60
- 'Content-Type': 'application/json'
61
- },
56
+ headers={"accept": "application/json", "Content-Type": "application/json"},
62
57
  data='{"sequences": ["CCO"]}',
63
- timeout=60
58
+ timeout=60,
64
59
  )
@@ -2,17 +2,20 @@
2
2
  Test cases for utils/embeddings/ollama.py
3
3
  """
4
4
 
5
- import pytest
6
5
  import ollama
6
+ import pytest
7
+
7
8
  from ..utils.embeddings.ollama import EmbeddingWithOllama
8
9
 
10
+
9
11
  @pytest.fixture(name="ollama_config")
10
12
  def fixture_ollama_config():
11
13
  """Return a dictionary with Ollama configuration."""
12
14
  return {
13
- "model_name": "all-minilm", # Choose a small model
15
+ "model_name": "all-minilm", # Choose a small model
14
16
  }
15
17
 
18
+
16
19
  def test_no_model_ollama(ollama_config):
17
20
  """Test the case when the Ollama model is not available."""
18
21
  cfg = ollama_config
@@ -25,16 +28,19 @@ def test_no_model_ollama(ollama_config):
25
28
 
26
29
  # Check if the model is available
27
30
  with pytest.raises(
28
- ValueError, match=f"Error: Pulled {cfg["model_name"]} model and restarted Ollama server."
31
+ ValueError,
32
+ match=f"Error: Pulled {cfg['model_name']} model and restarted Ollama server.",
29
33
  ):
30
34
  EmbeddingWithOllama(model_name=cfg["model_name"])
31
35
 
36
+
32
37
  @pytest.fixture(name="embedding_model")
33
38
  def embedding_model_fixture(ollama_config):
34
39
  """Return the configuration object for the Ollama embedding model and model object"""
35
40
  cfg = ollama_config
36
41
  return EmbeddingWithOllama(model_name=cfg["model_name"])
37
42
 
43
+
38
44
  def test_embedding_with_ollama_embed_documents(embedding_model):
39
45
  """Test embedding documents using the EmbeddingWithOllama class."""
40
46
  # Perform embedding
@@ -44,6 +50,7 @@ def test_embedding_with_ollama_embed_documents(embedding_model):
44
50
  assert len(result) == 3
45
51
  assert len(result[0]) == 384
46
52
 
53
+
47
54
  def test_embedding_with_ollama_embed_query(embedding_model):
48
55
  """Test embedding a query using the EmbeddingWithOllama class."""
49
56
  # Perform embedding
@@ -4,19 +4,19 @@ Test cases for utils/enrichments/enrichments.py
4
4
 
5
5
  from ..utils.enrichments.enrichments import Enrichments
6
6
 
7
+
7
8
  class TestEnrichments(Enrichments):
8
9
  """Test implementation of the Enrichments interface for testing purposes."""
9
10
 
10
11
  def enrich_documents(self, texts: list[str]) -> list[list[float]]:
11
- return [
12
- f"Additional text description of {text} as the input." for text in texts
13
- ]
12
+ return [f"Additional text description of {text} as the input." for text in texts]
14
13
 
15
14
  def enrich_documents_with_rag(self, texts, docs):
16
15
  # Currently we don't have a RAG model to test this method.
17
16
  # Thus, we will just call the enrich_documents method instead.
18
17
  return self.enrich_documents(texts)
19
18
 
19
+
20
20
  def test_enrich_documents():
21
21
  """Test enriching documents using the Enrichments interface."""
22
22
  enrichments = TestEnrichments()
@@ -27,6 +27,7 @@ def test_enrich_documents():
27
27
  "Additional text description of text2 as the input.",
28
28
  ]
29
29
 
30
+
30
31
  def test_enrich_documents_with_rag():
31
32
  """Test enriching documents with RAG using the Enrichments interface."""
32
33
  enrichments = TestEnrichments()
@@ -2,8 +2,9 @@
2
2
  Test cases for utils/enrichments/ollama.py
3
3
  """
4
4
 
5
- import pytest
6
5
  import ollama
6
+ import pytest
7
+
7
8
  from ..utils.enrichments.ollama import EnrichmentWithOllama
8
9
 
9
10
 
@@ -13,7 +14,7 @@ def fixture_ollama_config():
13
14
  return {
14
15
  "model_name": "llama3.2:1b",
15
16
  "prompt_enrichment": """
16
- Given the input as a list of strings, please return the list of addditional information
17
+ Given the input as a list of strings, please return the list of addditional information
17
18
  of each input terms using your prior knowledge.
18
19
 
19
20
  Example:
@@ -5,6 +5,7 @@ Test cases for utils/enrichments/ols_terms.py
5
5
  """
6
6
 
7
7
  import pytest
8
+
8
9
  from ..utils.enrichments.ols_terms import EnrichmentWithOLS
9
10
 
10
11
  # In this test, we will consider 5 examples:
@@ -5,23 +5,26 @@ Test cases for utils/enrichments/pubchem_strings.py
5
5
  """
6
6
 
7
7
  import pytest
8
+
8
9
  from ..utils.enrichments.pubchem_strings import EnrichmentWithPubChem
9
10
 
10
11
  # In this test, we will consider 2 examples:
11
12
  # 1. PubChem ID: 5311000 (Alclometasone)
12
13
  # 2. PubChem ID: 1X (Fake ID)
13
14
  # The expected SMILES representation for the first PubChem ID is:
14
- SMILES_FIRST = 'C[C@@H]1C[C@H]2[C@@H]3[C@@H](CC4=CC(=O)C=C[C@@]'
15
- SMILES_FIRST += '4([C@H]3[C@H](C[C@@]2([C@]1(C(=O)CO)O)C)O)C)Cl'
15
+ SMILES_FIRST = "C[C@@H]1C[C@H]2[C@@H]3[C@@H](CC4=CC(=O)C=C[C@@]"
16
+ SMILES_FIRST += "4([C@H]3[C@H](C[C@@]2([C@]1(C(=O)CO)O)C)O)C)Cl"
16
17
  # The expected description for the first PubChem ID starts with:
17
18
  DESCRIPTION_FIRST = "Alclometasone is a prednisolone compound having an alpha-chloro substituent"
18
19
  # The expected SMILES representation and description for the second PubChem ID is None.
19
20
 
21
+
20
22
  @pytest.fixture(name="enrich_obj")
21
23
  def fixture_pubchem_config():
22
24
  """Return a dictionary with the configuration for the PubChem enrichment."""
23
25
  return EnrichmentWithPubChem()
24
26
 
27
+
25
28
  def test_enrich_documents(enrich_obj):
26
29
  """Test the enrich_documents method."""
27
30
  pubchem_ids = ["5311000", "1X"]
@@ -30,11 +33,13 @@ def test_enrich_documents(enrich_obj):
30
33
  assert enriched_descriptions[0].startswith(DESCRIPTION_FIRST)
31
34
  assert enriched_descriptions[1] is None
32
35
 
36
+
33
37
  def test_enrich_documents_with_rag(enrich_obj):
34
38
  """Test the enrich_documents_with_rag method."""
35
39
  pubchem_ids = ["5311000", "1X"]
36
- enriched_descriptions, enriched_strings = enrich_obj.enrich_documents_with_rag(pubchem_ids,
37
- None)
40
+ enriched_descriptions, enriched_strings = enrich_obj.enrich_documents_with_rag(
41
+ pubchem_ids, None
42
+ )
38
43
  assert enriched_strings == [SMILES_FIRST, None]
39
44
  assert enriched_descriptions[0].startswith(DESCRIPTION_FIRST)
40
45
  assert enriched_descriptions[1] is None