aiagents4pharma 1.4.1__py3-none-any.whl → 1.4.2__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.
@@ -1,7 +1,10 @@
1
1
  '''
2
2
  This file is used to import all the modules in the package.
3
3
  '''
4
+ # import everything from the module
5
+ from . import ask_question
4
6
  from . import simulate_model
7
+ from . import custom_plotter
8
+ from . import fetch_parameters
5
9
  from . import model_description
6
- from . import ask_question
7
- from . import plot_figure
10
+ from . import search_models
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aiagents4pharma
3
- Version: 1.4.1
3
+ Version: 1.4.2
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
@@ -3,16 +3,15 @@ aiagents4pharma/talk2biomodels/__init__.py,sha256=MueXwbnuiQyiju7mW6NepFUiZJdodM
3
3
  aiagents4pharma/talk2biomodels/models/__init__.py,sha256=5fTHHm3PVloYPNKXbgNlcPgv3-u28ZquxGydFYDfhJA,122
4
4
  aiagents4pharma/talk2biomodels/models/basico_model.py,sha256=SC9rFzLWzNxcQueAduL3dBmDh-lTtP1agH-TXjucOkw,4199
5
5
  aiagents4pharma/talk2biomodels/models/sys_bio_model.py,sha256=xN-ZXCpIxNkEXuDIvi_AW6LpCyPqXReGyhLPyJIXNqs,1980
6
- aiagents4pharma/talk2biomodels/tools/__init__.py,sha256=AM03pbYT3nOzI5jf_CJmSDaDwrI-IZ0Zq9hLA2tOXpw,182
6
+ aiagents4pharma/talk2biomodels/tools/__init__.py,sha256=qO3MYCJmXpoUlZYtSW3VxTXdt-yUNHyH-Ua578pdyhg,280
7
7
  aiagents4pharma/talk2biomodels/tools/ask_question.py,sha256=o9ae4s3wsDFr_pGBU1cSxKhJ7E2yjybIzG1Y4z6957Y,4534
8
8
  aiagents4pharma/talk2biomodels/tools/custom_plotter.py,sha256=CdgJjlHAkdyjnwPD6nHARsJXnx_CE0MWg5VOz4oBjY0,2910
9
9
  aiagents4pharma/talk2biomodels/tools/fetch_parameters.py,sha256=levr42F-m53Oya8VTbLlvLJt1snNgnIlSHs4JDiNAv8,2063
10
10
  aiagents4pharma/talk2biomodels/tools/model_description.py,sha256=lcVKVvh50wJ4BmB7xMnTZOtWjCmQUnkh6TQJsX-IjGw,5338
11
- aiagents4pharma/talk2biomodels/tools/plot_figure.py,sha256=S_d8nNy7NVSBIqnDhg6ex_AdaMqUmVX8D1qOjRGe3r8,5594
12
11
  aiagents4pharma/talk2biomodels/tools/search_models.py,sha256=5qmgQcwlICYAFG11y-aEhBSeYYT6Lu6AKGL2V-p1ggQ,2685
13
12
  aiagents4pharma/talk2biomodels/tools/simulate_model.py,sha256=MxlAy62SuonBbEbKmoUz0HcdfTWvk-x9WMSo17dBU9U,7552
