aiagents4pharma 1.10.0__tar.gz → 1.12.0__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.
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/PKG-INFO +5 -6
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/README.md +2 -5
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2biomodels/agents/t2b_agent.py +7 -10
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2biomodels/models/basico_model.py +29 -32
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2biomodels/models/sys_bio_model.py +9 -6
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2biomodels/states/state_talk2biomodels.py +3 -3
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2biomodels/tests/test_basico_model.py +7 -8
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2biomodels/tests/test_langgraph.py +64 -2
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2biomodels/tests/test_sys_bio_model.py +13 -7
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2biomodels/tools/__init__.py +1 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2biomodels/tools/get_modelinfo.py +5 -3
- aiagents4pharma-1.12.0/aiagents4pharma/talk2biomodels/tools/parameter_scan.py +292 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2biomodels/tools/simulate_model.py +9 -11
- aiagents4pharma-1.12.0/aiagents4pharma/talk2knowledgegraphs/__init__.py +5 -0
- aiagents4pharma-1.12.0/aiagents4pharma/talk2knowledgegraphs/tests/test_utils_enrichments_enrichments.py +39 -0
- aiagents4pharma-1.12.0/aiagents4pharma/talk2knowledgegraphs/tests/test_utils_enrichments_ollama.py +117 -0
- aiagents4pharma-1.12.0/aiagents4pharma/talk2knowledgegraphs/utils/__init__.py +5 -0
- aiagents4pharma-1.12.0/aiagents4pharma/talk2knowledgegraphs/utils/enrichments/__init__.py +5 -0
- aiagents4pharma-1.12.0/aiagents4pharma/talk2knowledgegraphs/utils/enrichments/enrichments.py +36 -0
- aiagents4pharma-1.12.0/aiagents4pharma/talk2knowledgegraphs/utils/enrichments/ollama.py +123 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma.egg-info/PKG-INFO +5 -6
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma.egg-info/SOURCES.txt +7 -1
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma.egg-info/requires.txt +2 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/pyproject.toml +2 -0
- aiagents4pharma-1.12.0/release_version.txt +1 -0
- aiagents4pharma-1.10.0/aiagents4pharma/talk2knowledgegraphs/__init__.py +0 -4
- aiagents4pharma-1.10.0/aiagents4pharma/talk2knowledgegraphs/utils/__init__.py +0 -0
- aiagents4pharma-1.10.0/release_version.txt +0 -1
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/LICENSE +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/__init__.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/configs/__init__.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/configs/config.yaml +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/configs/talk2biomodels/__init__.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/configs/talk2biomodels/agents/__init__.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/configs/talk2biomodels/agents/t2b_agent/__init__.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/configs/talk2biomodels/agents/t2b_agent/default.yaml +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2biomodels/__init__.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2biomodels/agents/__init__.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2biomodels/models/__init__.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2biomodels/states/__init__.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2biomodels/tests/__init__.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2biomodels/tools/ask_question.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2biomodels/tools/custom_plotter.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2biomodels/tools/load_biomodel.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2biomodels/tools/search_models.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2cells/__init__.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2cells/agents/__init__.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2cells/agents/scp_agent.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2cells/states/__init__.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2cells/states/state_talk2cells.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2cells/tests/scp_agent/test_scp_agent.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2cells/tools/__init__.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2cells/tools/scp_agent/__init__.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2cells/tools/scp_agent/display_studies.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2cells/tools/scp_agent/search_studies.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2competitors/__init__.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2competitors/agents/__init__.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2competitors/agents/main_agent.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2competitors/agents/s2_agent.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2competitors/config/__init__.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2competitors/config/config.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2competitors/state/__init__.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2competitors/state/state_talk2competitors.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2competitors/tests/__init__.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2competitors/tests/test_langgraph.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2competitors/tools/__init__.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2competitors/tools/s2/__init__.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2competitors/tools/s2/display_results.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2competitors/tools/s2/multi_paper_rec.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2competitors/tools/s2/search.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2competitors/tools/s2/single_paper_rec.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2knowledgegraphs/datasets/__init__.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2knowledgegraphs/datasets/biobridge_primekg.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2knowledgegraphs/datasets/dataset.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2knowledgegraphs/datasets/primekg.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2knowledgegraphs/datasets/starkqa_primekg.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2knowledgegraphs/tests/__init__.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2knowledgegraphs/tests/test_datasets_biobridge_primekg.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2knowledgegraphs/tests/test_datasets_dataset.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2knowledgegraphs/tests/test_datasets_primekg.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2knowledgegraphs/tests/test_datasets_starkqa_primekg.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2knowledgegraphs/tests/test_utils_embeddings_embeddings.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2knowledgegraphs/tests/test_utils_embeddings_huggingface.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2knowledgegraphs/tests/test_utils_embeddings_sentencetransformer.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2knowledgegraphs/utils/embeddings/__init__.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2knowledgegraphs/utils/embeddings/embeddings.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2knowledgegraphs/utils/embeddings/huggingface.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2knowledgegraphs/utils/embeddings/sentence_transformer.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2knowledgegraphs/utils/kg_utils.py +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma.egg-info/dependency_links.txt +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma.egg-info/top_level.txt +0 -0
- {aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: aiagents4pharma
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.12.0
|
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
|
@@ -20,9 +20,11 @@ Requires-Dist: langchain-community==0.3.5
|
|
20
20
|
Requires-Dist: langchain-core==0.3.31
|
21
21
|
Requires-Dist: langchain-experimental==0.3.3
|
22
22
|
Requires-Dist: langchain-openai==0.2.5
|
23
|
+
Requires-Dist: langchain_ollama==0.2.2
|
23
24
|
Requires-Dist: langgraph==0.2.66
|
24
25
|
Requires-Dist: matplotlib==3.9.2
|
25
26
|
Requires-Dist: openai==1.59.4
|
27
|
+
Requires-Dist: ollama==0.4.6
|
26
28
|
Requires-Dist: pandas==2.2.3
|
27
29
|
Requires-Dist: plotly==5.24.1
|
28
30
|
Requires-Dist: pydantic==2.9.2
|
@@ -74,6 +76,7 @@ Our toolkit currently consists of three intelligent agents, each designed to sim
|
|
74
76
|
- Forward simulation of both internal and open-source models (BioModels).
|
75
77
|
- Adjust parameters within the model to simulate different conditions.
|
76
78
|
- Query simulation results.
|
79
|
+
- Extract model information such as species, parameters, units and description.
|
77
80
|
|
78
81
|
### 2. Talk2Cells _(Work in Progress)_
|
79
82
|
|
@@ -87,11 +90,7 @@ Our toolkit currently consists of three intelligent agents, each designed to sim
|
|
87
90
|
|
88
91
|
## Getting Started
|
89
92
|
|
90
|
-
|
91
|
-
|
92
|
-
- **Python 3.10+**
|
93
|
-
- **Git**
|
94
|
-
- Required libraries specified in `requirements.txt`
|
93
|
+

|
95
94
|
|
96
95
|
### Installation
|
97
96
|
|
@@ -28,6 +28,7 @@ Our toolkit currently consists of three intelligent agents, each designed to sim
|
|
28
28
|
- Forward simulation of both internal and open-source models (BioModels).
|
29
29
|
- Adjust parameters within the model to simulate different conditions.
|
30
30
|
- Query simulation results.
|
31
|
+
- Extract model information such as species, parameters, units and description.
|
31
32
|
|
32
33
|
### 2. Talk2Cells _(Work in Progress)_
|
33
34
|
|
@@ -41,11 +42,7 @@ Our toolkit currently consists of three intelligent agents, each designed to sim
|
|
41
42
|
|
42
43
|
## Getting Started
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
- **Python 3.10+**
|
47
|
-
- **Git**
|
48
|
-
- Required libraries specified in `requirements.txt`
|
45
|
+

|
49
46
|
|
50
47
|
### Installation
|
51
48
|
|
{aiagents4pharma-1.10.0 → aiagents4pharma-1.12.0}/aiagents4pharma/talk2biomodels/agents/t2b_agent.py
RENAMED
@@ -16,6 +16,7 @@ from ..tools.get_modelinfo import GetModelInfoTool
|
|
16
16
|
from ..tools.simulate_model import SimulateModelTool
|
17
17
|
from ..tools.custom_plotter import CustomPlotterTool
|
18
18
|
from ..tools.ask_question import AskQuestionTool
|
19
|
+
from ..tools.parameter_scan import ParameterScanTool
|
19
20
|
from ..states.state_talk2biomodels import Talk2Biomodels
|
20
21
|
|
21
22
|
# Initialize logger
|
@@ -35,17 +36,13 @@ def get_app(uniq_id, llm_model='gpt-4o-mini'):
|
|
35
36
|
return response
|
36
37
|
|
37
38
|
# Define the tools
|
38
|
-
simulate_model = SimulateModelTool()
|
39
|
-
custom_plotter = CustomPlotterTool()
|
40
|
-
ask_question = AskQuestionTool()
|
41
|
-
search_model = SearchModelsTool()
|
42
|
-
get_modelinfo = GetModelInfoTool()
|
43
39
|
tools = ToolNode([
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
40
|
+
SimulateModelTool(),
|
41
|
+
AskQuestionTool(),
|
42
|
+
CustomPlotterTool(),
|
43
|
+
SearchModelsTool(),
|
44
|
+
GetModelInfoTool(),
|
45
|
+
ParameterScanTool()
|
49
46
|
])
|
50
47
|
|
51
48
|
# Define the model
|
@@ -48,52 +48,49 @@ class BasicoModel(SysBioModel):
|
|
48
48
|
self.name = basico.model_info.get_model_name(model=self.copasi_model)
|
49
49
|
return self
|
50
50
|
|
51
|
-
def
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
def update_parameters(self, parameters: Dict[str, Union[float, int]]) -> None:
|
52
|
+
"""
|
53
|
+
Update model parameters with new values.
|
54
|
+
"""
|
55
|
+
# Update parameters in the model
|
56
|
+
for param_name, param_value in parameters.items():
|
57
|
+
# check if the param_name is not None
|
58
|
+
if param_name is None:
|
59
|
+
continue
|
60
|
+
# if param is a kinetic parameter
|
61
|
+
df_all_params = basico.model_info.get_parameters(model=self.copasi_model)
|
62
|
+
if param_name in df_all_params.index.tolist():
|
63
|
+
basico.model_info.set_parameters(name=param_name,
|
64
|
+
exact=True,
|
65
|
+
initial_value=param_value,
|
66
|
+
model=self.copasi_model)
|
67
|
+
# if param is a species
|
68
|
+
else:
|
69
|
+
basico.model_info.set_species(name=param_name,
|
70
|
+
exact=True,
|
71
|
+
initial_concentration=param_value,
|
72
|
+
model=self.copasi_model)
|
73
|
+
|
74
|
+
def simulate(self, duration: Union[int, float] = 10, interval: int = 10) -> pd.DataFrame:
|
56
75
|
"""
|
57
76
|
Simulate the COPASI model over a specified range of time points.
|
58
77
|
|
59
78
|
Args:
|
60
|
-
parameters: Dictionary of model parameters to update before simulation.
|
61
79
|
duration: Duration of the simulation in time units.
|
62
80
|
interval: Interval between time points in the simulation.
|
63
81
|
|
64
82
|
Returns:
|
65
83
|
Pandas DataFrame with time-course simulation results.
|
66
84
|
"""
|
67
|
-
|
68
|
-
# Update parameters in the model
|
69
|
-
if parameters:
|
70
|
-
for param_name, param_value in parameters.items():
|
71
|
-
# check if the param_name is not None
|
72
|
-
if param_name is None:
|
73
|
-
continue
|
74
|
-
# if param is a kinectic parameter
|
75
|
-
df_all_params = basico.model_info.get_parameters(model=self.copasi_model)
|
76
|
-
if param_name in df_all_params.index.tolist():
|
77
|
-
basico.model_info.set_parameters(name=param_name,
|
78
|
-
exact=True,
|
79
|
-
initial_value=param_value,
|
80
|
-
model=self.copasi_model)
|
81
|
-
# if param is a species
|
82
|
-
else:
|
83
|
-
basico.model_info.set_species(name=param_name,
|
84
|
-
exact=True,
|
85
|
-
initial_concentration=param_value,
|
86
|
-
model=self.copasi_model)
|
87
|
-
|
88
85
|
# Run the simulation and return results
|
89
86
|
df_result = basico.run_time_course(model=self.copasi_model,
|
90
87
|
intervals=interval,
|
91
88
|
duration=duration)
|
92
|
-
# Replace curly braces in column headers with square brackets
|
93
|
-
# Because curly braces in the world of LLMS are used for
|
94
|
-
# structured output
|
95
|
-
df_result.columns = df_result.columns.str.replace('{', '[', regex=False).\
|
96
|
-
|
89
|
+
# # Replace curly braces in column headers with square brackets
|
90
|
+
# # Because curly braces in the world of LLMS are used for
|
91
|
+
# # structured output
|
92
|
+
# df_result.columns = df_result.columns.str.replace('{', '[', regex=False).\
|
93
|
+
# str.replace('}', ']', regex=False)
|
97
94
|
# Reset the index
|
98
95
|
df_result.reset_index(inplace=True)
|
99
96
|
# Store the simulation results
|
@@ -35,18 +35,21 @@ class SysBioModel(ABC, BaseModel):
|
|
35
35
|
Returns:
|
36
36
|
dict: Dictionary with model metadata
|
37
37
|
"""
|
38
|
+
@abstractmethod
|
39
|
+
def update_parameters(self, parameters: Dict[str, Union[float, int]]) -> None:
|
40
|
+
"""
|
41
|
+
Abstract method to update model parameters.
|
42
|
+
|
43
|
+
Args:
|
44
|
+
parameters: Dictionary of parameter values.
|
45
|
+
"""
|
38
46
|
|
39
47
|
@abstractmethod
|
40
|
-
def simulate(self,
|
41
|
-
parameters: Dict[str, Union[float, int]],
|
42
|
-
duration: Union[int, float]) -> List[float]:
|
48
|
+
def simulate(self, duration: Union[int, float]) -> List[float]:
|
43
49
|
"""
|
44
50
|
Abstract method to run a simulation of the model.
|
45
|
-
This method should be implemented to simulate model
|
46
|
-
behavior based on the provided parameters.
|
47
51
|
|
48
52
|
Args:
|
49
|
-
parameters: Dictionary of parameter values.
|
50
53
|
duration: Duration of the simulation.
|
51
54
|
|
52
55
|
Returns:
|
@@ -12,13 +12,13 @@ class Talk2Biomodels(AgentState):
|
|
12
12
|
"""
|
13
13
|
The state for the Talk2BioModels agent.
|
14
14
|
"""
|
15
|
-
|
16
|
-
# sbml_file_path: str
|
15
|
+
llm_model: str
|
17
16
|
# A StateGraph may receive a concurrent updates
|
18
17
|
# which is not supported by the StateGraph.
|
19
18
|
# Therefore, we need to use Annotated to specify
|
20
19
|
# the operator for the sbml_file_path field.
|
21
20
|
# https://langchain-ai.github.io/langgraph/troubleshooting/errors/INVALID_CONCURRENT_GRAPH_UPDATE/
|
21
|
+
model_id: Annotated[list, operator.add]
|
22
22
|
sbml_file_path: Annotated[list, operator.add]
|
23
23
|
dic_simulated_data: Annotated[list[dict], operator.add]
|
24
|
-
|
24
|
+
dic_scanned_data: Annotated[list[dict], operator.add]
|
@@ -19,13 +19,14 @@ def test_with_biomodel_id(model):
|
|
19
19
|
Test initialization of BasicoModel with biomodel_id.
|
20
20
|
"""
|
21
21
|
assert model.biomodel_id == 64
|
22
|
+
model.update_parameters(parameters={'Pyruvate': 0.5, 'KmPFKF6P': 1.5})
|
23
|
+
df_species = basico.model_info.get_species(model=model.copasi_model)
|
24
|
+
assert df_species.loc['Pyruvate', 'initial_concentration'] == 0.5
|
25
|
+
df_parameters = basico.model_info.get_parameters(model=model.copasi_model)
|
26
|
+
assert df_parameters.loc['KmPFKF6P', 'initial_value'] == 1.5
|
22
27
|
# check if the simulation results are a pandas DataFrame object
|
23
|
-
assert isinstance(model.simulate(
|
24
|
-
|
25
|
-
interval=2),
|
26
|
-
pd.DataFrame)
|
27
|
-
assert isinstance(model.simulate(parameters={None: None}, duration=2, interval=2),
|
28
|
-
pd.DataFrame)
|
28
|
+
assert isinstance(model.simulate(duration=2, interval=2), pd.DataFrame)
|
29
|
+
model.update_parameters(parameters={None: None})
|
29
30
|
assert model.description == basico.biomodels.get_model_info(model.biomodel_id)["description"]
|
30
31
|
|
31
32
|
def test_with_sbml_file():
|
@@ -35,8 +36,6 @@ def test_with_sbml_file():
|
|
35
36
|
model_object = BasicoModel(sbml_file_path="./BIOMD0000000064_url.xml")
|
36
37
|
assert model_object.sbml_file_path == "./BIOMD0000000064_url.xml"
|
37
38
|
assert isinstance(model_object.simulate(duration=2, interval=2), pd.DataFrame)
|
38
|
-
assert isinstance(model_object.simulate(parameters={'NADH': 0.5}, duration=2, interval=2),
|
39
|
-
pd.DataFrame)
|
40
39
|
|
41
40
|
def test_check_biomodel_id_or_sbml_file_path():
|
42
41
|
'''
|
@@ -119,6 +119,68 @@ def test_simulate_model_tool():
|
|
119
119
|
# Check if the data of the second model contains
|
120
120
|
assert 'mTORC2' in dic_simulated_data[1]['data']
|
121
121
|
|
122
|
+
def test_param_scan_tool():
|
123
|
+
'''
|
124
|
+
In this test, we will test the parameter_scan tool.
|
125
|
+
We will prompt it to scan the parameter `kIL6RBind`
|
126
|
+
from 1 to 100 in steps of 10, record the changes
|
127
|
+
in the concentration of the species `Ab{serum}` in
|
128
|
+
model 537.
|
129
|
+
|
130
|
+
We will pass the inaccuarate parameter (`KIL6Rbind`)
|
131
|
+
and species names (just `Ab`) to the tool to test
|
132
|
+
if it can deal with it.
|
133
|
+
|
134
|
+
We expect the agent to first invoke the parameter_scan
|
135
|
+
tool and raise an error. It will then invoke another
|
136
|
+
tool get_modelinfo to get the correct parameter
|
137
|
+
and species names. Finally, the agent will reinvoke
|
138
|
+
the parameter_scan tool with the correct parameter
|
139
|
+
and species names.
|
140
|
+
|
141
|
+
'''
|
142
|
+
unique_id = 123
|
143
|
+
app = get_app(unique_id)
|
144
|
+
config = {"configurable": {"thread_id": unique_id}}
|
145
|
+
app.update_state(config, {"llm_model": "gpt-4o-mini"})
|
146
|
+
prompt = """How will the value of Ab in model 537 change
|
147
|
+
if the param kIL6Rbind is varied from 1 to 100 in steps of 10?
|
148
|
+
Set the initial `DoseQ2W` concentration to 300.
|
149
|
+
Reset the IL6{serum} concentration to 100 every 500 hours.
|
150
|
+
Assume that the model is simulated for 2016 hours with
|
151
|
+
an interval of 2016."""
|
152
|
+
# Invoke the agent
|
153
|
+
app.invoke(
|
154
|
+
{"messages": [HumanMessage(content=prompt)]},
|
155
|
+
config=config
|
156
|
+
)
|
157
|
+
current_state = app.get_state(config)
|
158
|
+
reversed_messages = current_state.values["messages"][::-1]
|
159
|
+
# Loop through the reversed messages until a
|
160
|
+
# ToolMessage is found.
|
161
|
+
df = pd.DataFrame(columns=['name', 'status', 'content'])
|
162
|
+
names = []
|
163
|
+
statuses = []
|
164
|
+
contents = []
|
165
|
+
for msg in reversed_messages:
|
166
|
+
# Assert that the message is a ToolMessage
|
167
|
+
# and its status is "error"
|
168
|
+
if not isinstance(msg, ToolMessage):
|
169
|
+
continue
|
170
|
+
names.append(msg.name)
|
171
|
+
statuses.append(msg.status)
|
172
|
+
contents.append(msg.content)
|
173
|
+
df = pd.DataFrame({'name': names, 'status': statuses, 'content': contents})
|
174
|
+
# print (df)
|
175
|
+
assert any((df["status"] == "error") &
|
176
|
+
(df["name"] == "parameter_scan") &
|
177
|
+
(df["content"].str.startswith("Error: ValueError('Invalid parameter name:")))
|
178
|
+
assert any((df["status"] == "success") &
|
179
|
+
(df["name"] == "parameter_scan") &
|
180
|
+
(df["content"].str.startswith("Parameter scan results of")))
|
181
|
+
assert any((df["status"] == "success") &
|
182
|
+
(df["name"] == "get_modelinfo"))
|
183
|
+
|
122
184
|
def test_integration():
|
123
185
|
'''
|
124
186
|
Test the integration of the tools.
|
@@ -184,9 +246,9 @@ def test_integration():
|
|
184
246
|
reversed_messages = current_state.values["messages"][::-1]
|
185
247
|
# Loop through the reversed messages
|
186
248
|
# until a ToolMessage is found.
|
187
|
-
expected_header = ['Time', 'CRP
|
249
|
+
expected_header = ['Time', 'CRP{serum}', 'CRPExtracellular']
|
188
250
|
expected_header += ['CRP Suppression (%)', 'CRP (% of baseline)']
|
189
|
-
expected_header += ['CRP
|
251
|
+
expected_header += ['CRP{liver}']
|
190
252
|
predicted_artifact = []
|
191
253
|
for msg in reversed_messages:
|
192
254
|
if isinstance(msg, ToolMessage):
|
@@ -16,6 +16,8 @@ class TestBioModel(SysBioModel):
|
|
16
16
|
sbml_file_path: Optional[str] = Field(None, description="Path to an SBML file")
|
17
17
|
name: Optional[str] = Field(..., description="Name of the model")
|
18
18
|
description: Optional[str] = Field("", description="Description of the model")
|
19
|
+
param1: Optional[float] = Field(0.0, description="Parameter 1")
|
20
|
+
param2: Optional[float] = Field(0.0, description="Parameter 2")
|
19
21
|
|
20
22
|
def get_model_metadata(self) -> Dict[str, Union[str, int]]:
|
21
23
|
'''
|
@@ -23,15 +25,18 @@ class TestBioModel(SysBioModel):
|
|
23
25
|
'''
|
24
26
|
return self.biomodel_id
|
25
27
|
|
26
|
-
def
|
27
|
-
|
28
|
-
|
28
|
+
def update_parameters(self, parameters):
|
29
|
+
'''
|
30
|
+
Update the model parameters.
|
31
|
+
'''
|
32
|
+
self.param1 = parameters.get('param1', 0.0)
|
33
|
+
self.param2 = parameters.get('param2', 0.0)
|
34
|
+
|
35
|
+
def simulate(self, duration: Union[int, float]) -> List[float]:
|
29
36
|
'''
|
30
37
|
Simulate the model.
|
31
38
|
'''
|
32
|
-
param1
|
33
|
-
param2 = parameters.get('param2', 0.0)
|
34
|
-
return [param1 + param2 * t for t in range(int(duration))]
|
39
|
+
return [self.param1 + self.param2 * t for t in range(int(duration))]
|
35
40
|
|
36
41
|
def test_get_model_metadata():
|
37
42
|
'''
|
@@ -53,5 +58,6 @@ def test_simulate():
|
|
53
58
|
Test the simulate method of the BioModel class.
|
54
59
|
'''
|
55
60
|
model = TestBioModel(biomodel_id=123, name="Test Model", description="A test model")
|
56
|
-
|
61
|
+
model.update_parameters({'param1': 1.0, 'param2': 2.0})
|
62
|
+
results = model.simulate(duration=4.0)
|
57
63
|
assert results == [1.0, 3.0, 5.0, 7.0]
|
@@ -47,8 +47,10 @@ class GetModelInfoTool(BaseTool):
|
|
47
47
|
"""
|
48
48
|
This tool ise used extract model information.
|
49
49
|
"""
|
50
|
-
name: str = "
|
51
|
-
description: str = "A tool for extracting
|
50
|
+
name: str = "get_modelinfo"
|
51
|
+
description: str = """A tool for extracting name,
|
52
|
+
description, species, parameters,
|
53
|
+
compartments, and units from a model."""
|
52
54
|
args_schema: Type[BaseModel] = GetModelInfoInput
|
53
55
|
|
54
56
|
def _run(self,
|
@@ -81,7 +83,7 @@ class GetModelInfoTool(BaseTool):
|
|
81
83
|
# Extract species from the model
|
82
84
|
if requested_model_info.species:
|
83
85
|
df_species = basico.model_info.get_species(model=model_obj.copasi_model)
|
84
|
-
dic_results['Species'] = df_species.
|
86
|
+
dic_results['Species'] = df_species['display_name'].tolist()
|
85
87
|
dic_results['Species'] = ','.join(dic_results['Species'])
|
86
88
|
|
87
89
|
# Extract parameters from the model
|