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,104 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Enrichment class for enriching PubChem IDs with their STRINGS representation.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import logging
|
|
8
|
+
|
|
9
|
+
import hydra
|
|
10
|
+
import requests
|
|
11
|
+
|
|
12
|
+
# Initialize logger
|
|
13
|
+
logging.basicConfig(level=logging.INFO)
|
|
14
|
+
logger = logging.getLogger(__name__)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def cas_rn2pubchem_cid(casrn):
|
|
18
|
+
"""
|
|
19
|
+
Convert CAS RN to PubChem CID.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
casrn: The CAS RN of the drug.
|
|
23
|
+
|
|
24
|
+
Returns:
|
|
25
|
+
The PubChem CID of the drug.
|
|
26
|
+
"""
|
|
27
|
+
# Load Hydra configuration for PubChem ID conversion
|
|
28
|
+
with hydra.initialize(version_base=None, config_path="../configs"):
|
|
29
|
+
cfg = hydra.compose(config_name="config", overrides=["utils/pubchem_utils=default"])
|
|
30
|
+
cfg = cfg.utils.pubchem_utils
|
|
31
|
+
# Prepare the URL
|
|
32
|
+
pubchem_url_for_drug = f"{cfg.pubchem_casrn2cid_url}{casrn}/record/JSON"
|
|
33
|
+
# Get the data
|
|
34
|
+
response = requests.get(pubchem_url_for_drug, timeout=60)
|
|
35
|
+
data = response.json()
|
|
36
|
+
# Extract the PubChem CID
|
|
37
|
+
cid = None
|
|
38
|
+
for substance in data.get("PC_Substances", []):
|
|
39
|
+
for compound in substance.get("compound", []):
|
|
40
|
+
if "id" in compound and "type" in compound["id"] and compound["id"]["type"] == 1:
|
|
41
|
+
cid = compound["id"].get("id", {}).get("cid")
|
|
42
|
+
break
|
|
43
|
+
if cid is not None:
|
|
44
|
+
break
|
|
45
|
+
return cid
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def external_id2pubchem_cid(db, db_id):
|
|
49
|
+
"""
|
|
50
|
+
Convert external DB ID to PubChem CID.
|
|
51
|
+
Please refer to the following URL for more information
|
|
52
|
+
on data sources:
|
|
53
|
+
https://pubchem.ncbi.nlm.nih.gov/sources/
|
|
54
|
+
|
|
55
|
+
Args:
|
|
56
|
+
db: The database name.
|
|
57
|
+
db_id: The database ID of the drug.
|
|
58
|
+
|
|
59
|
+
Returns:
|
|
60
|
+
The PubChem CID of the drug.
|
|
61
|
+
"""
|
|
62
|
+
# Load Hydra configuration for PubChem ID conversion
|
|
63
|
+
with hydra.initialize(version_base=None, config_path="../configs"):
|
|
64
|
+
cfg = hydra.compose(config_name="config", overrides=["utils/pubchem_utils=default"])
|
|
65
|
+
cfg = cfg.utils.pubchem_utils
|
|
66
|
+
# Prepare the URL
|
|
67
|
+
pubchem_url_for_drug = f"{cfg.pubchem_cid_base_url}/{db}/{db_id}/JSON"
|
|
68
|
+
# Get the data
|
|
69
|
+
response = requests.get(pubchem_url_for_drug, timeout=60)
|
|
70
|
+
data = response.json()
|
|
71
|
+
# Extract the PubChem CID
|
|
72
|
+
cid = None
|
|
73
|
+
for substance in data.get("PC_Substances", []):
|
|
74
|
+
for compound in substance.get("compound", []):
|
|
75
|
+
if "id" in compound and "type" in compound["id"] and compound["id"]["type"] == 1:
|
|
76
|
+
cid = compound["id"].get("id", {}).get("cid")
|
|
77
|
+
break
|
|
78
|
+
return cid
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def pubchem_cid_description(cid):
|
|
82
|
+
"""
|
|
83
|
+
Get the description of a PubChem CID.
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
cid: The PubChem CID of the drug.
|
|
87
|
+
|
|
88
|
+
Returns:
|
|
89
|
+
The description of the PubChem CID.
|
|
90
|
+
"""
|
|
91
|
+
# Load Hydra configuration for PubChem CID description
|
|
92
|
+
with hydra.initialize(version_base=None, config_path="../configs"):
|
|
93
|
+
cfg = hydra.compose(config_name="config", overrides=["utils/pubchem_utils=default"])
|
|
94
|
+
cfg = cfg.utils.pubchem_utils
|
|
95
|
+
# Prepare the URL
|
|
96
|
+
pubchem_url_for_descpription = f"{cfg.pubchem_cid_description_url}/{cid}/description/JSON"
|
|
97
|
+
# Get the data
|
|
98
|
+
response = requests.get(pubchem_url_for_descpription, timeout=60)
|
|
99
|
+
data = response.json()
|
|
100
|
+
# Extract the PubChem CID description
|
|
101
|
+
description = ""
|
|
102
|
+
for information in data["InformationList"]["Information"]:
|
|
103
|
+
description += information.get("Description", "")
|
|
104
|
+
return description
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# syntax=docker/dockerfile:1
|
|
2
|
+
|
|
3
|
+
# Dockerfile for the talk2scholars application
|
|
4
|
+
# Multi-stage build for optimized image size with UV package manager
|
|
5
|
+
|
|
6
|
+
ARG BASE_IMAGE=ubuntu:24.04
|
|
7
|
+
ARG PYTHON_VERSION=3.12
|
|
8
|
+
|
|
9
|
+
FROM ${BASE_IMAGE} AS dev-base
|
|
10
|
+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
|
11
|
+
build-essential \
|
|
12
|
+
ca-certificates \
|
|
13
|
+
cmake \
|
|
14
|
+
curl \
|
|
15
|
+
g++ \
|
|
16
|
+
libopenblas-dev \
|
|
17
|
+
libomp-dev \
|
|
18
|
+
ninja-build \
|
|
19
|
+
wget \
|
|
20
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
21
|
+
|
|
22
|
+
FROM dev-base AS python-install
|
|
23
|
+
ARG PYTHON_VERSION=3.12
|
|
24
|
+
|
|
25
|
+
# Install Python (available in Ubuntu 24.04 default repos)
|
|
26
|
+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
|
27
|
+
python${PYTHON_VERSION} \
|
|
28
|
+
python${PYTHON_VERSION}-dev \
|
|
29
|
+
python${PYTHON_VERSION}-venv \
|
|
30
|
+
python3-pip \
|
|
31
|
+
&& rm -rf /var/lib/apt/lists/* \
|
|
32
|
+
&& update-alternatives --install /usr/bin/python3 python3 /usr/bin/python${PYTHON_VERSION} 1 \
|
|
33
|
+
&& update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_VERSION} 1
|
|
34
|
+
|
|
35
|
+
FROM python-install AS uv-install
|
|
36
|
+
WORKDIR /app
|
|
37
|
+
|
|
38
|
+
# Install UV package manager and dependencies
|
|
39
|
+
COPY pyproject.toml uv.lock* ./
|
|
40
|
+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
|
|
41
|
+
export PATH="/root/.local/bin:$PATH" && \
|
|
42
|
+
export UV_PROJECT_ENVIRONMENT="/opt/venv" && \
|
|
43
|
+
uv sync --frozen --extra dev --no-install-project --python python${PYTHON_VERSION} && \
|
|
44
|
+
. /opt/venv/bin/activate && \
|
|
45
|
+
# RAPIDS packages (commented out - will be added in future if needed)
|
|
46
|
+
# uv pip install \
|
|
47
|
+
# --extra-index-url=https://pypi.nvidia.com \
|
|
48
|
+
# --index-strategy unsafe-best-match \
|
|
49
|
+
# cudf-cu12 dask-cudf-cu12 && \
|
|
50
|
+
uv cache clean
|
|
51
|
+
|
|
52
|
+
FROM ${BASE_IMAGE} AS runtime
|
|
53
|
+
ARG PYTHON_VERSION=3.12
|
|
54
|
+
LABEL maintainer="talk2scholars"
|
|
55
|
+
LABEL version="1.0.0"
|
|
56
|
+
LABEL description="AI Agents for Pharma - Scholars Application"
|
|
57
|
+
|
|
58
|
+
# Install runtime dependencies
|
|
59
|
+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
|
60
|
+
ca-certificates \
|
|
61
|
+
curl \
|
|
62
|
+
libmagic1 \
|
|
63
|
+
libopenblas0 \
|
|
64
|
+
libomp5 \
|
|
65
|
+
python${PYTHON_VERSION} \
|
|
66
|
+
&& rm -rf /var/lib/apt/lists/* \
|
|
67
|
+
&& update-alternatives --install /usr/bin/python3 python3 /usr/bin/python${PYTHON_VERSION} 1 \
|
|
68
|
+
&& update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_VERSION} 1
|
|
69
|
+
|
|
70
|
+
# Copy UV virtual environment from build stage
|
|
71
|
+
COPY --from=uv-install /opt/venv /opt/venv
|
|
72
|
+
|
|
73
|
+
# Set environment variables
|
|
74
|
+
ENV PATH="/opt/venv/bin:$PATH"
|
|
75
|
+
ENV PYTHONPATH="/app"
|
|
76
|
+
ENV PYTHONUNBUFFERED=1
|
|
77
|
+
ENV PYTHONDONTWRITEBYTECODE=1
|
|
78
|
+
ENV STREAMLIT_SERVER_HEADLESS=true
|
|
79
|
+
ENV STREAMLIT_SERVER_ENABLE_CORS=false
|
|
80
|
+
|
|
81
|
+
# Set working directory and create necessary directories
|
|
82
|
+
WORKDIR /app
|
|
83
|
+
|
|
84
|
+
# Copy application code
|
|
85
|
+
COPY aiagents4pharma/talk2scholars /app/aiagents4pharma/talk2scholars
|
|
86
|
+
COPY docs /app/docs
|
|
87
|
+
COPY app /app/app
|
|
88
|
+
|
|
89
|
+
# Copy and set up the entrypoint script (commented out - will be added in future if needed)
|
|
90
|
+
# COPY aiagents4pharma/talk2knowledgegraphs/entrypoint.sh /usr/local/bin/entrypoint.sh
|
|
91
|
+
# RUN chmod +x /usr/local/bin/entrypoint.sh
|
|
92
|
+
|
|
93
|
+
# Health check for production monitoring
|
|
94
|
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
|
95
|
+
CMD curl -f http://localhost:8501/health || exit 1
|
|
96
|
+
|
|
97
|
+
# Expose the default Streamlit port
|
|
98
|
+
EXPOSE 8501
|
|
99
|
+
|
|
100
|
+
# Set the entrypoint (commented out - will be added in future if needed)
|
|
101
|
+
# ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
|
102
|
+
|
|
103
|
+
# Default command (can be overridden)
|
|
104
|
+
CMD ["streamlit", "run", "/app/app/frontend/streamlit_app_talk2scholars.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Please check out the README file in the root folder for more information.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This file is used to import all the modules in the package.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from . import main_agent, paper_download_agent, pdf_agent, s2_agent, zotero_agent
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
"main_agent",
|
|
9
|
+
"s2_agent",
|
|
10
|
+
"paper_download_agent",
|
|
11
|
+
"zotero_agent",
|
|
12
|
+
"pdf_agent",
|
|
13
|
+
]
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Main agent module for initializing and running the Talk2Scholars application.
|
|
5
|
+
|
|
6
|
+
This module sets up the hierarchical agent system using LangGraph and integrates
|
|
7
|
+
various sub-agents for handling different tasks such as semantic scholar, zotero,
|
|
8
|
+
PDF processing, and paper downloading.
|
|
9
|
+
|
|
10
|
+
Functions:
|
|
11
|
+
- get_app: Initializes and returns the LangGraph-based hierarchical agent system.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import logging
|
|
15
|
+
|
|
16
|
+
import hydra
|
|
17
|
+
from langchain_core.language_models.chat_models import BaseChatModel
|
|
18
|
+
from langchain_openai import ChatOpenAI
|
|
19
|
+
from langgraph.checkpoint.memory import MemorySaver
|
|
20
|
+
from langgraph_supervisor import create_supervisor
|
|
21
|
+
|
|
22
|
+
from ..agents.paper_download_agent import get_app as get_app_paper_download
|
|
23
|
+
from ..agents.pdf_agent import get_app as get_app_pdf
|
|
24
|
+
from ..agents.s2_agent import get_app as get_app_s2
|
|
25
|
+
from ..agents.zotero_agent import get_app as get_app_zotero
|
|
26
|
+
from ..state.state_talk2scholars import Talk2Scholars
|
|
27
|
+
|
|
28
|
+
# Initialize logger
|
|
29
|
+
logging.basicConfig(level=logging.INFO)
|
|
30
|
+
logger = logging.getLogger(__name__)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def get_app(uniq_id, llm_model: BaseChatModel):
|
|
34
|
+
"""
|
|
35
|
+
Initializes and returns the LangGraph-based hierarchical agent system.
|
|
36
|
+
|
|
37
|
+
This function constructs the agent workflow by defining nodes for the supervisor
|
|
38
|
+
and sub-agents. It compiles the graph using `StateGraph` to enable structured
|
|
39
|
+
conversational workflows.
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
thread_id (str): A unique session identifier for tracking conversation state.
|
|
43
|
+
llm_model (BaseChatModel, optional): The language model used for query processing.
|
|
44
|
+
Defaults to `ChatOpenAI(model="gpt-4o-mini", temperature=0)`.
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
StateGraph: A compiled LangGraph application that can process user queries.
|
|
48
|
+
|
|
49
|
+
Example:
|
|
50
|
+
>>> app = get_app("thread_123")
|
|
51
|
+
>>> result = app.invoke(initial_state)
|
|
52
|
+
"""
|
|
53
|
+
# Replace placeholder mini model with a configured ChatOpenAI instance
|
|
54
|
+
if getattr(llm_model, "model_name", None) == "gpt-4o-mini":
|
|
55
|
+
llm_model = ChatOpenAI(
|
|
56
|
+
model="gpt-4o-mini",
|
|
57
|
+
temperature=0,
|
|
58
|
+
model_kwargs={"parallel_tool_calls": False},
|
|
59
|
+
)
|
|
60
|
+
# Load hydra configuration
|
|
61
|
+
logger.log(logging.INFO, "Launching Talk2Scholars with thread_id %s", uniq_id)
|
|
62
|
+
with hydra.initialize(version_base=None, config_path="../configs/"):
|
|
63
|
+
cfg = hydra.compose(
|
|
64
|
+
config_name="config", overrides=["agents/talk2scholars/main_agent=default"]
|
|
65
|
+
)
|
|
66
|
+
cfg = cfg.agents.talk2scholars.main_agent
|
|
67
|
+
logger.log(logging.INFO, "System_prompt of Talk2Scholars: %s", cfg.system_prompt)
|
|
68
|
+
# Create supervisor workflow
|
|
69
|
+
workflow = create_supervisor(
|
|
70
|
+
[
|
|
71
|
+
get_app_s2(uniq_id, llm_model), # semantic scholar
|
|
72
|
+
get_app_zotero(uniq_id, llm_model), # zotero
|
|
73
|
+
get_app_paper_download(uniq_id, llm_model), # pdf
|
|
74
|
+
get_app_pdf(uniq_id, llm_model), # paper download
|
|
75
|
+
],
|
|
76
|
+
model=llm_model,
|
|
77
|
+
state_schema=Talk2Scholars,
|
|
78
|
+
# Full history is needed to extract
|
|
79
|
+
# the tool artifacts
|
|
80
|
+
output_mode="full_history",
|
|
81
|
+
# Allow supervisor to resume control and chain multiple sub-agent calls
|
|
82
|
+
add_handoff_back_messages=True,
|
|
83
|
+
prompt=cfg.system_prompt,
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
# Compile and run
|
|
87
|
+
app = workflow.compile(checkpointer=MemorySaver(), name="Talk2Scholars_MainAgent")
|
|
88
|
+
|
|
89
|
+
return app
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
This module defines the paper download agent that connects to the arXiv API to fetch
|
|
4
|
+
paper details and PDFs. It is part of the Talk2Scholars project.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import logging
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
import hydra
|
|
11
|
+
from langchain_core.language_models.chat_models import BaseChatModel
|
|
12
|
+
from langgraph.checkpoint.memory import MemorySaver
|
|
13
|
+
from langgraph.graph import START, StateGraph
|
|
14
|
+
from langgraph.prebuilt.chat_agent_executor import create_react_agent
|
|
15
|
+
from langgraph.prebuilt.tool_node import ToolNode
|
|
16
|
+
|
|
17
|
+
from ..state.state_talk2scholars import Talk2Scholars
|
|
18
|
+
from ..tools.paper_download.paper_downloader import download_papers
|
|
19
|
+
|
|
20
|
+
# Initialize logger
|
|
21
|
+
logging.basicConfig(level=logging.INFO)
|
|
22
|
+
logger = logging.getLogger(__name__)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def get_app(uniq_id, llm_model: BaseChatModel):
|
|
26
|
+
"""
|
|
27
|
+
Initializes and returns the LangGraph application for the Talk2Scholars paper download agent.
|
|
28
|
+
|
|
29
|
+
This agent supports downloading scientific papers from multiple preprint servers, including
|
|
30
|
+
arXiv, BioRxiv, and MedRxiv. It can intelligently handle user queries by extracting or resolving
|
|
31
|
+
necessary identifiers (e.g., arXiv ID or DOI) from the paper title and routing the request to
|
|
32
|
+
the appropriate download tool.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
uniq_id (str): A unique identifier for tracking the current session.
|
|
36
|
+
llm_model (BaseChatModel, optional): The language model to be used by the agent.
|
|
37
|
+
Defaults to ChatOpenAI(model="gpt-4o-mini", temperature=0.5).
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
StateGraph: A compiled LangGraph application that enables the paper download agent to
|
|
41
|
+
process user queries and retrieve research papers from arXiv (using arXiv ID),
|
|
42
|
+
BioRxiv and MedRxiv (using DOI resolved from the paper title or provided directly).
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
# Load Hydra configuration
|
|
46
|
+
logger.info("Loading Hydra configuration for Talk2Scholars paper download agent")
|
|
47
|
+
with hydra.initialize(version_base=None, config_path="../configs"):
|
|
48
|
+
cfg = hydra.compose(
|
|
49
|
+
config_name="config",
|
|
50
|
+
overrides=["agents/talk2scholars/paper_download_agent=default"],
|
|
51
|
+
)
|
|
52
|
+
cfg = cfg.agents.talk2scholars.paper_download_agent
|
|
53
|
+
|
|
54
|
+
# Define tools properly
|
|
55
|
+
tools = ToolNode(
|
|
56
|
+
[
|
|
57
|
+
download_papers,
|
|
58
|
+
]
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
# Define the model
|
|
62
|
+
logger.info("Using OpenAI model %s", llm_model)
|
|
63
|
+
model = create_react_agent(
|
|
64
|
+
llm_model,
|
|
65
|
+
tools=tools,
|
|
66
|
+
state_schema=Talk2Scholars,
|
|
67
|
+
prompt=cfg.paper_download_agent,
|
|
68
|
+
checkpointer=MemorySaver(),
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
def paper_download_agent_node(state: Talk2Scholars) -> dict[str, Any]:
|
|
72
|
+
"""
|
|
73
|
+
Processes the current state to fetch the research paper from arXiv, BioRxiv, or MedRxiv.
|
|
74
|
+
"""
|
|
75
|
+
logger.info("Creating paper download agent node with thread_id: %s", uniq_id)
|
|
76
|
+
result = model.invoke(state, {"configurable": {"thread_id": uniq_id}})
|
|
77
|
+
return result
|
|
78
|
+
|
|
79
|
+
# Define new graph
|
|
80
|
+
workflow = StateGraph(Talk2Scholars)
|
|
81
|
+
|
|
82
|
+
# Adding node for paper download agent
|
|
83
|
+
workflow.add_node("paper_download_agent", paper_download_agent_node)
|
|
84
|
+
|
|
85
|
+
# Entering into the agent
|
|
86
|
+
workflow.add_edge(START, "paper_download_agent")
|
|
87
|
+
|
|
88
|
+
# Memory management for states between graph runs
|
|
89
|
+
checkpointer = MemorySaver()
|
|
90
|
+
|
|
91
|
+
# Compile the graph
|
|
92
|
+
app = workflow.compile(checkpointer=checkpointer, name="paper_download_agent")
|
|
93
|
+
|
|
94
|
+
# Logging the information and returning the app
|
|
95
|
+
logger.info("Compiled the graph")
|
|
96
|
+
return app
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Agent for interacting with PDF documents via question and answer.
|
|
4
|
+
|
|
5
|
+
This module initializes and compiles a LangGraph application that enables users to query PDF
|
|
6
|
+
documents using a question_and_answer tool. It integrates a language model and follows
|
|
7
|
+
the ReAct pattern to process and answer queries related to PDF content.
|
|
8
|
+
|
|
9
|
+
Usage:
|
|
10
|
+
>>> app = get_app("unique_thread_id")
|
|
11
|
+
>>> response = app.invoke(initial_state)
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import logging
|
|
15
|
+
|
|
16
|
+
import hydra
|
|
17
|
+
from langchain_core.language_models.chat_models import BaseChatModel
|
|
18
|
+
from langgraph.checkpoint.memory import MemorySaver
|
|
19
|
+
from langgraph.graph import START, StateGraph
|
|
20
|
+
from langgraph.prebuilt import ToolNode, create_react_agent
|
|
21
|
+
|
|
22
|
+
from ..state.state_talk2scholars import Talk2Scholars
|
|
23
|
+
from ..tools.pdf.question_and_answer import question_and_answer
|
|
24
|
+
|
|
25
|
+
# Initialize logger
|
|
26
|
+
logging.basicConfig(level=logging.INFO)
|
|
27
|
+
logger = logging.getLogger(__name__)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def get_app(uniq_id, llm_model: BaseChatModel):
|
|
31
|
+
"""
|
|
32
|
+
Initializes and returns the LangGraph application for the PDF agent.
|
|
33
|
+
|
|
34
|
+
This function sets up the PDF agent by loading configuration settings via Hydra,
|
|
35
|
+
initializing a model, and creating a workflow graph that incorporates
|
|
36
|
+
PDF-specific tools. The agent is built using the ReAct pattern to facilitate interactive
|
|
37
|
+
querying and processing of PDF documents.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
uniq_id (str): A unique identifier for the current conversation session or thread.
|
|
41
|
+
llm_model (BaseChatModel, optional): The language model instance to be used.
|
|
42
|
+
Defaults to ChatOpenAI(model="gpt-4o-mini", temperature=0).
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
StateGraph: A compiled LangGraph application capable of handling PDF interactions.
|
|
46
|
+
|
|
47
|
+
Example:
|
|
48
|
+
>>> app = get_app("thread_123")
|
|
49
|
+
>>> result = app.invoke(initial_state)
|
|
50
|
+
"""
|
|
51
|
+
# Load configuration using Hydra.
|
|
52
|
+
with hydra.initialize(version_base=None, config_path="../configs"):
|
|
53
|
+
cfg = hydra.compose(
|
|
54
|
+
config_name="config",
|
|
55
|
+
overrides=["agents/talk2scholars/pdf_agent=default"],
|
|
56
|
+
)
|
|
57
|
+
cfg = cfg.agents.talk2scholars.pdf_agent
|
|
58
|
+
logger.info("Loaded pdf_agent configuration.")
|
|
59
|
+
|
|
60
|
+
def pdf_agent_node(state: Talk2Scholars):
|
|
61
|
+
"""
|
|
62
|
+
Processes the current state by invoking the language model for PDF question and answer.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
state (Talk2Scholars): The current conversation state containing query details
|
|
66
|
+
and context.
|
|
67
|
+
|
|
68
|
+
Returns:
|
|
69
|
+
Any: The response generated by the language model after processing the state.
|
|
70
|
+
"""
|
|
71
|
+
logger.info("Creating Agent_PDF node with thread_id %s", uniq_id)
|
|
72
|
+
response = model.invoke(state, {"configurable": {"thread_id": uniq_id}})
|
|
73
|
+
return response
|
|
74
|
+
|
|
75
|
+
# Define the tool node that includes the PDF QnA tool.
|
|
76
|
+
tools = ToolNode([question_and_answer])
|
|
77
|
+
|
|
78
|
+
logger.info("Using OpenAI model %s", llm_model)
|
|
79
|
+
|
|
80
|
+
# Create the agent using the provided BaseChatModel instance.
|
|
81
|
+
model = create_react_agent(
|
|
82
|
+
llm_model,
|
|
83
|
+
tools=tools,
|
|
84
|
+
state_schema=Talk2Scholars,
|
|
85
|
+
prompt=cfg.pdf_agent,
|
|
86
|
+
checkpointer=MemorySaver(),
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
# Define a new workflow graph with the state schema.
|
|
90
|
+
workflow = StateGraph(Talk2Scholars)
|
|
91
|
+
workflow.add_node("pdf_agent", pdf_agent_node)
|
|
92
|
+
workflow.add_edge(START, "pdf_agent")
|
|
93
|
+
|
|
94
|
+
# Initialize memory to persist state between runs.
|
|
95
|
+
checkpointer = MemorySaver()
|
|
96
|
+
|
|
97
|
+
# Compile the graph into a runnable app.
|
|
98
|
+
app = workflow.compile(checkpointer=checkpointer, name="pdf_agent")
|
|
99
|
+
logger.info("Compiled the PDF agent graph.")
|
|
100
|
+
|
|
101
|
+
return app
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# /usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Agent for interacting with Semantic Scholar
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import logging
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
import hydra
|
|
11
|
+
from langchain_core.language_models.chat_models import BaseChatModel
|
|
12
|
+
from langgraph.checkpoint.memory import MemorySaver
|
|
13
|
+
from langgraph.graph import START, StateGraph
|
|
14
|
+
from langgraph.prebuilt import ToolNode, create_react_agent
|
|
15
|
+
|
|
16
|
+
from ..state.state_talk2scholars import Talk2Scholars
|
|
17
|
+
from ..tools.s2.display_dataframe import display_dataframe
|
|
18
|
+
from ..tools.s2.multi_paper_rec import (
|
|
19
|
+
get_multi_paper_recommendations,
|
|
20
|
+
)
|
|
21
|
+
from ..tools.s2.query_dataframe import query_dataframe
|
|
22
|
+
from ..tools.s2.retrieve_semantic_scholar_paper_id import (
|
|
23
|
+
retrieve_semantic_scholar_paper_id,
|
|
24
|
+
)
|
|
25
|
+
from ..tools.s2.search import search_tool
|
|
26
|
+
from ..tools.s2.single_paper_rec import (
|
|
27
|
+
get_single_paper_recommendations,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# Initialize logger
|
|
31
|
+
logging.basicConfig(level=logging.INFO)
|
|
32
|
+
logger = logging.getLogger(__name__)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def get_app(uniq_id, llm_model: BaseChatModel):
|
|
36
|
+
"""
|
|
37
|
+
Initializes and returns the LangGraph application for the Semantic Scholar (S2) agent.
|
|
38
|
+
|
|
39
|
+
This function sets up the S2 agent, which integrates various tools to search, retrieve,
|
|
40
|
+
and display research papers from Semantic Scholar. The agent follows the ReAct pattern
|
|
41
|
+
for structured interaction.
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
uniq_id (str): Unique identifier for the current conversation session.
|
|
45
|
+
llm_model (BaseChatModel, optional): The language model to be used by the agent.
|
|
46
|
+
Defaults to `ChatOpenAI(model="gpt-4o-mini", temperature=0)`.
|
|
47
|
+
|
|
48
|
+
Returns:
|
|
49
|
+
StateGraph: A compiled LangGraph application that enables the S2 agent to process
|
|
50
|
+
user queries and retrieve research papers.
|
|
51
|
+
|
|
52
|
+
Example:
|
|
53
|
+
>>> app = get_app("thread_123")
|
|
54
|
+
>>> result = app.invoke(initial_state)
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
def s2_agent_node(state: Talk2Scholars) -> dict[str, Any]:
|
|
58
|
+
"""
|
|
59
|
+
Processes the user query and retrieves relevant research papers.
|
|
60
|
+
|
|
61
|
+
This function calls the language model using the configured `ReAct` agent to analyze
|
|
62
|
+
the state and generate an appropriate response. The function then returns control
|
|
63
|
+
to the main supervisor.
|
|
64
|
+
|
|
65
|
+
Args:
|
|
66
|
+
state (Talk2Scholars): The current conversation state, including messages exchanged
|
|
67
|
+
and any previously retrieved research papers.
|
|
68
|
+
|
|
69
|
+
Returns:
|
|
70
|
+
Dict[str, Any]: A dictionary containing the updated conversation state.
|
|
71
|
+
|
|
72
|
+
Example:
|
|
73
|
+
>>> result = s2_agent_node(current_state)
|
|
74
|
+
>>> papers = result.get("papers", [])
|
|
75
|
+
"""
|
|
76
|
+
logger.log(logging.INFO, "Creating Agent_S2 node with thread_id %s", uniq_id)
|
|
77
|
+
result = model.invoke(state, {"configurable": {"thread_id": uniq_id}})
|
|
78
|
+
|
|
79
|
+
return result
|
|
80
|
+
|
|
81
|
+
logger.log(logging.INFO, "thread_id, llm_model: %s, %s", uniq_id, llm_model)
|
|
82
|
+
|
|
83
|
+
# Load hydra configuration
|
|
84
|
+
logger.log(logging.INFO, "Load Hydra configuration for Talk2Scholars S2 agent.")
|
|
85
|
+
with hydra.initialize(version_base=None, config_path="../configs"):
|
|
86
|
+
cfg = hydra.compose(
|
|
87
|
+
config_name="config", overrides=["agents/talk2scholars/s2_agent=default"]
|
|
88
|
+
)
|
|
89
|
+
cfg = cfg.agents.talk2scholars.s2_agent
|
|
90
|
+
logger.log(logging.INFO, "Loaded configuration for S2 agent")
|
|
91
|
+
|
|
92
|
+
# Define the tools
|
|
93
|
+
tools = ToolNode(
|
|
94
|
+
[
|
|
95
|
+
search_tool,
|
|
96
|
+
display_dataframe,
|
|
97
|
+
query_dataframe,
|
|
98
|
+
retrieve_semantic_scholar_paper_id,
|
|
99
|
+
get_single_paper_recommendations,
|
|
100
|
+
get_multi_paper_recommendations,
|
|
101
|
+
]
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
# Define the model
|
|
105
|
+
logger.log(logging.INFO, "Using OpenAI model %s", llm_model)
|
|
106
|
+
|
|
107
|
+
# Create the agent
|
|
108
|
+
model = create_react_agent(
|
|
109
|
+
llm_model,
|
|
110
|
+
tools=tools,
|
|
111
|
+
state_schema=Talk2Scholars,
|
|
112
|
+
prompt=cfg.s2_agent,
|
|
113
|
+
checkpointer=MemorySaver(),
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
workflow = StateGraph(Talk2Scholars)
|
|
117
|
+
workflow.add_node("s2_agent", s2_agent_node)
|
|
118
|
+
workflow.add_edge(START, "s2_agent")
|
|
119
|
+
|
|
120
|
+
# Initialize memory to persist state between graph runs
|
|
121
|
+
checkpointer = MemorySaver()
|
|
122
|
+
|
|
123
|
+
# Finally, we compile it!
|
|
124
|
+
# This compiles it into a LangChain Runnable,
|
|
125
|
+
# meaning you can use it as you would any other runnable.
|
|
126
|
+
# Note that we're (optionally) passing the memory when compiling the graph
|
|
127
|
+
app = workflow.compile(checkpointer=checkpointer, name="s2_agent")
|
|
128
|
+
logger.log(
|
|
129
|
+
logging.INFO,
|
|
130
|
+
"Compiled the graph with thread_id %s and llm_model %s",
|
|
131
|
+
uniq_id,
|
|
132
|
+
llm_model,
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
return app
|