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.
- aiagents4pharma/__init__.py +11 -0
- aiagents4pharma/talk2aiagents4pharma/.dockerignore +13 -0
- aiagents4pharma/talk2aiagents4pharma/Dockerfile +133 -0
- aiagents4pharma/talk2aiagents4pharma/README.md +1 -0
- aiagents4pharma/talk2aiagents4pharma/__init__.py +5 -0
- aiagents4pharma/talk2aiagents4pharma/agents/__init__.py +6 -0
- aiagents4pharma/talk2aiagents4pharma/agents/main_agent.py +70 -0
- aiagents4pharma/talk2aiagents4pharma/configs/__init__.py +5 -0
- aiagents4pharma/talk2aiagents4pharma/configs/agents/__init__.py +5 -0
- aiagents4pharma/talk2aiagents4pharma/configs/agents/main_agent/default.yaml +29 -0
- aiagents4pharma/talk2aiagents4pharma/configs/app/__init__.py +0 -0
- aiagents4pharma/talk2aiagents4pharma/configs/app/frontend/__init__.py +0 -0
- aiagents4pharma/talk2aiagents4pharma/configs/app/frontend/default.yaml +102 -0
- aiagents4pharma/talk2aiagents4pharma/configs/config.yaml +4 -0
- aiagents4pharma/talk2aiagents4pharma/docker-compose/cpu/.env.example +23 -0
- aiagents4pharma/talk2aiagents4pharma/docker-compose/cpu/docker-compose.yml +93 -0
- aiagents4pharma/talk2aiagents4pharma/docker-compose/gpu/.env.example +23 -0
- aiagents4pharma/talk2aiagents4pharma/docker-compose/gpu/docker-compose.yml +108 -0
- aiagents4pharma/talk2aiagents4pharma/install.md +154 -0
- aiagents4pharma/talk2aiagents4pharma/states/__init__.py +5 -0
- aiagents4pharma/talk2aiagents4pharma/states/state_talk2aiagents4pharma.py +18 -0
- aiagents4pharma/talk2aiagents4pharma/tests/__init__.py +3 -0
- aiagents4pharma/talk2aiagents4pharma/tests/test_main_agent.py +312 -0
- aiagents4pharma/talk2biomodels/.dockerignore +13 -0
- aiagents4pharma/talk2biomodels/Dockerfile +104 -0
- aiagents4pharma/talk2biomodels/README.md +1 -0
- aiagents4pharma/talk2biomodels/__init__.py +5 -0
- aiagents4pharma/talk2biomodels/agents/__init__.py +6 -0
- aiagents4pharma/talk2biomodels/agents/t2b_agent.py +104 -0
- aiagents4pharma/talk2biomodels/api/__init__.py +5 -0
- aiagents4pharma/talk2biomodels/api/ols.py +75 -0
- aiagents4pharma/talk2biomodels/api/uniprot.py +36 -0
- aiagents4pharma/talk2biomodels/configs/__init__.py +5 -0
- aiagents4pharma/talk2biomodels/configs/agents/__init__.py +5 -0
- aiagents4pharma/talk2biomodels/configs/agents/t2b_agent/__init__.py +3 -0
- aiagents4pharma/talk2biomodels/configs/agents/t2b_agent/default.yaml +14 -0
- aiagents4pharma/talk2biomodels/configs/app/__init__.py +0 -0
- aiagents4pharma/talk2biomodels/configs/app/frontend/__init__.py +0 -0
- aiagents4pharma/talk2biomodels/configs/app/frontend/default.yaml +72 -0
- aiagents4pharma/talk2biomodels/configs/config.yaml +7 -0
- aiagents4pharma/talk2biomodels/configs/tools/__init__.py +5 -0
- aiagents4pharma/talk2biomodels/configs/tools/ask_question/__init__.py +3 -0
- aiagents4pharma/talk2biomodels/configs/tools/ask_question/default.yaml +30 -0
- aiagents4pharma/talk2biomodels/configs/tools/custom_plotter/__init__.py +3 -0
- aiagents4pharma/talk2biomodels/configs/tools/custom_plotter/default.yaml +8 -0
- aiagents4pharma/talk2biomodels/configs/tools/get_annotation/__init__.py +3 -0
- aiagents4pharma/talk2biomodels/configs/tools/get_annotation/default.yaml +8 -0
- aiagents4pharma/talk2biomodels/install.md +63 -0
- aiagents4pharma/talk2biomodels/models/__init__.py +5 -0
- aiagents4pharma/talk2biomodels/models/basico_model.py +125 -0
- aiagents4pharma/talk2biomodels/models/sys_bio_model.py +60 -0
- aiagents4pharma/talk2biomodels/states/__init__.py +6 -0
- aiagents4pharma/talk2biomodels/states/state_talk2biomodels.py +49 -0
- aiagents4pharma/talk2biomodels/tests/BIOMD0000000449_url.xml +1585 -0
- aiagents4pharma/talk2biomodels/tests/__init__.py +3 -0
- aiagents4pharma/talk2biomodels/tests/article_on_model_537.pdf +0 -0
- aiagents4pharma/talk2biomodels/tests/test_api.py +31 -0
- aiagents4pharma/talk2biomodels/tests/test_ask_question.py +42 -0
- aiagents4pharma/talk2biomodels/tests/test_basico_model.py +67 -0
- aiagents4pharma/talk2biomodels/tests/test_get_annotation.py +190 -0
- aiagents4pharma/talk2biomodels/tests/test_getmodelinfo.py +92 -0
- aiagents4pharma/talk2biomodels/tests/test_integration.py +116 -0
- aiagents4pharma/talk2biomodels/tests/test_load_biomodel.py +35 -0
- aiagents4pharma/talk2biomodels/tests/test_param_scan.py +71 -0
- aiagents4pharma/talk2biomodels/tests/test_query_article.py +184 -0
- aiagents4pharma/talk2biomodels/tests/test_save_model.py +47 -0
- aiagents4pharma/talk2biomodels/tests/test_search_models.py +35 -0
- aiagents4pharma/talk2biomodels/tests/test_simulate_model.py +44 -0
- aiagents4pharma/talk2biomodels/tests/test_steady_state.py +86 -0
- aiagents4pharma/talk2biomodels/tests/test_sys_bio_model.py +67 -0
- aiagents4pharma/talk2biomodels/tools/__init__.py +17 -0
- aiagents4pharma/talk2biomodels/tools/ask_question.py +125 -0
- aiagents4pharma/talk2biomodels/tools/custom_plotter.py +165 -0
- aiagents4pharma/talk2biomodels/tools/get_annotation.py +342 -0
- aiagents4pharma/talk2biomodels/tools/get_modelinfo.py +159 -0
- aiagents4pharma/talk2biomodels/tools/load_arguments.py +134 -0
- aiagents4pharma/talk2biomodels/tools/load_biomodel.py +44 -0
- aiagents4pharma/talk2biomodels/tools/parameter_scan.py +310 -0
- aiagents4pharma/talk2biomodels/tools/query_article.py +64 -0
- aiagents4pharma/talk2biomodels/tools/save_model.py +98 -0
- aiagents4pharma/talk2biomodels/tools/search_models.py +96 -0
- aiagents4pharma/talk2biomodels/tools/simulate_model.py +137 -0
- aiagents4pharma/talk2biomodels/tools/steady_state.py +187 -0
- aiagents4pharma/talk2biomodels/tools/utils.py +23 -0
- aiagents4pharma/talk2cells/README.md +1 -0
- aiagents4pharma/talk2cells/__init__.py +5 -0
- aiagents4pharma/talk2cells/agents/__init__.py +6 -0
- aiagents4pharma/talk2cells/agents/scp_agent.py +87 -0
- aiagents4pharma/talk2cells/states/__init__.py +6 -0
- aiagents4pharma/talk2cells/states/state_talk2cells.py +15 -0
- aiagents4pharma/talk2cells/tests/scp_agent/test_scp_agent.py +22 -0
- aiagents4pharma/talk2cells/tools/__init__.py +6 -0
- aiagents4pharma/talk2cells/tools/scp_agent/__init__.py +6 -0
- aiagents4pharma/talk2cells/tools/scp_agent/display_studies.py +27 -0
- aiagents4pharma/talk2cells/tools/scp_agent/search_studies.py +78 -0
- aiagents4pharma/talk2knowledgegraphs/.dockerignore +13 -0
- aiagents4pharma/talk2knowledgegraphs/Dockerfile +131 -0
- aiagents4pharma/talk2knowledgegraphs/README.md +1 -0
- aiagents4pharma/talk2knowledgegraphs/__init__.py +5 -0
- aiagents4pharma/talk2knowledgegraphs/agents/__init__.py +5 -0
- aiagents4pharma/talk2knowledgegraphs/agents/t2kg_agent.py +99 -0
- aiagents4pharma/talk2knowledgegraphs/configs/__init__.py +5 -0
- aiagents4pharma/talk2knowledgegraphs/configs/agents/t2kg_agent/__init__.py +3 -0
- aiagents4pharma/talk2knowledgegraphs/configs/agents/t2kg_agent/default.yaml +62 -0
- aiagents4pharma/talk2knowledgegraphs/configs/app/__init__.py +5 -0
- aiagents4pharma/talk2knowledgegraphs/configs/app/frontend/__init__.py +3 -0
- aiagents4pharma/talk2knowledgegraphs/configs/app/frontend/default.yaml +79 -0
- aiagents4pharma/talk2knowledgegraphs/configs/config.yaml +13 -0
- aiagents4pharma/talk2knowledgegraphs/configs/tools/__init__.py +5 -0
- aiagents4pharma/talk2knowledgegraphs/configs/tools/graphrag_reasoning/__init__.py +3 -0
- aiagents4pharma/talk2knowledgegraphs/configs/tools/graphrag_reasoning/default.yaml +24 -0
- aiagents4pharma/talk2knowledgegraphs/configs/tools/multimodal_subgraph_extraction/__init__.py +0 -0
- aiagents4pharma/talk2knowledgegraphs/configs/tools/multimodal_subgraph_extraction/default.yaml +33 -0
- aiagents4pharma/talk2knowledgegraphs/configs/tools/subgraph_extraction/__init__.py +3 -0
- aiagents4pharma/talk2knowledgegraphs/configs/tools/subgraph_extraction/default.yaml +43 -0
- aiagents4pharma/talk2knowledgegraphs/configs/tools/subgraph_summarization/__init__.py +3 -0
- aiagents4pharma/talk2knowledgegraphs/configs/tools/subgraph_summarization/default.yaml +9 -0
- aiagents4pharma/talk2knowledgegraphs/configs/utils/database/milvus/__init__.py +3 -0
- aiagents4pharma/talk2knowledgegraphs/configs/utils/database/milvus/default.yaml +61 -0
- aiagents4pharma/talk2knowledgegraphs/configs/utils/enrichments/ols_terms/default.yaml +3 -0
- aiagents4pharma/talk2knowledgegraphs/configs/utils/enrichments/reactome_pathways/default.yaml +3 -0
- aiagents4pharma/talk2knowledgegraphs/configs/utils/enrichments/uniprot_proteins/default.yaml +6 -0
- aiagents4pharma/talk2knowledgegraphs/configs/utils/pubchem_utils/default.yaml +5 -0
- aiagents4pharma/talk2knowledgegraphs/datasets/__init__.py +5 -0
- aiagents4pharma/talk2knowledgegraphs/datasets/biobridge_primekg.py +607 -0
- aiagents4pharma/talk2knowledgegraphs/datasets/dataset.py +25 -0
- aiagents4pharma/talk2knowledgegraphs/datasets/primekg.py +212 -0
- aiagents4pharma/talk2knowledgegraphs/datasets/starkqa_primekg.py +210 -0
- aiagents4pharma/talk2knowledgegraphs/docker-compose/cpu/.env.example +23 -0
- aiagents4pharma/talk2knowledgegraphs/docker-compose/cpu/docker-compose.yml +93 -0
- aiagents4pharma/talk2knowledgegraphs/docker-compose/gpu/.env.example +23 -0
- aiagents4pharma/talk2knowledgegraphs/docker-compose/gpu/docker-compose.yml +108 -0
- aiagents4pharma/talk2knowledgegraphs/entrypoint.sh +180 -0
- aiagents4pharma/talk2knowledgegraphs/install.md +165 -0
- aiagents4pharma/talk2knowledgegraphs/milvus_data_dump.py +886 -0
- aiagents4pharma/talk2knowledgegraphs/states/__init__.py +5 -0
- aiagents4pharma/talk2knowledgegraphs/states/state_talk2knowledgegraphs.py +40 -0
- aiagents4pharma/talk2knowledgegraphs/tests/__init__.py +0 -0
- aiagents4pharma/talk2knowledgegraphs/tests/test_agents_t2kg_agent.py +318 -0
- aiagents4pharma/talk2knowledgegraphs/tests/test_datasets_biobridge_primekg.py +248 -0
- aiagents4pharma/talk2knowledgegraphs/tests/test_datasets_dataset.py +33 -0
- aiagents4pharma/talk2knowledgegraphs/tests/test_datasets_primekg.py +86 -0
- aiagents4pharma/talk2knowledgegraphs/tests/test_datasets_starkqa_primekg.py +125 -0
- aiagents4pharma/talk2knowledgegraphs/tests/test_tools_graphrag_reasoning.py +257 -0
- aiagents4pharma/talk2knowledgegraphs/tests/test_tools_milvus_multimodal_subgraph_extraction.py +1444 -0
- aiagents4pharma/talk2knowledgegraphs/tests/test_tools_multimodal_subgraph_extraction.py +159 -0
- aiagents4pharma/talk2knowledgegraphs/tests/test_tools_subgraph_extraction.py +152 -0
- aiagents4pharma/talk2knowledgegraphs/tests/test_tools_subgraph_summarization.py +201 -0
- aiagents4pharma/talk2knowledgegraphs/tests/test_utils_database_milvus_connection_manager.py +812 -0
- aiagents4pharma/talk2knowledgegraphs/tests/test_utils_embeddings_embeddings.py +51 -0
- aiagents4pharma/talk2knowledgegraphs/tests/test_utils_embeddings_huggingface.py +49 -0
- aiagents4pharma/talk2knowledgegraphs/tests/test_utils_embeddings_nim_molmim.py +59 -0
- aiagents4pharma/talk2knowledgegraphs/tests/test_utils_embeddings_ollama.py +63 -0
- aiagents4pharma/talk2knowledgegraphs/tests/test_utils_embeddings_sentencetransformer.py +47 -0
- aiagents4pharma/talk2knowledgegraphs/tests/test_utils_enrichments_enrichments.py +40 -0
- aiagents4pharma/talk2knowledgegraphs/tests/test_utils_enrichments_ollama.py +94 -0
- aiagents4pharma/talk2knowledgegraphs/tests/test_utils_enrichments_ols.py +70 -0
- aiagents4pharma/talk2knowledgegraphs/tests/test_utils_enrichments_pubchem.py +45 -0
- aiagents4pharma/talk2knowledgegraphs/tests/test_utils_enrichments_reactome.py +44 -0
- aiagents4pharma/talk2knowledgegraphs/tests/test_utils_enrichments_uniprot.py +48 -0
- aiagents4pharma/talk2knowledgegraphs/tests/test_utils_extractions_milvus_multimodal_pcst.py +759 -0
- aiagents4pharma/talk2knowledgegraphs/tests/test_utils_kg_utils.py +78 -0
- aiagents4pharma/talk2knowledgegraphs/tests/test_utils_pubchem_utils.py +123 -0
- aiagents4pharma/talk2knowledgegraphs/tools/__init__.py +11 -0
- aiagents4pharma/talk2knowledgegraphs/tools/graphrag_reasoning.py +138 -0
- aiagents4pharma/talk2knowledgegraphs/tools/load_arguments.py +22 -0
- aiagents4pharma/talk2knowledgegraphs/tools/milvus_multimodal_subgraph_extraction.py +965 -0
- aiagents4pharma/talk2knowledgegraphs/tools/multimodal_subgraph_extraction.py +374 -0
- aiagents4pharma/talk2knowledgegraphs/tools/subgraph_extraction.py +291 -0
- aiagents4pharma/talk2knowledgegraphs/tools/subgraph_summarization.py +123 -0
- aiagents4pharma/talk2knowledgegraphs/utils/__init__.py +5 -0
- aiagents4pharma/talk2knowledgegraphs/utils/database/__init__.py +5 -0
- aiagents4pharma/talk2knowledgegraphs/utils/database/milvus_connection_manager.py +586 -0
- aiagents4pharma/talk2knowledgegraphs/utils/embeddings/__init__.py +5 -0
- aiagents4pharma/talk2knowledgegraphs/utils/embeddings/embeddings.py +81 -0
- aiagents4pharma/talk2knowledgegraphs/utils/embeddings/huggingface.py +111 -0
- aiagents4pharma/talk2knowledgegraphs/utils/embeddings/nim_molmim.py +54 -0
- aiagents4pharma/talk2knowledgegraphs/utils/embeddings/ollama.py +87 -0
- aiagents4pharma/talk2knowledgegraphs/utils/embeddings/sentence_transformer.py +73 -0
- aiagents4pharma/talk2knowledgegraphs/utils/enrichments/__init__.py +12 -0
- aiagents4pharma/talk2knowledgegraphs/utils/enrichments/enrichments.py +37 -0
- aiagents4pharma/talk2knowledgegraphs/utils/enrichments/ollama.py +129 -0
- aiagents4pharma/talk2knowledgegraphs/utils/enrichments/ols_terms.py +89 -0
- aiagents4pharma/talk2knowledgegraphs/utils/enrichments/pubchem_strings.py +78 -0
- aiagents4pharma/talk2knowledgegraphs/utils/enrichments/reactome_pathways.py +71 -0
- aiagents4pharma/talk2knowledgegraphs/utils/enrichments/uniprot_proteins.py +98 -0
- aiagents4pharma/talk2knowledgegraphs/utils/extractions/__init__.py +5 -0
- aiagents4pharma/talk2knowledgegraphs/utils/extractions/milvus_multimodal_pcst.py +762 -0
- aiagents4pharma/talk2knowledgegraphs/utils/extractions/multimodal_pcst.py +298 -0
- aiagents4pharma/talk2knowledgegraphs/utils/extractions/pcst.py +229 -0
- aiagents4pharma/talk2knowledgegraphs/utils/kg_utils.py +67 -0
- aiagents4pharma/talk2knowledgegraphs/utils/pubchem_utils.py +104 -0
- aiagents4pharma/talk2scholars/.dockerignore +13 -0
- aiagents4pharma/talk2scholars/Dockerfile +104 -0
- aiagents4pharma/talk2scholars/README.md +1 -0
- aiagents4pharma/talk2scholars/__init__.py +7 -0
- aiagents4pharma/talk2scholars/agents/__init__.py +13 -0
- aiagents4pharma/talk2scholars/agents/main_agent.py +89 -0
- aiagents4pharma/talk2scholars/agents/paper_download_agent.py +96 -0
- aiagents4pharma/talk2scholars/agents/pdf_agent.py +101 -0
- aiagents4pharma/talk2scholars/agents/s2_agent.py +135 -0
- aiagents4pharma/talk2scholars/agents/zotero_agent.py +127 -0
- aiagents4pharma/talk2scholars/configs/__init__.py +7 -0
- aiagents4pharma/talk2scholars/configs/agents/__init__.py +7 -0
- aiagents4pharma/talk2scholars/configs/agents/talk2scholars/__init__.py +7 -0
- aiagents4pharma/talk2scholars/configs/agents/talk2scholars/main_agent/__init__.py +3 -0
- aiagents4pharma/talk2scholars/configs/agents/talk2scholars/main_agent/default.yaml +52 -0
- aiagents4pharma/talk2scholars/configs/agents/talk2scholars/paper_download_agent/__init__.py +3 -0
- aiagents4pharma/talk2scholars/configs/agents/talk2scholars/paper_download_agent/default.yaml +19 -0
- aiagents4pharma/talk2scholars/configs/agents/talk2scholars/pdf_agent/__init__.py +3 -0
- aiagents4pharma/talk2scholars/configs/agents/talk2scholars/pdf_agent/default.yaml +19 -0
- aiagents4pharma/talk2scholars/configs/agents/talk2scholars/s2_agent/__init__.py +3 -0
- aiagents4pharma/talk2scholars/configs/agents/talk2scholars/s2_agent/default.yaml +44 -0
- aiagents4pharma/talk2scholars/configs/agents/talk2scholars/zotero_agent/__init__.py +3 -0
- aiagents4pharma/talk2scholars/configs/agents/talk2scholars/zotero_agent/default.yaml +19 -0
- aiagents4pharma/talk2scholars/configs/app/__init__.py +7 -0
- aiagents4pharma/talk2scholars/configs/app/frontend/__init__.py +3 -0
- aiagents4pharma/talk2scholars/configs/app/frontend/default.yaml +72 -0
- aiagents4pharma/talk2scholars/configs/config.yaml +16 -0
- aiagents4pharma/talk2scholars/configs/tools/__init__.py +21 -0
- aiagents4pharma/talk2scholars/configs/tools/multi_paper_recommendation/__init__.py +3 -0
- aiagents4pharma/talk2scholars/configs/tools/multi_paper_recommendation/default.yaml +26 -0
- aiagents4pharma/talk2scholars/configs/tools/paper_download/__init__.py +3 -0
- aiagents4pharma/talk2scholars/configs/tools/paper_download/default.yaml +124 -0
- aiagents4pharma/talk2scholars/configs/tools/question_and_answer/__init__.py +3 -0
- aiagents4pharma/talk2scholars/configs/tools/question_and_answer/default.yaml +62 -0
- aiagents4pharma/talk2scholars/configs/tools/retrieve_semantic_scholar_paper_id/__init__.py +3 -0
- aiagents4pharma/talk2scholars/configs/tools/retrieve_semantic_scholar_paper_id/default.yaml +12 -0
- aiagents4pharma/talk2scholars/configs/tools/search/__init__.py +3 -0
- aiagents4pharma/talk2scholars/configs/tools/search/default.yaml +26 -0
- aiagents4pharma/talk2scholars/configs/tools/single_paper_recommendation/__init__.py +3 -0
- aiagents4pharma/talk2scholars/configs/tools/single_paper_recommendation/default.yaml +26 -0
- aiagents4pharma/talk2scholars/configs/tools/zotero_read/__init__.py +3 -0
- aiagents4pharma/talk2scholars/configs/tools/zotero_read/default.yaml +57 -0
- aiagents4pharma/talk2scholars/configs/tools/zotero_write/__inti__.py +3 -0
- aiagents4pharma/talk2scholars/configs/tools/zotero_write/default.yaml +55 -0
- aiagents4pharma/talk2scholars/docker-compose/cpu/.env.example +21 -0
- aiagents4pharma/talk2scholars/docker-compose/cpu/docker-compose.yml +90 -0
- aiagents4pharma/talk2scholars/docker-compose/gpu/.env.example +21 -0
- aiagents4pharma/talk2scholars/docker-compose/gpu/docker-compose.yml +105 -0
- aiagents4pharma/talk2scholars/install.md +122 -0
- aiagents4pharma/talk2scholars/state/__init__.py +7 -0
- aiagents4pharma/talk2scholars/state/state_talk2scholars.py +98 -0
- aiagents4pharma/talk2scholars/tests/__init__.py +3 -0
- aiagents4pharma/talk2scholars/tests/test_agents_main_agent.py +256 -0
- aiagents4pharma/talk2scholars/tests/test_agents_paper_agents_download_agent.py +139 -0
- aiagents4pharma/talk2scholars/tests/test_agents_pdf_agent.py +114 -0
- aiagents4pharma/talk2scholars/tests/test_agents_s2_agent.py +198 -0
- aiagents4pharma/talk2scholars/tests/test_agents_zotero_agent.py +160 -0
- aiagents4pharma/talk2scholars/tests/test_s2_tools_display_dataframe.py +91 -0
- aiagents4pharma/talk2scholars/tests/test_s2_tools_query_dataframe.py +191 -0
- aiagents4pharma/talk2scholars/tests/test_states_state.py +38 -0
- aiagents4pharma/talk2scholars/tests/test_tools_paper_downloader.py +507 -0
- aiagents4pharma/talk2scholars/tests/test_tools_question_and_answer_tool.py +105 -0
- aiagents4pharma/talk2scholars/tests/test_tools_s2_multi.py +307 -0
- aiagents4pharma/talk2scholars/tests/test_tools_s2_retrieve.py +67 -0
- aiagents4pharma/talk2scholars/tests/test_tools_s2_search.py +286 -0
- aiagents4pharma/talk2scholars/tests/test_tools_s2_single.py +298 -0
- aiagents4pharma/talk2scholars/tests/test_utils_arxiv_downloader.py +469 -0
- aiagents4pharma/talk2scholars/tests/test_utils_base_paper_downloader.py +598 -0
- aiagents4pharma/talk2scholars/tests/test_utils_biorxiv_downloader.py +669 -0
- aiagents4pharma/talk2scholars/tests/test_utils_medrxiv_downloader.py +500 -0
- aiagents4pharma/talk2scholars/tests/test_utils_nvidia_nim_reranker.py +117 -0
- aiagents4pharma/talk2scholars/tests/test_utils_pdf_answer_formatter.py +67 -0
- aiagents4pharma/talk2scholars/tests/test_utils_pdf_batch_processor.py +92 -0
- aiagents4pharma/talk2scholars/tests/test_utils_pdf_collection_manager.py +173 -0
- aiagents4pharma/talk2scholars/tests/test_utils_pdf_document_processor.py +68 -0
- aiagents4pharma/talk2scholars/tests/test_utils_pdf_generate_answer.py +72 -0
- aiagents4pharma/talk2scholars/tests/test_utils_pdf_gpu_detection.py +129 -0
- aiagents4pharma/talk2scholars/tests/test_utils_pdf_paper_loader.py +116 -0
- aiagents4pharma/talk2scholars/tests/test_utils_pdf_rag_pipeline.py +88 -0
- aiagents4pharma/talk2scholars/tests/test_utils_pdf_retrieve_chunks.py +190 -0
- aiagents4pharma/talk2scholars/tests/test_utils_pdf_singleton_manager.py +159 -0
- aiagents4pharma/talk2scholars/tests/test_utils_pdf_vector_normalization.py +121 -0
- aiagents4pharma/talk2scholars/tests/test_utils_pdf_vector_store.py +406 -0
- aiagents4pharma/talk2scholars/tests/test_utils_pubmed_downloader.py +1007 -0
- aiagents4pharma/talk2scholars/tests/test_utils_read_helper_utils.py +106 -0
- aiagents4pharma/talk2scholars/tests/test_utils_s2_utils_ext_ids.py +403 -0
- aiagents4pharma/talk2scholars/tests/test_utils_tool_helper_utils.py +85 -0
- aiagents4pharma/talk2scholars/tests/test_utils_zotero_human_in_the_loop.py +266 -0
- aiagents4pharma/talk2scholars/tests/test_utils_zotero_path.py +496 -0
- aiagents4pharma/talk2scholars/tests/test_utils_zotero_pdf_downloader_utils.py +46 -0
- aiagents4pharma/talk2scholars/tests/test_utils_zotero_read.py +743 -0
- aiagents4pharma/talk2scholars/tests/test_utils_zotero_write.py +151 -0
- aiagents4pharma/talk2scholars/tools/__init__.py +9 -0
- aiagents4pharma/talk2scholars/tools/paper_download/__init__.py +12 -0
- aiagents4pharma/talk2scholars/tools/paper_download/paper_downloader.py +442 -0
- aiagents4pharma/talk2scholars/tools/paper_download/utils/__init__.py +22 -0
- aiagents4pharma/talk2scholars/tools/paper_download/utils/arxiv_downloader.py +207 -0
- aiagents4pharma/talk2scholars/tools/paper_download/utils/base_paper_downloader.py +336 -0
- aiagents4pharma/talk2scholars/tools/paper_download/utils/biorxiv_downloader.py +313 -0
- aiagents4pharma/talk2scholars/tools/paper_download/utils/medrxiv_downloader.py +196 -0
- aiagents4pharma/talk2scholars/tools/paper_download/utils/pubmed_downloader.py +323 -0
- aiagents4pharma/talk2scholars/tools/pdf/__init__.py +7 -0
- aiagents4pharma/talk2scholars/tools/pdf/question_and_answer.py +170 -0
- aiagents4pharma/talk2scholars/tools/pdf/utils/__init__.py +37 -0
- aiagents4pharma/talk2scholars/tools/pdf/utils/answer_formatter.py +62 -0
- aiagents4pharma/talk2scholars/tools/pdf/utils/batch_processor.py +198 -0
- aiagents4pharma/talk2scholars/tools/pdf/utils/collection_manager.py +172 -0
- aiagents4pharma/talk2scholars/tools/pdf/utils/document_processor.py +76 -0
- aiagents4pharma/talk2scholars/tools/pdf/utils/generate_answer.py +97 -0
- aiagents4pharma/talk2scholars/tools/pdf/utils/get_vectorstore.py +59 -0
- aiagents4pharma/talk2scholars/tools/pdf/utils/gpu_detection.py +150 -0
- aiagents4pharma/talk2scholars/tools/pdf/utils/nvidia_nim_reranker.py +97 -0
- aiagents4pharma/talk2scholars/tools/pdf/utils/paper_loader.py +123 -0
- aiagents4pharma/talk2scholars/tools/pdf/utils/rag_pipeline.py +113 -0
- aiagents4pharma/talk2scholars/tools/pdf/utils/retrieve_chunks.py +197 -0
- aiagents4pharma/talk2scholars/tools/pdf/utils/singleton_manager.py +140 -0
- aiagents4pharma/talk2scholars/tools/pdf/utils/tool_helper.py +86 -0
- aiagents4pharma/talk2scholars/tools/pdf/utils/vector_normalization.py +150 -0
- aiagents4pharma/talk2scholars/tools/pdf/utils/vector_store.py +327 -0
- aiagents4pharma/talk2scholars/tools/s2/__init__.py +21 -0
- aiagents4pharma/talk2scholars/tools/s2/display_dataframe.py +110 -0
- aiagents4pharma/talk2scholars/tools/s2/multi_paper_rec.py +111 -0
- aiagents4pharma/talk2scholars/tools/s2/query_dataframe.py +233 -0
- aiagents4pharma/talk2scholars/tools/s2/retrieve_semantic_scholar_paper_id.py +128 -0
- aiagents4pharma/talk2scholars/tools/s2/search.py +101 -0
- aiagents4pharma/talk2scholars/tools/s2/single_paper_rec.py +102 -0
- aiagents4pharma/talk2scholars/tools/s2/utils/__init__.py +5 -0
- aiagents4pharma/talk2scholars/tools/s2/utils/multi_helper.py +223 -0
- aiagents4pharma/talk2scholars/tools/s2/utils/search_helper.py +205 -0
- aiagents4pharma/talk2scholars/tools/s2/utils/single_helper.py +216 -0
- aiagents4pharma/talk2scholars/tools/zotero/__init__.py +7 -0
- aiagents4pharma/talk2scholars/tools/zotero/utils/__init__.py +7 -0
- aiagents4pharma/talk2scholars/tools/zotero/utils/read_helper.py +270 -0
- aiagents4pharma/talk2scholars/tools/zotero/utils/review_helper.py +74 -0
- aiagents4pharma/talk2scholars/tools/zotero/utils/write_helper.py +194 -0
- aiagents4pharma/talk2scholars/tools/zotero/utils/zotero_path.py +180 -0
- aiagents4pharma/talk2scholars/tools/zotero/utils/zotero_pdf_downloader.py +133 -0
- aiagents4pharma/talk2scholars/tools/zotero/zotero_read.py +105 -0
- aiagents4pharma/talk2scholars/tools/zotero/zotero_review.py +162 -0
- aiagents4pharma/talk2scholars/tools/zotero/zotero_write.py +91 -0
- aiagents4pharma-0.0.0.dist-info/METADATA +335 -0
- aiagents4pharma-0.0.0.dist-info/RECORD +336 -0
- aiagents4pharma-0.0.0.dist-info/WHEEL +4 -0
- aiagents4pharma-0.0.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Test cases for utils/embeddings/embeddings.py
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import pytest
|
|
6
|
+
|
|
7
|
+
from ..utils.embeddings.embeddings import Embeddings
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class TestEmbeddings(Embeddings):
|
|
11
|
+
"""Test implementation of the Embeddings interface for testing purposes."""
|
|
12
|
+
|
|
13
|
+
def embed_documents(self, texts: list[str]) -> list[list[float]]:
|
|
14
|
+
return [[0.1, 0.2, 0.3] for _ in texts]
|
|
15
|
+
|
|
16
|
+
def embed_query(self, text: str) -> list[float]:
|
|
17
|
+
return [0.1, 0.2, 0.3]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_embed_documents():
|
|
21
|
+
"""Test embedding documents using the Embeddings interface."""
|
|
22
|
+
embeddings = TestEmbeddings()
|
|
23
|
+
texts = ["text1", "text2"]
|
|
24
|
+
result = embeddings.embed_documents(texts)
|
|
25
|
+
assert result == [[0.1, 0.2, 0.3], [0.1, 0.2, 0.3]]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def test_embed_query():
|
|
29
|
+
"""Test embedding a query using the Embeddings interface."""
|
|
30
|
+
embeddings = TestEmbeddings()
|
|
31
|
+
text = "query"
|
|
32
|
+
result = embeddings.embed_query(text)
|
|
33
|
+
assert result == [0.1, 0.2, 0.3]
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@pytest.mark.asyncio
|
|
37
|
+
async def test_aembed_documents():
|
|
38
|
+
"""Test asynchronous embedding of documents using the Embeddings interface."""
|
|
39
|
+
embeddings = TestEmbeddings()
|
|
40
|
+
texts = ["text1", "text2"]
|
|
41
|
+
result = await embeddings.aembed_documents(texts)
|
|
42
|
+
assert result == [[0.1, 0.2, 0.3], [0.1, 0.2, 0.3]]
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@pytest.mark.asyncio
|
|
46
|
+
async def test_aembed_query():
|
|
47
|
+
"""Test asynchronous embedding of a query using the Embeddings interface."""
|
|
48
|
+
embeddings = TestEmbeddings()
|
|
49
|
+
text = "query"
|
|
50
|
+
result = await embeddings.aembed_query(text)
|
|
51
|
+
assert result == [0.1, 0.2, 0.3]
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Test cases for utils/embeddings/huggingface.py
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import pytest
|
|
6
|
+
|
|
7
|
+
from ..utils.embeddings.huggingface import EmbeddingWithHuggingFace
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@pytest.fixture(name="embedding_model")
|
|
11
|
+
def embedding_model_fixture():
|
|
12
|
+
"""Return the configuration object for the HuggingFace embedding model and model object"""
|
|
13
|
+
return EmbeddingWithHuggingFace(
|
|
14
|
+
model_name="NeuML/pubmedbert-base-embeddings",
|
|
15
|
+
model_cache_dir="../../cache",
|
|
16
|
+
truncation=True,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_embedding_with_huggingface_embed_documents(embedding_model):
|
|
21
|
+
"""Test embedding documents using the EmbeddingWithHuggingFace class."""
|
|
22
|
+
# Perform embedding
|
|
23
|
+
texts = ["Adalimumab", "Infliximab", "Vedolizumab"]
|
|
24
|
+
result = embedding_model.embed_documents(texts)
|
|
25
|
+
# Check the result
|
|
26
|
+
assert len(result) == 3
|
|
27
|
+
assert len(result[0]) == 768
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_embedding_with_huggingface_embed_query(embedding_model):
|
|
31
|
+
"""Test embedding a query using the EmbeddingWithHuggingFace class."""
|
|
32
|
+
# Perform embedding
|
|
33
|
+
text = "Adalimumab"
|
|
34
|
+
result = embedding_model.embed_query(text)
|
|
35
|
+
# Check the result
|
|
36
|
+
assert len(result) == 768
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def test_embedding_with_huggingface_failed():
|
|
40
|
+
"""Test embedding documents using the EmbeddingWithHuggingFace class."""
|
|
41
|
+
# Check if the model is available on HuggingFace Hub
|
|
42
|
+
model_name = "aiagents4pharma/embeddings"
|
|
43
|
+
err_msg = f"Model {model_name} is not available on HuggingFace Hub."
|
|
44
|
+
with pytest.raises(ValueError, match=err_msg):
|
|
45
|
+
EmbeddingWithHuggingFace(
|
|
46
|
+
model_name=model_name,
|
|
47
|
+
model_cache_dir="../../cache",
|
|
48
|
+
truncation=True,
|
|
49
|
+
)
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Test cases for utils/embeddings/nim_molmim.py
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import unittest
|
|
8
|
+
from unittest.mock import MagicMock, patch
|
|
9
|
+
|
|
10
|
+
from ..utils.embeddings.nim_molmim import EmbeddingWithMOLMIM
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class TestEmbeddingWithMOLMIM(unittest.TestCase):
|
|
14
|
+
"""
|
|
15
|
+
Test cases for EmbeddingWithMOLMIM class.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def setUp(self):
|
|
19
|
+
self.base_url = "https://fake-nim-api.com/embeddings"
|
|
20
|
+
self.embeddings_model = EmbeddingWithMOLMIM(self.base_url)
|
|
21
|
+
self.test_texts = ["CCO", "CCC", "C=O"]
|
|
22
|
+
self.test_query = "CCO"
|
|
23
|
+
self.mock_response = {"embeddings": [[0.1, 0.2, 0.3], [0.4, 0.5, 0.6], [0.7, 0.8, 0.9]]}
|
|
24
|
+
|
|
25
|
+
@patch("requests.post")
|
|
26
|
+
def test_embed_documents(self, mock_post):
|
|
27
|
+
"""
|
|
28
|
+
Test the embed_documents method.
|
|
29
|
+
"""
|
|
30
|
+
# Mock the response from requests.post
|
|
31
|
+
mock_post.return_value = MagicMock()
|
|
32
|
+
mock_post.return_value.json.return_value = self.mock_response
|
|
33
|
+
embeddings = self.embeddings_model.embed_documents(self.test_texts)
|
|
34
|
+
# Assertions
|
|
35
|
+
self.assertEqual(embeddings, self.mock_response["embeddings"])
|
|
36
|
+
mock_post.assert_called_once_with(
|
|
37
|
+
self.base_url,
|
|
38
|
+
headers={"accept": "application/json", "Content-Type": "application/json"},
|
|
39
|
+
data='{"sequences": ["CCO", "CCC", "C=O"]}',
|
|
40
|
+
timeout=60,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
@patch("requests.post")
|
|
44
|
+
def test_embed_query(self, mock_post):
|
|
45
|
+
"""
|
|
46
|
+
Test the embed_query method.
|
|
47
|
+
"""
|
|
48
|
+
# Mock the response from requests.post
|
|
49
|
+
mock_post.return_value = MagicMock()
|
|
50
|
+
mock_post.return_value.json.return_value = {"embeddings": [[0.1, 0.2, 0.3]]}
|
|
51
|
+
embedding = self.embeddings_model.embed_query(self.test_query)
|
|
52
|
+
# Assertions
|
|
53
|
+
self.assertEqual(embedding, [[0.1, 0.2, 0.3]])
|
|
54
|
+
mock_post.assert_called_once_with(
|
|
55
|
+
self.base_url,
|
|
56
|
+
headers={"accept": "application/json", "Content-Type": "application/json"},
|
|
57
|
+
data='{"sequences": ["CCO"]}',
|
|
58
|
+
timeout=60,
|
|
59
|
+
)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Test cases for utils/embeddings/ollama.py
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import ollama
|
|
6
|
+
import pytest
|
|
7
|
+
|
|
8
|
+
from ..utils.embeddings.ollama import EmbeddingWithOllama
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@pytest.fixture(name="ollama_config")
|
|
12
|
+
def fixture_ollama_config():
|
|
13
|
+
"""Return a dictionary with Ollama configuration."""
|
|
14
|
+
return {
|
|
15
|
+
"model_name": "all-minilm", # Choose a small model
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def test_no_model_ollama(ollama_config):
|
|
20
|
+
"""Test the case when the Ollama model is not available."""
|
|
21
|
+
cfg = ollama_config
|
|
22
|
+
|
|
23
|
+
# Delete the Ollama model
|
|
24
|
+
try:
|
|
25
|
+
ollama.delete(cfg["model_name"])
|
|
26
|
+
except ollama.ResponseError:
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
# Check if the model is available
|
|
30
|
+
with pytest.raises(
|
|
31
|
+
ValueError,
|
|
32
|
+
match=f"Error: Pulled {cfg['model_name']} model and restarted Ollama server.",
|
|
33
|
+
):
|
|
34
|
+
EmbeddingWithOllama(model_name=cfg["model_name"])
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@pytest.fixture(name="embedding_model")
|
|
38
|
+
def embedding_model_fixture(ollama_config):
|
|
39
|
+
"""Return the configuration object for the Ollama embedding model and model object"""
|
|
40
|
+
cfg = ollama_config
|
|
41
|
+
return EmbeddingWithOllama(model_name=cfg["model_name"])
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def test_embedding_with_ollama_embed_documents(embedding_model):
|
|
45
|
+
"""Test embedding documents using the EmbeddingWithOllama class."""
|
|
46
|
+
# Perform embedding
|
|
47
|
+
texts = ["Adalimumab", "Infliximab", "Vedolizumab"]
|
|
48
|
+
result = embedding_model.embed_documents(texts)
|
|
49
|
+
# Check the result
|
|
50
|
+
assert len(result) == 3
|
|
51
|
+
assert len(result[0]) == 384
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def test_embedding_with_ollama_embed_query(embedding_model):
|
|
55
|
+
"""Test embedding a query using the EmbeddingWithOllama class."""
|
|
56
|
+
# Perform embedding
|
|
57
|
+
text = "Adalimumab"
|
|
58
|
+
result = embedding_model.embed_query(text)
|
|
59
|
+
# Check the result
|
|
60
|
+
assert len(result) == 384
|
|
61
|
+
|
|
62
|
+
# Delete the Ollama model so that it will not be cached afterward
|
|
63
|
+
ollama.delete(embedding_model.model_name)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Test cases for utils/embeddings/sentence_transformer.py
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import numpy as np
|
|
6
|
+
import pytest
|
|
7
|
+
|
|
8
|
+
from ..utils.embeddings.sentence_transformer import EmbeddingWithSentenceTransformer
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@pytest.fixture(name="embedding_model")
|
|
12
|
+
def embedding_model_fixture():
|
|
13
|
+
"""
|
|
14
|
+
Fixture for creating an instance of EmbeddingWithSentenceTransformer.
|
|
15
|
+
"""
|
|
16
|
+
model_name = "sentence-transformers/all-MiniLM-L6-v1" # Small model for testing
|
|
17
|
+
embedding_model = EmbeddingWithSentenceTransformer(model_name=model_name)
|
|
18
|
+
# Move underlying model to CPU for testing
|
|
19
|
+
embedding_model.model.to("cpu")
|
|
20
|
+
return embedding_model
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_embed_documents(embedding_model):
|
|
24
|
+
"""
|
|
25
|
+
Test the embed_documents method of EmbeddingWithSentenceTransformer class.
|
|
26
|
+
"""
|
|
27
|
+
# Perform embedding
|
|
28
|
+
texts = ["This is a test sentence.", "Another test sentence."]
|
|
29
|
+
embeddings = embedding_model.embed_documents(texts)
|
|
30
|
+
# Check the result
|
|
31
|
+
assert len(embeddings) == len(texts)
|
|
32
|
+
assert len(embeddings[0]) > 0
|
|
33
|
+
assert len(embeddings[0]) == 384
|
|
34
|
+
assert embeddings.dtype == np.float32
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def test_embed_query(embedding_model):
|
|
38
|
+
"""
|
|
39
|
+
Test the embed_query method of EmbeddingWithSentenceTransformer class.
|
|
40
|
+
"""
|
|
41
|
+
# Perform embedding
|
|
42
|
+
text = "This is a test query."
|
|
43
|
+
embedding = embedding_model.embed_query(text)
|
|
44
|
+
# Check the result
|
|
45
|
+
assert len(embedding) > 0
|
|
46
|
+
assert len(embedding) == 384
|
|
47
|
+
assert embedding.dtype == np.float32
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Test cases for utils/enrichments/enrichments.py
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from ..utils.enrichments.enrichments import Enrichments
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class TestEnrichments(Enrichments):
|
|
9
|
+
"""Test implementation of the Enrichments interface for testing purposes."""
|
|
10
|
+
|
|
11
|
+
def enrich_documents(self, texts: list[str]) -> list[list[float]]:
|
|
12
|
+
return [f"Additional text description of {text} as the input." for text in texts]
|
|
13
|
+
|
|
14
|
+
def enrich_documents_with_rag(self, texts, docs):
|
|
15
|
+
# Currently we don't have a RAG model to test this method.
|
|
16
|
+
# Thus, we will just call the enrich_documents method instead.
|
|
17
|
+
return self.enrich_documents(texts)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_enrich_documents():
|
|
21
|
+
"""Test enriching documents using the Enrichments interface."""
|
|
22
|
+
enrichments = TestEnrichments()
|
|
23
|
+
texts = ["text1", "text2"]
|
|
24
|
+
result = enrichments.enrich_documents(texts)
|
|
25
|
+
assert result == [
|
|
26
|
+
"Additional text description of text1 as the input.",
|
|
27
|
+
"Additional text description of text2 as the input.",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def test_enrich_documents_with_rag():
|
|
32
|
+
"""Test enriching documents with RAG using the Enrichments interface."""
|
|
33
|
+
enrichments = TestEnrichments()
|
|
34
|
+
texts = ["text1", "text2"]
|
|
35
|
+
docs = ["doc1", "doc2"]
|
|
36
|
+
result = enrichments.enrich_documents_with_rag(texts, docs)
|
|
37
|
+
assert result == [
|
|
38
|
+
"Additional text description of text1 as the input.",
|
|
39
|
+
"Additional text description of text2 as the input.",
|
|
40
|
+
]
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Test cases for utils/enrichments/ollama.py
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import ollama
|
|
6
|
+
import pytest
|
|
7
|
+
|
|
8
|
+
from ..utils.enrichments.ollama import EnrichmentWithOllama
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@pytest.fixture(name="ollama_config")
|
|
12
|
+
def fixture_ollama_config():
|
|
13
|
+
"""Return a dictionary with Ollama configuration."""
|
|
14
|
+
return {
|
|
15
|
+
"model_name": "llama3.2:1b",
|
|
16
|
+
"prompt_enrichment": """
|
|
17
|
+
Given the input as a list of strings, please return the list of addditional information
|
|
18
|
+
of each input terms using your prior knowledge.
|
|
19
|
+
|
|
20
|
+
Example:
|
|
21
|
+
Input: ['acetaminophen', 'aspirin']
|
|
22
|
+
Ouput: ['acetaminophen is a medication used to treat pain and fever',
|
|
23
|
+
'aspirin is a medication used to treat pain, fever, and inflammation']
|
|
24
|
+
|
|
25
|
+
Do not include any pretext as the output, only the list of strings enriched.
|
|
26
|
+
|
|
27
|
+
Input: {input}
|
|
28
|
+
""",
|
|
29
|
+
"temperature": 0.0,
|
|
30
|
+
"streaming": False,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_no_model_ollama(ollama_config):
|
|
35
|
+
"""Test the case when the Ollama model is not available."""
|
|
36
|
+
cfg = ollama_config
|
|
37
|
+
cfg_model = "smollm2:135m" # Choose a small model
|
|
38
|
+
|
|
39
|
+
# Delete the Ollama model
|
|
40
|
+
try:
|
|
41
|
+
ollama.delete(cfg_model)
|
|
42
|
+
except ollama.ResponseError:
|
|
43
|
+
pass
|
|
44
|
+
|
|
45
|
+
# Check if the model is available
|
|
46
|
+
with pytest.raises(
|
|
47
|
+
ValueError,
|
|
48
|
+
match=f"Error: Pulled {cfg_model} model and restarted Ollama server.",
|
|
49
|
+
):
|
|
50
|
+
EnrichmentWithOllama(
|
|
51
|
+
model_name=cfg_model,
|
|
52
|
+
prompt_enrichment=cfg["prompt_enrichment"],
|
|
53
|
+
temperature=cfg["temperature"],
|
|
54
|
+
streaming=cfg["streaming"],
|
|
55
|
+
)
|
|
56
|
+
ollama.delete(cfg_model)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def test_enrich_ollama(ollama_config):
|
|
60
|
+
"""Test the Ollama textual enrichment class for node enrichment."""
|
|
61
|
+
# Prepare enrichment model
|
|
62
|
+
cfg = ollama_config
|
|
63
|
+
enr_model = EnrichmentWithOllama(
|
|
64
|
+
model_name=cfg["model_name"],
|
|
65
|
+
prompt_enrichment=cfg["prompt_enrichment"],
|
|
66
|
+
temperature=cfg["temperature"],
|
|
67
|
+
streaming=cfg["streaming"],
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
# Perform enrichment for nodes
|
|
71
|
+
nodes = ["acetaminophen"]
|
|
72
|
+
enriched_nodes = enr_model.enrich_documents(nodes)
|
|
73
|
+
# Check the enriched nodes
|
|
74
|
+
assert len(enriched_nodes) == 1
|
|
75
|
+
assert all(enriched_nodes[i] != nodes[i] for i in range(len(nodes)))
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def test_enrich_ollama_rag(ollama_config):
|
|
79
|
+
"""Test the Ollama textual enrichment class for enrichment with RAG (not implemented)."""
|
|
80
|
+
# Prepare enrichment model
|
|
81
|
+
cfg = ollama_config
|
|
82
|
+
enr_model = EnrichmentWithOllama(
|
|
83
|
+
model_name=cfg["model_name"],
|
|
84
|
+
prompt_enrichment=cfg["prompt_enrichment"],
|
|
85
|
+
temperature=cfg["temperature"],
|
|
86
|
+
streaming=cfg["streaming"],
|
|
87
|
+
)
|
|
88
|
+
# Perform enrichment for nodes
|
|
89
|
+
nodes = ["acetaminophen"]
|
|
90
|
+
docs = [r"\path\to\doc1", r"\path\to\doc2"]
|
|
91
|
+
enriched_nodes = enr_model.enrich_documents_with_rag(nodes, docs)
|
|
92
|
+
# Check the enriched nodes
|
|
93
|
+
assert len(enriched_nodes) == 1
|
|
94
|
+
assert all(enriched_nodes[i] != nodes[i] for i in range(len(nodes)))
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Test cases for utils/enrichments/ols_terms.py
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import pytest
|
|
8
|
+
|
|
9
|
+
from ..utils.enrichments.ols_terms import EnrichmentWithOLS
|
|
10
|
+
|
|
11
|
+
# In this test, we will consider 5 examples:
|
|
12
|
+
# 1. CL_0000899: T-helper 17 cell (Cell Ontology)
|
|
13
|
+
# 2. GO_0046427: positive regulation of receptor signaling pathway via JAK-STAT (GO)
|
|
14
|
+
# 3. UBERON_0000004: nose (Uberon)
|
|
15
|
+
# 4. HP_0009739: Hypoplasia of the antihelix (Human Phenotype Ontology)
|
|
16
|
+
# 5. MONDO_0005011: Crohn disease (MONDO)
|
|
17
|
+
# 6. XYZ_0000000: Non-existing term (for testing error handling)
|
|
18
|
+
|
|
19
|
+
# The expected description for each term starts with:
|
|
20
|
+
CL_DESC = "CD4-positive, alpha-beta T cell"
|
|
21
|
+
GO_DESC = "Any process that activates or increases the frequency, rate or extent"
|
|
22
|
+
UBERON_DESC = "The olfactory organ of vertebrates, consisting of nares"
|
|
23
|
+
HP_DESC = "Developmental hypoplasia of the antihelix"
|
|
24
|
+
MONDO_DESC = "A gastrointestinal disorder characterized by chronic inflammation"
|
|
25
|
+
|
|
26
|
+
# The expected description for the non-existing term is None
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@pytest.fixture(name="enrich_obj")
|
|
30
|
+
def fixture_uniprot_config():
|
|
31
|
+
"""Return a dictionary with the configuration for OLS enrichment."""
|
|
32
|
+
return EnrichmentWithOLS()
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_enrich_documents(enrich_obj):
|
|
36
|
+
"""Test the enrich_documents method."""
|
|
37
|
+
ols_terms = [
|
|
38
|
+
"CL_0000899",
|
|
39
|
+
"GO_0046427",
|
|
40
|
+
"UBERON_0000004",
|
|
41
|
+
"HP_0009739",
|
|
42
|
+
"MONDO_0005011",
|
|
43
|
+
"XYZ_0000000",
|
|
44
|
+
]
|
|
45
|
+
descriptions = enrich_obj.enrich_documents(ols_terms)
|
|
46
|
+
assert CL_DESC in descriptions[0]
|
|
47
|
+
assert GO_DESC in descriptions[1]
|
|
48
|
+
assert UBERON_DESC in descriptions[2]
|
|
49
|
+
assert HP_DESC in descriptions[3]
|
|
50
|
+
assert MONDO_DESC in descriptions[4]
|
|
51
|
+
assert descriptions[5] == ""
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def test_enrich_documents_with_rag(enrich_obj):
|
|
55
|
+
"""Test the enrich_documents_with_rag method."""
|
|
56
|
+
ols_terms = [
|
|
57
|
+
"CL_0000899",
|
|
58
|
+
"GO_0046427",
|
|
59
|
+
"UBERON_0000004",
|
|
60
|
+
"HP_0009739",
|
|
61
|
+
"MONDO_0005011",
|
|
62
|
+
"XYZ_0000000",
|
|
63
|
+
]
|
|
64
|
+
descriptions = enrich_obj.enrich_documents_with_rag(ols_terms, None)
|
|
65
|
+
assert CL_DESC in descriptions[0]
|
|
66
|
+
assert GO_DESC in descriptions[1]
|
|
67
|
+
assert UBERON_DESC in descriptions[2]
|
|
68
|
+
assert HP_DESC in descriptions[3]
|
|
69
|
+
assert MONDO_DESC in descriptions[4]
|
|
70
|
+
assert descriptions[5] == ""
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Test cases for utils/enrichments/pubchem_strings.py
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import pytest
|
|
8
|
+
|
|
9
|
+
from ..utils.enrichments.pubchem_strings import EnrichmentWithPubChem
|
|
10
|
+
|
|
11
|
+
# In this test, we will consider 2 examples:
|
|
12
|
+
# 1. PubChem ID: 5311000 (Alclometasone)
|
|
13
|
+
# 2. PubChem ID: 1X (Fake ID)
|
|
14
|
+
# The expected SMILES representation for the first PubChem ID is:
|
|
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"
|
|
17
|
+
# The expected description for the first PubChem ID starts with:
|
|
18
|
+
DESCRIPTION_FIRST = "Alclometasone is a prednisolone compound having an alpha-chloro substituent"
|
|
19
|
+
# The expected SMILES representation and description for the second PubChem ID is None.
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@pytest.fixture(name="enrich_obj")
|
|
23
|
+
def fixture_pubchem_config():
|
|
24
|
+
"""Return a dictionary with the configuration for the PubChem enrichment."""
|
|
25
|
+
return EnrichmentWithPubChem()
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def test_enrich_documents(enrich_obj):
|
|
29
|
+
"""Test the enrich_documents method."""
|
|
30
|
+
pubchem_ids = ["5311000", "1X"]
|
|
31
|
+
enriched_descriptions, enriched_strings = enrich_obj.enrich_documents(pubchem_ids)
|
|
32
|
+
assert enriched_strings == [SMILES_FIRST, None]
|
|
33
|
+
assert enriched_descriptions[0].startswith(DESCRIPTION_FIRST)
|
|
34
|
+
assert enriched_descriptions[1] is None
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def test_enrich_documents_with_rag(enrich_obj):
|
|
38
|
+
"""Test the enrich_documents_with_rag method."""
|
|
39
|
+
pubchem_ids = ["5311000", "1X"]
|
|
40
|
+
enriched_descriptions, enriched_strings = enrich_obj.enrich_documents_with_rag(
|
|
41
|
+
pubchem_ids, None
|
|
42
|
+
)
|
|
43
|
+
assert enriched_strings == [SMILES_FIRST, None]
|
|
44
|
+
assert enriched_descriptions[0].startswith(DESCRIPTION_FIRST)
|
|
45
|
+
assert enriched_descriptions[1] is None
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Test cases for utils/enrichments/reactome_pathways.py
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import pytest
|
|
8
|
+
|
|
9
|
+
from ..utils.enrichments.reactome_pathways import EnrichmentWithReactome
|
|
10
|
+
|
|
11
|
+
# In this test, we will consider 2 examples:
|
|
12
|
+
# 1. R-HSA-3244647: cGAS binds cytosolic DNA
|
|
13
|
+
# 2. R-HSA-9905952: ATP binds P2RX7 in P2RX7 trimer:PANX1 heptamer
|
|
14
|
+
# 3. R-HSA-1234567: Fake pathway
|
|
15
|
+
|
|
16
|
+
# The expected description of pathway R-HSA-3244647 startswith:
|
|
17
|
+
FIRST_PATHWAY = "Cyclic GMP-AMP (cGAMP) synthase (cGAS) was identified as a cytosolic DNA"
|
|
18
|
+
# The expected description of pathway R-HSA-9905952 startswith:
|
|
19
|
+
SECOND_PATHWAY = "The P2RX7 (P2X7, P2Z) trimer binds ATP,"
|
|
20
|
+
# The expected description of pathway R-HSA-1234567 is None.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@pytest.fixture(name="enrich_obj")
|
|
24
|
+
def fixture_uniprot_config():
|
|
25
|
+
"""Return a dictionary with the configuration for Reactome enrichment."""
|
|
26
|
+
return EnrichmentWithReactome()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def test_enrich_documents(enrich_obj):
|
|
30
|
+
"""Test the enrich_documents method."""
|
|
31
|
+
reactome_pathways = ["R-HSA-3244647", "R-HSA-9905952", "R-HSA-1234567"]
|
|
32
|
+
descriptions = enrich_obj.enrich_documents(reactome_pathways)
|
|
33
|
+
assert descriptions[0].startswith(FIRST_PATHWAY)
|
|
34
|
+
assert descriptions[1].startswith(SECOND_PATHWAY)
|
|
35
|
+
assert descriptions[2] is None
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def test_enrich_documents_with_rag(enrich_obj):
|
|
39
|
+
"""Test the enrich_documents_with_rag method."""
|
|
40
|
+
reactome_pathways = ["R-HSA-3244647", "R-HSA-9905952", "R-HSA-1234567"]
|
|
41
|
+
descriptions = enrich_obj.enrich_documents_with_rag(reactome_pathways, None)
|
|
42
|
+
assert descriptions[0].startswith(FIRST_PATHWAY)
|
|
43
|
+
assert descriptions[1].startswith(SECOND_PATHWAY)
|
|
44
|
+
assert descriptions[2] is None
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Test cases for utils/enrichments/uniprot_proteins.py
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import pytest
|
|
8
|
+
|
|
9
|
+
from ..utils.enrichments.uniprot_proteins import EnrichmentWithUniProt
|
|
10
|
+
|
|
11
|
+
# In this test, we will consider 2 examples:
|
|
12
|
+
# 1. Gene Name: TP53
|
|
13
|
+
# 2. Gene Name: TP5 (Incomplete; must return empty results)
|
|
14
|
+
# 2. Gene Name: XZ (Shorter than 3 characters; must return empty results)
|
|
15
|
+
# The expected description of TP53 startswith:
|
|
16
|
+
START_DESCP = "Multifunctional transcription factor"
|
|
17
|
+
# The expected amino acid sequence of TP53 startswith:
|
|
18
|
+
START_SEQ = "MEEPQSDPSV"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@pytest.fixture(name="enrich_obj")
|
|
22
|
+
def fixture_uniprot_config():
|
|
23
|
+
"""Return a dictionary with the configuration for UniProt enrichment."""
|
|
24
|
+
return EnrichmentWithUniProt()
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def test_enrich_documents(enrich_obj):
|
|
28
|
+
"""Test the enrich_documents method."""
|
|
29
|
+
gene_names = ["TP53", "TP5", "XZ"]
|
|
30
|
+
descriptions, sequences = enrich_obj.enrich_documents(gene_names)
|
|
31
|
+
assert descriptions[0].startswith(START_DESCP)
|
|
32
|
+
assert sequences[0].startswith(START_SEQ)
|
|
33
|
+
assert descriptions[1] is None
|
|
34
|
+
assert sequences[1] is None
|
|
35
|
+
assert descriptions[2] is None
|
|
36
|
+
assert sequences[2] is None
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def test_enrich_documents_with_rag(enrich_obj):
|
|
40
|
+
"""Test the enrich_documents_with_rag method."""
|
|
41
|
+
gene_names = ["TP53", "TP5", "XZ"]
|
|
42
|
+
descriptions, sequences = enrich_obj.enrich_documents_with_rag(gene_names, None)
|
|
43
|
+
assert descriptions[0].startswith(START_DESCP)
|
|
44
|
+
assert sequences[0].startswith(START_SEQ)
|
|
45
|
+
assert descriptions[1] is None
|
|
46
|
+
assert sequences[1] is None
|
|
47
|
+
assert descriptions[2] is None
|
|
48
|
+
assert sequences[2] is None
|