14
- aiagents4pharma-1.4.1.dist-info/LICENSE,sha256=IcIbyB1Hyk5ZDah03VNQvJkbNk2hkBCDqQ8qtnCvB4Q,1077
15
- aiagents4pharma-1.4.1.dist-info/METADATA,sha256=Fh-G93O_d49FDuMV7nqQ0sGhwglioxFYiAJUTOWTPwI,6640
16
- aiagents4pharma-1.4.1.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
17
- aiagents4pharma-1.4.1.dist-info/top_level.txt,sha256=-AH8rMmrSnJtq7HaAObS78UU-cTCwvX660dSxeM7a0A,16
18
- aiagents4pharma-1.4.1.dist-info/RECORD,,
13
+ aiagents4pharma-1.4.2.dist-info/LICENSE,sha256=IcIbyB1Hyk5ZDah03VNQvJkbNk2hkBCDqQ8qtnCvB4Q,1077
14
+ aiagents4pharma-1.4.2.dist-info/METADATA,sha256=pUu7r6zAXbTuN-yGiPCV-BRje7cNLbRkfOsDEDJQ2PQ,6640
15
+ aiagents4pharma-1.4.2.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
16
+ aiagents4pharma-1.4.2.dist-info/top_level.txt,sha256=-AH8rMmrSnJtq7HaAObS78UU-cTCwvX660dSxeM7a0A,16
17
+ aiagents4pharma-1.4.2.dist-info/RECORD,,
@@ -1,135 +0,0 @@
1
- #!/usr/bin/env python3
2
-
3
- """
4
- Tool for plotting a figure.
5
- """
6
-
7
- from typing import Type, Optional
8
- from dataclasses import dataclass
9
- import matplotlib.pyplot as plt
10
- from pydantic import BaseModel, Field
11
- import streamlit as st
12
- from langchain_openai import ChatOpenAI
13
- from langchain_core.tools import BaseTool
14
- from langchain_core.prompts import ChatPromptTemplate
15
- from langchain_core.output_parsers.openai_tools import JsonOutputKeyToolsParser
16
- from langchain_experimental.tools import PythonAstREPLTool
17
- from ..models.basico_model import BasicoModel
18
-
19
- @dataclass
20
- class ModelData:
21
- """
22
- Dataclass for storing the model data.
23
- """
24
- modelid: Optional[int] = None
25
- sbml_file_path: Optional[str] = None
26
- model_object: Optional[BasicoModel] = None
27
-
28
- class PlotImageInput(BaseModel):
29
- """
30
- Input schema for the PlotImage tool.
31
- """
32
- question: str = Field(description="Description of the plot")
33
- sys_bio_model: ModelData = Field(description="model data", default=None)
34
-
35
- # Note: It's important that every field has type hints. BaseTool is a
36
- # Pydantic class and not having type hints can lead to unexpected behavior.
37
- class PlotImageTool(BaseTool):
38
- """
39
- Tool for plotting a figure.
40
- """
41
- name: str = "plot_figure"
42
- description: str = "A tool to plot or visualize the simulation results."
43
- args_schema: Type[BaseModel] = PlotImageInput
44
- st_session_key: str = None
45
-
46
- def _run(self,
47
- question: str,
48
- sys_bio_model: ModelData = ModelData()) -> str:
49
- """
50
- Run the tool.
51
-
52
- Args:
53
- question (str): The question to ask about the model description.
54
- sys_bio_model (ModelData): The model data.
55
-
56
- Returns:
57
- str: The answer to the question
58
- """
59
- st_session_key = self.st_session_key
60
- # Check if sys_bio_model is provided
61
- if sys_bio_model.modelid or sys_bio_model.sbml_file_path or sys_bio_model.model_object:
62
- if sys_bio_model.modelid:
63
- model_object = BasicoModel(model_id=sys_bio_model.modelid)
64
- elif sys_bio_model.sbml_file_path:
65
- model_object = BasicoModel(sbml_file_path=sys_bio_model.sbml_file_path)
66
- else:
67
- model_object = sys_bio_model.model_object
68
- if st_session_key:
69
- st.session_state[st_session_key] = model_object
70
- else:
71
- # If the model_object is not provided,
72
- # get it from the Streamlit session state
73
- if st_session_key:
74
- if st_session_key not in st.session_state:
75
- return f"Session key {st_session_key} not found in Streamlit session state."
76
- model_object = st.session_state[st_session_key]
77
- else:
78
- return "Please provide a valid model object or \
79
- Streamlit session key that contains the model object."
80
- if model_object is None:
81
- return "Please run the simulation first before plotting the figure."
82
- if model_object.simulation_results is None:
83
- model_object.simulate()
84
- df = model_object.simulation_results
85
- tool = PythonAstREPLTool(locals={"df": df})
86
- llm = ChatOpenAI(model="gpt-3.5-turbo")
87
- llm_with_tools = llm.bind_tools([tool], tool_choice=tool.name)
88
- system = f"""
89
- You have access to a pandas dataframe `df`.
90
- Here is the output of `df.head().to_markdown()`:
91
- {df.head().to_markdown()}
92
- Given a user question, write the Python code to
93
- plot a figure of the answer using matplolib.
94
- Return ONLY the valid Python code and nothing else.
95
- The firgure size should be equal or smaller than (2, 2).
96
- Show the grid and legend. The font size of the legend should be 6.
97
- Also write a suitable title for the figure. The font size of the title should be 8.
98
- The font size of the x-axis and y-axis labels should be 8.
99
- The font size of the x-axis and y-axis ticks should be 6.
100
- Make sure that the x-axis has at least 10 tick marks.
101
- Use color-blind friendly colors. The figure must be of high quality.
102
- Don't assume you have access to any libraries other
103
- than built-in Python ones, pandas, streamlit and matplotlib.
104
- """
105
- prompt = ChatPromptTemplate.from_messages([("system", system), ("human", "{question}")])
106
- parser = JsonOutputKeyToolsParser(key_name=tool.name, first_tool_only=True)
107
- code_chain = prompt | llm_with_tools | parser
108
- response = code_chain.invoke({"question": question})
109
- exec(response['query'], globals(), {"df": df, "plt": plt})
110
- # load for plotly
111
- fig = plt.gcf()
112
- if st_session_key:
113
- st.pyplot(fig, use_container_width=False)
114
- st.dataframe(df)
115
- return "Figure plotted successfully"
116
-
117
- def call_run(self,
118
- question: str,
119
- sys_bio_model: ModelData = ModelData(),
120
- st_session_key: str = None) -> str:
121
- """
122
- Run the tool.
123
- """
124
- return self._run(question=question,
125
- sys_bio_model=sys_bio_model,
126
- st_session_key=st_session_key)
127
-
128
- def get_metadata(self):
129
- """
130
- Get metadata for the tool.
131
- """
132
- return {
133
- "name": self.name,
134
- "description": self.description
135
- }