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,134 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
A utility module for defining the dataclasses
|
|
5
|
+
for the arguments to set up initial settings
|
|
6
|
+
before the experiment is run.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import logging
|
|
10
|
+
from dataclasses import dataclass
|
|
11
|
+
from typing import Annotated
|
|
12
|
+
|
|
13
|
+
import basico
|
|
14
|
+
from pydantic import Field
|
|
15
|
+
|
|
16
|
+
# Initialize logger
|
|
17
|
+
logging.basicConfig(level=logging.INFO)
|
|
18
|
+
logger = logging.getLogger(__name__)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@dataclass
|
|
22
|
+
class TimeData:
|
|
23
|
+
"""
|
|
24
|
+
Dataclass for storing the time data.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
duration: int | float = Field(description="Duration of the simulation", default=100)
|
|
28
|
+
interval: int | float = Field(
|
|
29
|
+
description="The interval is the time step or"
|
|
30
|
+
" the step size of the simulation. It is unrelated"
|
|
31
|
+
" to the step size of species concentration and parameter values.",
|
|
32
|
+
default=100,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@dataclass
|
|
37
|
+
class SpeciesInitialData:
|
|
38
|
+
"""
|
|
39
|
+
Dataclass for storing the species initial data.
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
species_name: list[str] = Field(
|
|
43
|
+
description="List of species whose initial concentration is to be set."
|
|
44
|
+
" This does not include species that reoccur or the species whose"
|
|
45
|
+
" concentration is to be determined/observed at the end of the experiment."
|
|
46
|
+
" Do not hallucinate the species name.",
|
|
47
|
+
default=[],
|
|
48
|
+
)
|
|
49
|
+
species_concentration: list[int | float] = Field(
|
|
50
|
+
description="List of initial concentrations of species."
|
|
51
|
+
" This does not include species that reoccur or the species whose"
|
|
52
|
+
" concentration is to be determined/observed at the end of the experiment."
|
|
53
|
+
" Do not hallucinate the species concentration.",
|
|
54
|
+
default=[],
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@dataclass
|
|
59
|
+
class TimeSpeciesNameConcentration:
|
|
60
|
+
"""
|
|
61
|
+
Dataclass for storing the time,
|
|
62
|
+
species name, and concentration data.
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
time: int | float = Field(description="time point where the event occurs")
|
|
66
|
+
species_name: str = Field(description="species name")
|
|
67
|
+
species_concentration: int | float = Field(
|
|
68
|
+
description="species concentration at the time point"
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
@dataclass
|
|
73
|
+
class ReocurringData:
|
|
74
|
+
"""
|
|
75
|
+
Dataclass for species that reoccur. In other words,
|
|
76
|
+
the concentration of the species resets to a certain
|
|
77
|
+
value after a certain time interval.
|
|
78
|
+
"""
|
|
79
|
+
|
|
80
|
+
data: list[TimeSpeciesNameConcentration] = Field(
|
|
81
|
+
description="List of time, name, and concentration data"
|
|
82
|
+
" of species or parameters that reoccur",
|
|
83
|
+
default=[],
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@dataclass
|
|
88
|
+
class ArgumentData:
|
|
89
|
+
"""
|
|
90
|
+
Dataclass for storing the argument data.
|
|
91
|
+
"""
|
|
92
|
+
|
|
93
|
+
experiment_name: Annotated[
|
|
94
|
+
str,
|
|
95
|
+
"An AI assigned _ separated name of"
|
|
96
|
+
" the experiment based on human query"
|
|
97
|
+
" and the context of the experiment."
|
|
98
|
+
" This must be set before the experiment is run.",
|
|
99
|
+
]
|
|
100
|
+
time_data: TimeData | None = Field(description="time data", default=None)
|
|
101
|
+
species_to_be_analyzed_before_experiment: SpeciesInitialData | None = Field(
|
|
102
|
+
description="Data of species whose initial concentration"
|
|
103
|
+
" is to be set before the experiment. This does not include"
|
|
104
|
+
" species that reoccur or the species whose concentration"
|
|
105
|
+
" is to be determined at the end of the experiment.",
|
|
106
|
+
default=None,
|
|
107
|
+
)
|
|
108
|
+
reocurring_data: ReocurringData | None = Field(
|
|
109
|
+
description="List of concentration and time data of species that"
|
|
110
|
+
" reoccur. For example, a species whose concentration resets"
|
|
111
|
+
" to a certain value after a certain time interval.",
|
|
112
|
+
default=None,
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def add_rec_events(model_object, reocurring_data):
|
|
117
|
+
"""
|
|
118
|
+
Add reocurring events to the model.
|
|
119
|
+
|
|
120
|
+
Args:
|
|
121
|
+
model_object: The model object.
|
|
122
|
+
reocurring_data: The reocurring data.
|
|
123
|
+
|
|
124
|
+
Returns:
|
|
125
|
+
None
|
|
126
|
+
"""
|
|
127
|
+
for row in reocurring_data.data:
|
|
128
|
+
tp, sn, sc = row.time, row.species_name, row.species_concentration
|
|
129
|
+
basico.add_event(
|
|
130
|
+
f"{sn}_{tp}",
|
|
131
|
+
f"Time > {tp}",
|
|
132
|
+
[[sn, str(sc)]],
|
|
133
|
+
model=model_object.copasi_model,
|
|
134
|
+
)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Function for loading the BioModel.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import Annotated, Any
|
|
8
|
+
|
|
9
|
+
from pydantic import BaseModel, BeforeValidator
|
|
10
|
+
|
|
11
|
+
from ..models.basico_model import BasicoModel
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def ensure_biomodel_id(value: Any) -> Any:
|
|
15
|
+
"""
|
|
16
|
+
Ensure that the biomodel_id is an integer or a string starting with 'BIOMD' or 'MODEL'.
|
|
17
|
+
"""
|
|
18
|
+
if isinstance(value, int):
|
|
19
|
+
return value
|
|
20
|
+
if isinstance(value, str) and (value.startswith("BIOMD") or value.startswith("MODEL")):
|
|
21
|
+
return value
|
|
22
|
+
raise ValueError("biomodel_id must be an integer or a string starting with 'BIOMD' or 'MODEL'.")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class ModelData(BaseModel):
|
|
26
|
+
"""
|
|
27
|
+
Base model for the model data.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
biomodel_id: Annotated[int | str, BeforeValidator(ensure_biomodel_id)] = None
|
|
31
|
+
# sbml_file_path: Optional[str] = None
|
|
32
|
+
use_uploaded_sbml_file: bool = False
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def load_biomodel(sys_bio_model, sbml_file_path=None):
|
|
36
|
+
"""
|
|
37
|
+
Load the BioModel.
|
|
38
|
+
"""
|
|
39
|
+
model_object = None
|
|
40
|
+
if sys_bio_model.biomodel_id:
|
|
41
|
+
model_object = BasicoModel(biomodel_id=sys_bio_model.biomodel_id)
|
|
42
|
+
elif sbml_file_path:
|
|
43
|
+
model_object = BasicoModel(sbml_file_path=sbml_file_path)
|
|
44
|
+
return model_object
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Tool for parameter scan.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import logging
|
|
8
|
+
from dataclasses import dataclass
|
|
9
|
+
from typing import Annotated
|
|
10
|
+
|
|
11
|
+
import basico
|
|
12
|
+
import pandas as pd
|
|
13
|
+
from langchain_core.messages import ToolMessage
|
|
14
|
+
from langchain_core.tools import BaseTool
|
|
15
|
+
from langchain_core.tools.base import InjectedToolCallId
|
|
16
|
+
from langgraph.prebuilt import InjectedState
|
|
17
|
+
from langgraph.types import Command
|
|
18
|
+
from pydantic import BaseModel, Field
|
|
19
|
+
|
|
20
|
+
from .load_arguments import SpeciesInitialData, TimeData
|
|
21
|
+
from .load_biomodel import ModelData, load_biomodel
|
|
22
|
+
from .utils import get_model_units
|
|
23
|
+
|
|
24
|
+
# Initialize logger
|
|
25
|
+
logging.basicConfig(level=logging.INFO)
|
|
26
|
+
logger = logging.getLogger(__name__)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@dataclass
|
|
30
|
+
class ParameterScanData(BaseModel):
|
|
31
|
+
"""
|
|
32
|
+
Dataclass for storing the parameter scan data.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
species_names: list[str] = Field(
|
|
36
|
+
description="species to be observed after each scan."
|
|
37
|
+
" These are the species whose concentration"
|
|
38
|
+
" will be observed after the parameter scan."
|
|
39
|
+
" Do not make up this data.",
|
|
40
|
+
default=[],
|
|
41
|
+
)
|
|
42
|
+
species_parameter_name: str = Field(
|
|
43
|
+
description="Species or parameter name to be scanned."
|
|
44
|
+
" This is the species or parameter whose value will be scanned"
|
|
45
|
+
" over a range of values. This does not include the species"
|
|
46
|
+
" that are to be observed after the scan."
|
|
47
|
+
"Do not make up this data.",
|
|
48
|
+
default=None,
|
|
49
|
+
)
|
|
50
|
+
species_parameter_values: list[int | float] = Field(
|
|
51
|
+
description="Species or parameter values to be scanned."
|
|
52
|
+
" These are the values of the species or parameters that will be"
|
|
53
|
+
" scanned over a range of values. This does not include the "
|
|
54
|
+
"species that are to be observed after the scan."
|
|
55
|
+
"Do not make up this data.",
|
|
56
|
+
default=None,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@dataclass
|
|
61
|
+
class ArgumentData:
|
|
62
|
+
"""
|
|
63
|
+
Dataclass for storing the argument data.
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
time_data: TimeData = Field(description="time data", default=None)
|
|
67
|
+
species_to_be_analyzed_before_experiment: SpeciesInitialData | None = Field(
|
|
68
|
+
description=" This is the initial condition of the model."
|
|
69
|
+
" This does not include species that reoccur or the species"
|
|
70
|
+
" whose concentration is to be determined/observed at the end"
|
|
71
|
+
" of the experiment. This also does not include the species"
|
|
72
|
+
" or the parameter that is to be scanned. Do not make up this data.",
|
|
73
|
+
default=None,
|
|
74
|
+
)
|
|
75
|
+
parameter_scan_data: ParameterScanData = Field(description="parameter scan data", default=None)
|
|
76
|
+
experiment_name: str = Field(
|
|
77
|
+
description="An AI assigned `_` separated unique name of"
|
|
78
|
+
" the parameter scan experiment based on human query."
|
|
79
|
+
" This must be unique for each experiment."
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def make_list_dic_scanned_data(dic_param_scan, arg_data, sys_bio_model, tool_call_id):
|
|
84
|
+
"""
|
|
85
|
+
Prepare the list dictionary of scanned data
|
|
86
|
+
that will be passed to the state of the graph.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
dic_param_scan: Dictionary of parameter scan results.
|
|
90
|
+
arg_data: The argument data.
|
|
91
|
+
sys_bio_model: The model data.
|
|
92
|
+
tool_call_id: The tool call ID.
|
|
93
|
+
|
|
94
|
+
Returns:
|
|
95
|
+
list: List of dictionary of scanned data.
|
|
96
|
+
"""
|
|
97
|
+
list_dic_scanned_data = []
|
|
98
|
+
for species_name, df_param_scan in dic_param_scan.items():
|
|
99
|
+
logger.log(
|
|
100
|
+
logging.INFO,
|
|
101
|
+
"Parameter scan results for %s with shape %s",
|
|
102
|
+
species_name,
|
|
103
|
+
df_param_scan.shape,
|
|
104
|
+
)
|
|
105
|
+
# Prepare the list dictionary of scanned data
|
|
106
|
+
# that will be passed to the state of the graph
|
|
107
|
+
list_dic_scanned_data.append(
|
|
108
|
+
{
|
|
109
|
+
"name": arg_data.experiment_name + ":" + species_name,
|
|
110
|
+
"source": (sys_bio_model.biomodel_id if sys_bio_model.biomodel_id else "upload"),
|
|
111
|
+
"tool_call_id": tool_call_id,
|
|
112
|
+
"data": df_param_scan.to_dict(),
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
return list_dic_scanned_data
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def run_parameter_scan(model_object, arg_data, dic_species_data, duration, interval) -> dict:
|
|
119
|
+
"""
|
|
120
|
+
Run parameter scan on the model.
|
|
121
|
+
|
|
122
|
+
Args:
|
|
123
|
+
model_object: The model object.
|
|
124
|
+
arg_data: The argument data.
|
|
125
|
+
dic_species_data: Dictionary of species data.
|
|
126
|
+
duration: Duration of the simulation.
|
|
127
|
+
interval: Interval between time points in the simulation.
|
|
128
|
+
|
|
129
|
+
Returns:
|
|
130
|
+
dict: Dictionary of parameter scan results. Each key is a species name
|
|
131
|
+
and each value is a DataFrame containing the results of the parameter scan.
|
|
132
|
+
"""
|
|
133
|
+
# Extract all parameter names from the model
|
|
134
|
+
df_all_parameters = basico.model_info.get_parameters(model=model_object.copasi_model)
|
|
135
|
+
all_parameters = []
|
|
136
|
+
if df_all_parameters is not None:
|
|
137
|
+
# For example model 10 in the BioModels database
|
|
138
|
+
# has no parameters
|
|
139
|
+
all_parameters = df_all_parameters.index.tolist()
|
|
140
|
+
|
|
141
|
+
# Extract all species name from the model
|
|
142
|
+
df_all_species = basico.model_info.get_species(model=model_object.copasi_model)
|
|
143
|
+
all_species = df_all_species["display_name"].tolist()
|
|
144
|
+
|
|
145
|
+
# Verify if the given species or parameter names to be scanned are valid
|
|
146
|
+
if arg_data.parameter_scan_data.species_parameter_name not in all_parameters + all_species:
|
|
147
|
+
logger.error(
|
|
148
|
+
"Invalid species or parameter name: %s",
|
|
149
|
+
arg_data.parameter_scan_data.species_parameter_name,
|
|
150
|
+
)
|
|
151
|
+
raise ValueError(
|
|
152
|
+
"Invalid species or parameter name: "
|
|
153
|
+
f"{arg_data.parameter_scan_data.species_parameter_name}."
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
# Dictionary to store the parameter scan results
|
|
157
|
+
dic_param_scan_results = {}
|
|
158
|
+
|
|
159
|
+
# Loop through the species names that are to be observed
|
|
160
|
+
for species_name in arg_data.parameter_scan_data.species_names:
|
|
161
|
+
# Verify if the given species name to be observed is valid
|
|
162
|
+
if species_name not in all_species:
|
|
163
|
+
logger.error("Invalid species name: %s", species_name)
|
|
164
|
+
raise ValueError(f"Invalid species name: {species_name}.")
|
|
165
|
+
|
|
166
|
+
# Copy the model object to avoid modifying the original model
|
|
167
|
+
model_object_copy = model_object.model_copy()
|
|
168
|
+
|
|
169
|
+
# Update the fixed model species and parameters
|
|
170
|
+
# These are the initial conditions of the model
|
|
171
|
+
# set by the user
|
|
172
|
+
model_object_copy.update_parameters(dic_species_data)
|
|
173
|
+
|
|
174
|
+
# Initialize empty DataFrame to store results
|
|
175
|
+
# of the parameter scan
|
|
176
|
+
df_param_scan = pd.DataFrame()
|
|
177
|
+
|
|
178
|
+
# Loop through the parameter that are to be scanned
|
|
179
|
+
for param_value in arg_data.parameter_scan_data.species_parameter_values:
|
|
180
|
+
# Update the parameter value in the model
|
|
181
|
+
model_object_copy.update_parameters(
|
|
182
|
+
{arg_data.parameter_scan_data.species_parameter_name: param_value}
|
|
183
|
+
)
|
|
184
|
+
# Simulate the model
|
|
185
|
+
model_object_copy.simulate(duration=duration, interval=interval)
|
|
186
|
+
# If the column name 'Time' is not present in the results DataFrame
|
|
187
|
+
if "Time" not in df_param_scan.columns:
|
|
188
|
+
df_param_scan["Time"] = model_object_copy.simulation_results["Time"]
|
|
189
|
+
# Add the simulation results to the results DataFrame
|
|
190
|
+
col_name = f"{arg_data.parameter_scan_data.species_parameter_name}_{param_value}"
|
|
191
|
+
df_param_scan[col_name] = model_object_copy.simulation_results[species_name]
|
|
192
|
+
|
|
193
|
+
logger.log(logging.INFO, "Parameter scan results with shape %s", df_param_scan.shape)
|
|
194
|
+
|
|
195
|
+
# Add the results of the parameter scan to the dictionary
|
|
196
|
+
dic_param_scan_results[species_name] = df_param_scan
|
|
197
|
+
# return df_param_scan
|
|
198
|
+
return dic_param_scan_results
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
class ParameterScanInput(BaseModel):
|
|
202
|
+
"""
|
|
203
|
+
Input schema for the ParameterScan tool.
|
|
204
|
+
"""
|
|
205
|
+
|
|
206
|
+
sys_bio_model: ModelData = Field(description="model data", default=None)
|
|
207
|
+
arg_data: ArgumentData = Field(
|
|
208
|
+
description="""time, species, and reocurring data
|
|
209
|
+
as well as the parameter scan name and
|
|
210
|
+
data""",
|
|
211
|
+
default=None,
|
|
212
|
+
)
|
|
213
|
+
tool_call_id: Annotated[str, InjectedToolCallId]
|
|
214
|
+
state: Annotated[dict, InjectedState]
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
# Note: It's important that every field has type hints. BaseTool is a
|
|
218
|
+
# Pydantic class and not having type hints can lead to unexpected behavior.
|
|
219
|
+
class ParameterScanTool(BaseTool):
|
|
220
|
+
"""
|
|
221
|
+
Tool for parameter scan.
|
|
222
|
+
"""
|
|
223
|
+
|
|
224
|
+
name: str = "parameter_scan"
|
|
225
|
+
description: str = """A tool to perform scanning of a given
|
|
226
|
+
parameter over a range of values and observe the effect on
|
|
227
|
+
the concentration of a given species"""
|
|
228
|
+
args_schema: type[BaseModel] = ParameterScanInput
|
|
229
|
+
|
|
230
|
+
def _run(
|
|
231
|
+
self,
|
|
232
|
+
tool_call_id: Annotated[str, InjectedToolCallId],
|
|
233
|
+
state: Annotated[dict, InjectedState],
|
|
234
|
+
sys_bio_model: ModelData = None,
|
|
235
|
+
arg_data: ArgumentData = None,
|
|
236
|
+
) -> Command:
|
|
237
|
+
"""
|
|
238
|
+
Run the tool.
|
|
239
|
+
|
|
240
|
+
Args:
|
|
241
|
+
tool_call_id (str): The tool call ID. This is injected by the system.
|
|
242
|
+
state (dict): The state of the tool.
|
|
243
|
+
sys_bio_model (ModelData): The model data.
|
|
244
|
+
arg_data (ArgumentData): The argument data.
|
|
245
|
+
|
|
246
|
+
Returns:
|
|
247
|
+
Command: The updated state of the tool.
|
|
248
|
+
"""
|
|
249
|
+
logger.log(logging.INFO, "Calling parameter_scan tool %s, %s", sys_bio_model, arg_data)
|
|
250
|
+
sbml_file_path = state["sbml_file_path"][-1] if len(state["sbml_file_path"]) > 0 else None
|
|
251
|
+
model_object = load_biomodel(sys_bio_model, sbml_file_path=sbml_file_path)
|
|
252
|
+
# Prepare the dictionary of species data
|
|
253
|
+
# that will be passed to the simulate method
|
|
254
|
+
# of the BasicoModel class
|
|
255
|
+
duration = 100.0
|
|
256
|
+
interval = 10
|
|
257
|
+
dic_species_data = {}
|
|
258
|
+
if arg_data:
|
|
259
|
+
# Prepare the dictionary of species data
|
|
260
|
+
if arg_data.species_to_be_analyzed_before_experiment is not None:
|
|
261
|
+
dic_species_data = dict(
|
|
262
|
+
zip(
|
|
263
|
+
arg_data.species_to_be_analyzed_before_experiment.species_name,
|
|
264
|
+
arg_data.species_to_be_analyzed_before_experiment.species_concentration,
|
|
265
|
+
strict=False,
|
|
266
|
+
)
|
|
267
|
+
)
|
|
268
|
+
|
|
269
|
+
# # Add reocurring events (if any) to the model
|
|
270
|
+
# if arg_data.reocurring_data is not None:
|
|
271
|
+
# add_rec_events(model_object, arg_data.reocurring_data)
|
|
272
|
+
|
|
273
|
+
# Set the duration and interval
|
|
274
|
+
if arg_data.time_data is not None:
|
|
275
|
+
duration = arg_data.time_data.duration
|
|
276
|
+
interval = arg_data.time_data.interval
|
|
277
|
+
|
|
278
|
+
# Run the parameter scan
|
|
279
|
+
dic_param_scan = run_parameter_scan(
|
|
280
|
+
model_object, arg_data, dic_species_data, duration, interval
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
logger.log(logging.INFO, "Parameter scan results ready")
|
|
284
|
+
# Prepare the list dictionary of scanned data
|
|
285
|
+
list_dic_scanned_data = make_list_dic_scanned_data(
|
|
286
|
+
dic_param_scan, arg_data, sys_bio_model, tool_call_id
|
|
287
|
+
)
|
|
288
|
+
# Prepare the dictionary of updated state for the model
|
|
289
|
+
dic_updated_state_for_model = {}
|
|
290
|
+
for key, value in {
|
|
291
|
+
"model_id": [sys_bio_model.biomodel_id],
|
|
292
|
+
"sbml_file_path": [sbml_file_path],
|
|
293
|
+
"dic_scanned_data": list_dic_scanned_data,
|
|
294
|
+
}.items():
|
|
295
|
+
if value:
|
|
296
|
+
dic_updated_state_for_model[key] = value
|
|
297
|
+
# Return the updated state
|
|
298
|
+
return Command(
|
|
299
|
+
update=dic_updated_state_for_model
|
|
300
|
+
| {
|
|
301
|
+
# update the message history
|
|
302
|
+
"messages": [
|
|
303
|
+
ToolMessage(
|
|
304
|
+
content=f"Parameter scan results of {arg_data.experiment_name}",
|
|
305
|
+
tool_call_id=tool_call_id,
|
|
306
|
+
artifact=get_model_units(model_object),
|
|
307
|
+
)
|
|
308
|
+
],
|
|
309
|
+
}
|
|
310
|
+
)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Tool for asking questions to the article.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import logging
|
|
8
|
+
from typing import Annotated
|
|
9
|
+
|
|
10
|
+
from langchain_community.document_loaders import PyPDFLoader
|
|
11
|
+
from langchain_core.tools import BaseTool
|
|
12
|
+
from langchain_core.vectorstores import InMemoryVectorStore
|
|
13
|
+
from langgraph.prebuilt import InjectedState
|
|
14
|
+
from pydantic import BaseModel, Field
|
|
15
|
+
|
|
16
|
+
# Initialize logger
|
|
17
|
+
logging.basicConfig(level=logging.INFO)
|
|
18
|
+
logger = logging.getLogger(__name__)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class QueryArticleInput(BaseModel):
|
|
22
|
+
"""
|
|
23
|
+
Input schema for the query_articles tool.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
question: Annotated[str, Field(description="User question to search articles.")]
|
|
27
|
+
state: Annotated[dict, InjectedState]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# Note: It's important that every field has type hints. BaseTool is a
|
|
31
|
+
# Pydantic class and not having type hints can lead to unexpected behavior.
|
|
32
|
+
class QueryArticle(BaseTool):
|
|
33
|
+
"""
|
|
34
|
+
Tool to ask questions to the article.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
name: str = "query_article"
|
|
38
|
+
description: str = "Ask questions to the article."
|
|
39
|
+
args_schema: type[BaseModel] = QueryArticleInput
|
|
40
|
+
|
|
41
|
+
def _run(self, question: str, state: Annotated[dict, InjectedState]):
|
|
42
|
+
"""
|
|
43
|
+
Run the tool.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
query (str): The search query.
|
|
47
|
+
"""
|
|
48
|
+
logger.log(logging.INFO, "loading the article from %s", state["pdf_file_name"])
|
|
49
|
+
logger.log(logging.INFO, "searching the article with the question: %s", question)
|
|
50
|
+
# Load the article
|
|
51
|
+
loader = PyPDFLoader(state["pdf_file_name"])
|
|
52
|
+
# Load the pages of the article
|
|
53
|
+
pages = []
|
|
54
|
+
for page in loader.lazy_load():
|
|
55
|
+
pages.append(page)
|
|
56
|
+
# Set up text embedding model
|
|
57
|
+
text_embedding_model = state["text_embedding_model"]
|
|
58
|
+
logging.info("Loaded text embedding model %s", text_embedding_model)
|
|
59
|
+
# Create a vector store from the pages
|
|
60
|
+
vector_store = InMemoryVectorStore.from_documents(pages, text_embedding_model)
|
|
61
|
+
# Search the article with the question
|
|
62
|
+
docs = vector_store.similarity_search(question)
|
|
63
|
+
# Return the content of the pages
|
|
64
|
+
return "\n".join([doc.page_content for doc in docs])
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Tool for saving models.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import logging
|
|
8
|
+
import os
|
|
9
|
+
from typing import Annotated
|
|
10
|
+
|
|
11
|
+
from langchain_core.messages import ToolMessage
|
|
12
|
+
from langchain_core.tools import BaseTool
|
|
13
|
+
from langchain_core.tools.base import InjectedToolCallId
|
|
14
|
+
from langgraph.prebuilt import InjectedState
|
|
15
|
+
from langgraph.types import Command
|
|
16
|
+
from pydantic import BaseModel, Field
|
|
17
|
+
|
|
18
|
+
# Initialize logger
|
|
19
|
+
logging.basicConfig(level=logging.INFO)
|
|
20
|
+
logger = logging.getLogger(__name__)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class SaveModelInput(BaseModel):
|
|
24
|
+
"""
|
|
25
|
+
Input schema for the save model tool.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
path_to_folder: str = Field(
|
|
29
|
+
description="Path to folder to save the model. Keep it to . if not provided.", default="."
|
|
30
|
+
)
|
|
31
|
+
output_filename: str = Field(
|
|
32
|
+
description="Filename to save the model as. Default is 'saved_model.xml'.",
|
|
33
|
+
default="saved_model.xml",
|
|
34
|
+
)
|
|
35
|
+
tool_call_id: Annotated[str, InjectedToolCallId]
|
|
36
|
+
state: Annotated[dict, InjectedState]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# Note: It's important that every field has type hints. BaseTool is a
|
|
40
|
+
# Pydantic class and not having type hints can lead to unexpected behavior.
|
|
41
|
+
class SaveModelTool(BaseTool):
|
|
42
|
+
"""
|
|
43
|
+
Tool for saving a model.
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
name: str = "save_model"
|
|
47
|
+
description: str = "A tool to save the current biomodel to a \
|
|
48
|
+
user specified path with the default filename\
|
|
49
|
+
'saved_model.xml'"
|
|
50
|
+
args_schema: type[BaseModel] = SaveModelInput
|
|
51
|
+
return_direct: bool = False
|
|
52
|
+
|
|
53
|
+
def _run(
|
|
54
|
+
self,
|
|
55
|
+
tool_call_id: Annotated[str, InjectedToolCallId],
|
|
56
|
+
state: Annotated[dict, InjectedState],
|
|
57
|
+
path_to_folder: str = ".",
|
|
58
|
+
output_filename: str = "saved_model.xml",
|
|
59
|
+
) -> Command:
|
|
60
|
+
"""
|
|
61
|
+
Run the tool.
|
|
62
|
+
|
|
63
|
+
Args:
|
|
64
|
+
path (str): The path to save the model.
|
|
65
|
+
tool_call_id (str): The tool call ID.
|
|
66
|
+
|
|
67
|
+
Returns:
|
|
68
|
+
|
|
69
|
+
"""
|
|
70
|
+
logger.log(
|
|
71
|
+
logging.INFO,
|
|
72
|
+
"Saving model to path: %s with filename: %s",
|
|
73
|
+
path_to_folder,
|
|
74
|
+
output_filename,
|
|
75
|
+
)
|
|
76
|
+
# Check if path does not exist
|
|
77
|
+
if not os.path.exists(path_to_folder):
|
|
78
|
+
content = f"Error: Path {path_to_folder} does not exist."
|
|
79
|
+
logger.error(content)
|
|
80
|
+
else:
|
|
81
|
+
logger.info("Saving now")
|
|
82
|
+
# Save the model to the specified path
|
|
83
|
+
with open(os.path.join(path_to_folder, output_filename), "w", encoding="utf-8") as f:
|
|
84
|
+
f.write(state["model_as_string"][-1])
|
|
85
|
+
content = f"Model saved successfully to {path_to_folder}/{output_filename}."
|
|
86
|
+
logger.info(content)
|
|
87
|
+
# Return the updated state of the tool
|
|
88
|
+
return Command(
|
|
89
|
+
update={
|
|
90
|
+
# update the message history
|
|
91
|
+
"messages": [
|
|
92
|
+
ToolMessage(
|
|
93
|
+
content=content,
|
|
94
|
+
tool_call_id=tool_call_id,
|
|
95
|
+
)
|
|
96
|
+
],
|
|
97
|
+
}
|
|
98
|
+
)
|