aiagents4pharma 1.14.1__tar.gz → 1.15.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/PKG-INFO +2 -1
  2. aiagents4pharma-1.15.1/aiagents4pharma/configs/talk2biomodels/agents/t2b_agent/default.yaml +14 -0
  3. aiagents4pharma-1.15.1/aiagents4pharma/configs/talk2biomodels/tools/ask_question/default.yaml +39 -0
  4. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/agents/t2b_agent.py +3 -1
  5. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/states/state_talk2biomodels.py +1 -0
  6. aiagents4pharma-1.15.1/aiagents4pharma/talk2biomodels/tests/test_query_article.py +76 -0
  7. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/tools/__init__.py +1 -0
  8. aiagents4pharma-1.15.1/aiagents4pharma/talk2biomodels/tools/query_article.py +59 -0
  9. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma.egg-info/PKG-INFO +2 -1
  10. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma.egg-info/SOURCES.txt +3 -0
  11. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma.egg-info/requires.txt +1 -0
  12. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/pyproject.toml +4 -1
  13. aiagents4pharma-1.15.1/release_version.txt +1 -0
  14. aiagents4pharma-1.14.1/aiagents4pharma/configs/talk2biomodels/agents/t2b_agent/default.yaml +0 -8
  15. aiagents4pharma-1.14.1/release_version.txt +0 -1
  16. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/LICENSE +0 -0
  17. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/README.md +0 -0
  18. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/__init__.py +0 -0
  19. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/configs/__init__.py +0 -0
  20. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/configs/config.yaml +0 -0
  21. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/configs/talk2biomodels/__init__.py +0 -0
  22. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/configs/talk2biomodels/agents/__init__.py +0 -0
  23. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/configs/talk2biomodels/agents/t2b_agent/__init__.py +0 -0
  24. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/configs/talk2biomodels/tools/__init__.py +0 -0
  25. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/configs/talk2biomodels/tools/ask_question/__init__.py +0 -0
  26. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/__init__.py +0 -0
  27. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/agents/__init__.py +0 -0
  28. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/api/__init__.py +0 -0
  29. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/api/kegg.py +0 -0
  30. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/api/ols.py +0 -0
  31. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/api/uniprot.py +0 -0
  32. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/models/__init__.py +0 -0
  33. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/models/basico_model.py +0 -0
  34. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/models/sys_bio_model.py +0 -0
  35. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/states/__init__.py +0 -0
  36. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/tests/__init__.py +0 -0
  37. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/tests/test_api.py +0 -0
  38. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/tests/test_ask_question.py +0 -0
  39. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/tests/test_basico_model.py +0 -0
  40. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/tests/test_get_annotation.py +0 -0
  41. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/tests/test_getmodelinfo.py +0 -0
  42. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/tests/test_integration.py +0 -0
  43. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/tests/test_param_scan.py +0 -0
  44. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/tests/test_search_models.py +0 -0
  45. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/tests/test_simulate_model.py +0 -0
  46. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/tests/test_steady_state.py +0 -0
  47. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/tests/test_sys_bio_model.py +0 -0
  48. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/tools/ask_question.py +0 -0
  49. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/tools/custom_plotter.py +0 -0
  50. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/tools/get_annotation.py +0 -0
  51. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/tools/get_modelinfo.py +0 -0
  52. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/tools/load_arguments.py +0 -0
  53. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/tools/load_biomodel.py +0 -0
  54. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/tools/parameter_scan.py +0 -0
  55. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/tools/search_models.py +0 -0
  56. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/tools/simulate_model.py +0 -0
  57. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2biomodels/tools/steady_state.py +0 -0
  58. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2cells/__init__.py +0 -0
  59. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2cells/agents/__init__.py +0 -0
  60. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2cells/agents/scp_agent.py +0 -0
  61. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2cells/states/__init__.py +0 -0
  62. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2cells/states/state_talk2cells.py +0 -0
  63. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2cells/tests/scp_agent/test_scp_agent.py +0 -0
  64. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2cells/tools/__init__.py +0 -0
  65. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2cells/tools/scp_agent/__init__.py +0 -0
  66. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2cells/tools/scp_agent/display_studies.py +0 -0
  67. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2cells/tools/scp_agent/search_studies.py +0 -0
  68. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2competitors/__init__.py +0 -0
  69. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2competitors/agents/__init__.py +0 -0
  70. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2competitors/agents/main_agent.py +0 -0
  71. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2competitors/agents/s2_agent.py +0 -0
  72. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2competitors/config/__init__.py +0 -0
  73. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2competitors/config/config.py +0 -0
  74. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2competitors/state/__init__.py +0 -0
  75. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2competitors/state/state_talk2competitors.py +0 -0
  76. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2competitors/tests/__init__.py +0 -0
  77. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2competitors/tests/test_langgraph.py +0 -0
  78. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2competitors/tools/__init__.py +0 -0
  79. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2competitors/tools/s2/__init__.py +0 -0
  80. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2competitors/tools/s2/display_results.py +0 -0
  81. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2competitors/tools/s2/multi_paper_rec.py +0 -0
  82. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2competitors/tools/s2/search.py +0 -0
  83. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2competitors/tools/s2/single_paper_rec.py +0 -0
  84. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2knowledgegraphs/__init__.py +0 -0
  85. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2knowledgegraphs/datasets/__init__.py +0 -0
  86. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2knowledgegraphs/datasets/biobridge_primekg.py +0 -0
  87. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2knowledgegraphs/datasets/dataset.py +0 -0
  88. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2knowledgegraphs/datasets/primekg.py +0 -0
  89. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2knowledgegraphs/datasets/starkqa_primekg.py +0 -0
  90. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2knowledgegraphs/tests/__init__.py +0 -0
  91. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2knowledgegraphs/tests/test_datasets_biobridge_primekg.py +0 -0
  92. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2knowledgegraphs/tests/test_datasets_dataset.py +0 -0
  93. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2knowledgegraphs/tests/test_datasets_primekg.py +0 -0
  94. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2knowledgegraphs/tests/test_datasets_starkqa_primekg.py +0 -0
  95. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2knowledgegraphs/tests/test_utils_embeddings_embeddings.py +0 -0
  96. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2knowledgegraphs/tests/test_utils_embeddings_huggingface.py +0 -0
  97. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2knowledgegraphs/tests/test_utils_embeddings_sentencetransformer.py +0 -0
  98. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2knowledgegraphs/tests/test_utils_enrichments_enrichments.py +0 -0
  99. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2knowledgegraphs/tests/test_utils_enrichments_ollama.py +0 -0
  100. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2knowledgegraphs/utils/__init__.py +0 -0
  101. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2knowledgegraphs/utils/embeddings/__init__.py +0 -0
  102. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2knowledgegraphs/utils/embeddings/embeddings.py +0 -0
  103. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2knowledgegraphs/utils/embeddings/huggingface.py +0 -0
  104. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2knowledgegraphs/utils/embeddings/sentence_transformer.py +0 -0
  105. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2knowledgegraphs/utils/enrichments/__init__.py +0 -0
  106. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2knowledgegraphs/utils/enrichments/enrichments.py +0 -0
  107. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2knowledgegraphs/utils/enrichments/ollama.py +0 -0
  108. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma/talk2knowledgegraphs/utils/kg_utils.py +0 -0
  109. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma.egg-info/dependency_links.txt +0 -0
  110. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/aiagents4pharma.egg-info/top_level.txt +0 -0
  111. {aiagents4pharma-1.14.1 → aiagents4pharma-1.15.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: aiagents4pharma
3
- Version: 1.14.1
3
+ Version: 1.15.1
4
4
  Summary: AI Agents for drug discovery, drug development, and other pharmaceutical R&D
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -29,6 +29,7 @@ Requires-Dist: pandas==2.2.3
29
29
  Requires-Dist: plotly==5.24.1
30
30
  Requires-Dist: pydantic==2.9.2
31
31
  Requires-Dist: pylint==3.3.1
32
+ Requires-Dist: pypdf==5.2.0
32
33
  Requires-Dist: pytest==8.3.3
33
34
  Requires-Dist: pytest-asyncio==0.25.2
34
35
  Requires-Dist: streamlit==1.39.0
@@ -0,0 +1,14 @@
1
+ _target_: talk2biomodels.agents.t2b_agent.get_app
2
+ state_modifier: >
3
+ You are Talk2BioModels agent.
4
+ If the user asks for the uploaded model,
5
+ then pass the use_uploaded_model argument
6
+ as True. If the user asks for simulation
7
+ or param_scan or steady state, suggest a
8
+ value for the `experiment_name` argument.
9
+
10
+ If the user asks question related to the
11
+ uploaded document/pdf/article/document,
12
+ use the tool `query_article` to answer the
13
+ question. Please note that the `experiment_name`
14
+ argument may be unrelated to the question asked.
@@ -0,0 +1,39 @@
1
+ _target_: talk2biomodels.tools.ask_question.AskQuestionTool
2
+ steady_state_prompt: >
3
+ Following are header columns of the data:
4
+ `species_name`: Name of the species,
5
+ `compartment`: Compartment of the species,
6
+ `initial_concentration`: Concentration of the species at the start of steady state,
7
+ `steady_state_concentration`: Concentration of the species at steady state,
8
+ `steady_state_transition_time`: Time taken to reach steady state,
9
+ `display_name`: An alias for the species name.
10
+
11
+ Here are some instructions to help you answer questions:
12
+
13
+ 1. Before you answer any question, follow the plan and solve
14
+ technique. Start by understanding the question, then plan your
15
+ approach to solve the question, and finally solve the question
16
+ by following the plan. Always give a brief explanation of your
17
+ answer to the user.
18
+
19
+ 2. If the user wants to know the time taken by the model to reach
20
+ steady state, you should look at the steady_state_transition_time
21
+ column of the data for the model species. The highest value in
22
+ this column is the time taken by the model to reach steady state.
23
+
24
+ 3. To get accurate results, trim the data to the relevant columns
25
+ before performing any calculations. This will help you avoid
26
+ errors in your calculations, and ignore irrelevant data.
27
+
28
+ 4. Please use the units provided below to answer the questions.
29
+ simulation_prompt: >
30
+ Following is the information about the data frame:
31
+ 1. First column is the time column, and the rest of the columns
32
+ are the species names.
33
+
34
+ 2. While the time column records the simulation time points, the
35
+ rest of the columns record the concentration of the species at
36
+ each time point.
37
+
38
+ 3. Please use the units provided below to answer the questions.
39
+
@@ -19,6 +19,7 @@ from ..tools.get_annotation import GetAnnotationTool
19
19
  from ..tools.ask_question import AskQuestionTool
20
20
  from ..tools.parameter_scan import ParameterScanTool
21
21
  from ..tools.steady_state import SteadyStateTool
22
+ from ..tools.query_article import QueryArticle
22
23
  from ..states.state_talk2biomodels import Talk2Biomodels
23
24
 
24
25
  # Initialize logger
@@ -46,7 +47,8 @@ def get_app(uniq_id, llm_model='gpt-4o-mini'):
46
47
  GetModelInfoTool(),
47
48
  SteadyStateTool(),
48
49
  ParameterScanTool(),
49
- GetAnnotationTool()
50
+ GetAnnotationTool(),
51
+ QueryArticle()
50
52
  ])
