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