51
53
 
52
54
  # Define the model
@@ -27,6 +27,7 @@ class Talk2Biomodels(AgentState):
27
27
  The state for the Talk2BioModels agent.
28
28
  """
29
29
  llm_model: str
30
+ pdf_file_name: str
30
31
  # A StateGraph may receive a concurrent updates
31
32
  # which is not supported by the StateGraph. Hence,
32
33
  # we need to add a reducer function to handle the
@@ -0,0 +1,76 @@
1
+ '''
2
+ Test cases for Talk2Biomodels query_article tool.
3
+ '''
4
+
5
+ from pydantic import BaseModel, Field
6
+ from langchain_core.messages import HumanMessage, ToolMessage
7
+ from langchain_openai import ChatOpenAI
8
+ from ..agents.t2b_agent import get_app
9
+
10
+ class Article(BaseModel):
11
+ '''
12
+ Article schema.
13
+ '''
14
+ title: str = Field(description="Title of the article.")
15
+
16
+ def test_query_article_with_an_article():
17
+ '''
18
+ Test the query_article tool by providing an article.
19
+ '''
20
+ unique_id = 12345
21
+ app = get_app(unique_id)
22
+ config = {"configurable": {"thread_id": unique_id}}
23
+ # Update state by providing the pdf file name
24
+ app.update_state(config,
25
+ {"pdf_file_name": "aiagents4pharma/talk2biomodels/tests/article_on_model_537.pdf"})
26
+ prompt = "What is the title of the article?"
27
+ # Test the tool query_article
28
+ response = app.invoke(
29
+ {"messages": [HumanMessage(content=prompt)]},
30
+ config=config
31
+ )
32
+ # Get the response from the tool
33
+ assistant_msg = response["messages"][-1].content
34
+ # Prepare a LLM that can be used as a judge
35
+ llm = ChatOpenAI(model='gpt-4o-mini', temperature=0)
36
+ # Make it return a structured output
37
+ structured_llm = llm.with_structured_output(Article)
38
+ # Prepare a prompt for the judge
39
+ prompt = "Given the text below, what is the title of the article?"
40
+ prompt += f"\n\n{assistant_msg}"
41
+ # Get the structured output
42
+ article = structured_llm.invoke(prompt)
43
+ # Check if the article title is correct
44
+ expected_title = "A Multiscale Model of IL-6–Mediated "
45
+ expected_title += "Immune Regulation in Crohn’s Disease"
46
+ # Check if the article title is correct
47
+ assert article.title == expected_title
48
+
49
+ def test_query_article_without_an_article():
50
+ '''
51
+ Test the query_article tool without providing an article.
52
+ The status of the tool should be error.
53
+ '''
54
+ unique_id = 12345
55
+ app = get_app(unique_id)
56
+ config = {"configurable": {"thread_id": unique_id}}
57
+ prompt = "What is the title of the uploaded article?"
58
+ # Test the tool query_article
59
+ app.invoke(
60
+ {"messages": [HumanMessage(content=prompt)]},
61
+ config=config
62
+ )
63
+ current_state = app.get_state(config)
64
+ # Get the messages from the current state
65
+ # and reverse the order
66
+ reversed_messages = current_state.values["messages"][::-1]
67
+ # Loop through the reversed messages
68
+ # until a ToolMessage is found.
69
+ tool_status_is_error = False
70
+ for msg in reversed_messages:
71
+ if isinstance(msg, ToolMessage):
72
+ # Skip until it finds a ToolMessage
73
+ if msg.name == "query_article" and msg.status == "error":
74
+ tool_status_is_error = True
75
+ break
76
+ assert tool_status_is_error
@@ -10,3 +10,4 @@ from . import parameter_scan
10
10
  from . import steady_state
11
11
  from . import load_biomodel
12
12
  from . import get_annotation
13
+ from . import query_article
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env python3
2
+
3
+ """
4
+ Tool for asking questions to the article.
5
+ """
6
+
7
+ import logging
8
+ from typing import Type, Annotated
9
+ from pydantic import BaseModel, Field
10
+ from langchain_core.tools import BaseTool
11
+ from langchain_core.vectorstores import InMemoryVectorStore
12
+ from langchain_openai.embeddings import OpenAIEmbeddings
13
+ from langchain_community.document_loaders import PyPDFLoader
14
+ from langgraph.prebuilt import InjectedState
15
+
16
+ # Initialize logger
17
+ logging.basicConfig(level=logging.INFO)
18
+ logger = logging.getLogger(__name__)
19
+
20
+ class QueryArticleInput(BaseModel):
21
+ """
22
+ Input schema for the query_articles tool.
23
+ """
24
+ question: Annotated[str, Field(description="User question to search articles.")]
25
+ state: Annotated[dict, InjectedState]
26
+
27
+ # Note: It's important that every field has type hints. BaseTool is a
28
+ # Pydantic class and not having type hints can lead to unexpected behavior.
29
+ class QueryArticle(BaseTool):
30
+ """
31
+ Tool to ask questions to the article.
32
+ """
33
+ name: str = "query_article"
34
+ description: str = "Ask questions to the article."
35
+ args_schema: Type[BaseModel] = QueryArticleInput
36
+
37
+ def _run(self,
38
+ question: str,
39
+ state: Annotated[dict, InjectedState]):
40
+ """
41
+ Run the tool.
42
+
43
+ Args:
44
+ query (str): The search query.
45
+ """
46
+ logger.log(logging.INFO, "loading the article from %s", state['pdf_file_name'])
47
+ logger.log(logging.INFO, "searching the article with the question: %s", question)
48
+ # Load the article
49
+ loader = PyPDFLoader(state['pdf_file_name'])
50
+ # Load the pages of the article
51
+ pages = []
52
+ for page in loader.lazy_load():
53
+ pages.append(page)
54
+ # Create a vector store from the pages
55
+ vector_store = InMemoryVectorStore.from_documents(pages, OpenAIEmbeddings())
56
+ # Search the article with the question
57
+ docs = vector_store.similarity_search(question)
58
+ # Return the content of the pages
59
+ return "\n".join([doc.page_content for doc in docs])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: aiagents4pharma
3
- Version: 1.14.1
3
+ Version: 1.15.1
4
4
  Summary: AI Agents for drug discovery, drug development, and other pharmaceutical R&D
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -29,6 +29,7 @@ Requires-Dist: pandas==2.2.3
29
29
  Requires-Dist: plotly==5.24.1
30
30
  Requires-Dist: pydantic==2.9.2
31
31
  Requires-Dist: pylint==3.3.1
32
+ Requires-Dist: pypdf==5.2.0
32
33
  Requires-Dist: pytest==8.3.3
33
34
  Requires-Dist: pytest-asyncio==0.25.2
34
35
  Requires-Dist: streamlit==1.39.0
@@ -16,6 +16,7 @@ aiagents4pharma/configs/talk2biomodels/agents/t2b_agent/__init__.py
16
16
  aiagents4pharma/configs/talk2biomodels/agents/t2b_agent/default.yaml
17
17
  aiagents4pharma/configs/talk2biomodels/tools/__init__.py
18
18
  aiagents4pharma/configs/talk2biomodels/tools/ask_question/__init__.py
19
+ aiagents4pharma/configs/talk2biomodels/tools/ask_question/default.yaml
19
20
  aiagents4pharma/talk2biomodels/__init__.py
20
21
  aiagents4pharma/talk2biomodels/agents/__init__.py
21
22
  aiagents4pharma/talk2biomodels/agents/t2b_agent.py
@@ -36,6 +37,7 @@ aiagents4pharma/talk2biomodels/tests/test_get_annotation.py
36
37
  aiagents4pharma/talk2biomodels/tests/test_getmodelinfo.py
37
38
  aiagents4pharma/talk2biomodels/tests/test_integration.py
38
39
  aiagents4pharma/talk2biomodels/tests/test_param_scan.py
40
+ aiagents4pharma/talk2biomodels/tests/test_query_article.py
39
41
  aiagents4pharma/talk2biomodels/tests/test_search_models.py
40
42
  aiagents4pharma/talk2biomodels/tests/test_simulate_model.py
41
43
  aiagents4pharma/talk2biomodels/tests/test_steady_state.py
@@ -48,6 +50,7 @@ aiagents4pharma/talk2biomodels/tools/get_modelinfo.py
48
50
  aiagents4pharma/talk2biomodels/tools/load_arguments.py
49
51
  aiagents4pharma/talk2biomodels/tools/load_biomodel.py
50
52
  aiagents4pharma/talk2biomodels/tools/parameter_scan.py
53
+ aiagents4pharma/talk2biomodels/tools/query_article.py
51
54
  aiagents4pharma/talk2biomodels/tools/search_models.py
52
55
  aiagents4pharma/talk2biomodels/tools/simulate_model.py
53
56
  aiagents4pharma/talk2biomodels/tools/steady_state.py
@@ -19,6 +19,7 @@ pandas==2.2.3
19
19
  plotly==5.24.1
20
20
  pydantic==2.9.2
21
21
  pylint==3.3.1
22
+ pypdf==5.2.0
22
23
  pytest==8.3.3
23
24
  pytest-asyncio==0.25.2
24
25
  streamlit==1.39.0
@@ -34,6 +34,7 @@ dependencies = [
34
34
  "plotly==5.24.1",
35
35
  "pydantic==2.9.2",
36
36
  "pylint==3.3.1",
37
+ "pypdf==5.2.0",
37
38
  "pytest==8.3.3",
38
39
  "pytest-asyncio==0.25.2",
39
40
  "streamlit==1.39.0",
@@ -67,7 +68,9 @@ include = ["aiagents4pharma*"]
67
68
  [tool.setuptools.package-data]
68
69
  aiagents4pharma = [
69
70
  "configs/*",
70
- "configs/talk2biomodels/agents/t2b_agent/*"]
71
+ "configs/talk2biomodels/agents/t2b_agent/*",
72
+ "configs/talk2biomodels/tools/ask_question/*",
73
+ "configs/talk2biomodels/tools/get_annotation/*"]
71
74
 
72
75
  [tool.pytest.ini_options]
73
76
  asyncio_default_fixture_loop_scope = "function"
@@ -0,0 +1 @@
1
+ v1.15.1
@@ -1,8 +0,0 @@
1
- _target_: talk2biomodels.agents.t2b_agent.get_app
2
- state_modifier: >
3
- You are Talk2BioModels agent.
4
- If the user asks for the uploaded model,
5
- then pass the use_uploaded_model argument
6
- as True. If the user asks for simulation
7
- or param_scan or steady state, suggest a
8
- value for the `experiment_name` argument.
@@ -1 +0,0 @@
1
- v1.14.1