From 0f0efc3634b57380bb889a78c9bfa86524dbb98d Mon Sep 17 00:00:00 2001 From: Kowalski1024 Date: Mon, 9 Jun 2025 08:31:22 +0200 Subject: [PATCH 1/6] [chore] change description to title --- src/reagentai/models/output.py | 4 ++-- src/reagentai/tools/image.py | 12 ++++++------ src/reagentai/ui/app.py | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/reagentai/models/output.py b/src/reagentai/models/output.py index 28ddff1..e2e78dc 100644 --- a/src/reagentai/models/output.py +++ b/src/reagentai/models/output.py @@ -7,8 +7,8 @@ class ImageOutput(BaseModel): Attributes: file_path (str): The file path to the image output. - description (str): A description or title for the image output. + title (str): A title for the image output. """ file_path: str - description: str + title: str diff --git a/src/reagentai/tools/image.py b/src/reagentai/tools/image.py index e7c03ea..6e65f47 100644 --- a/src/reagentai/tools/image.py +++ b/src/reagentai/tools/image.py @@ -13,14 +13,14 @@ def smiles_to_image( - smiles: str, image_description: str, size: tuple[int, int] = (600, 300) + smiles: str, title: str, size: tuple[int, int] = (600, 300) ) -> ImageOutput: """ Generate an image from a SMILES string. Args: smiles (str): The SMILES string to convert to an image. - image_description (str): A description or title for the generated image. + title (str): A title for the generated image. size (tuple[int, int]): The size of the image in pixels. Default is (600, 300). Returns: @@ -41,16 +41,16 @@ def smiles_to_image( temp_file_path = tmp_file.name logger.info(f"Generated image for SMILES: {smiles}, saved to {temp_file_path}") - return ImageOutput(file_path=temp_file_path, description=image_description) + return ImageOutput(file_path=temp_file_path, title=title) -def route_to_image(route: Route, image_description: str) -> ImageOutput: +def route_to_image(route: Route, title: str) -> ImageOutput: """ Generate an image from a retrosynthesis route. Args: route (Route): The retrosynthesis route to convert to an image. - image_description (str): A description or title for the generated image. + title (str): A title for the generated image. Returns: ImageOutput: An object containing the file path to the generated image and its description. @@ -64,4 +64,4 @@ def route_to_image(route: Route, image_description: str) -> ImageOutput: temp_file_path = tmp_file.name logger.info(f"Generated image for route, saved to {temp_file_path}") - return ImageOutput(file_path=temp_file_path, description=image_description) + return ImageOutput(file_path=temp_file_path, title=title) diff --git a/src/reagentai/ui/app.py b/src/reagentai/ui/app.py index 6292138..af57b17 100644 --- a/src/reagentai/ui/app.py +++ b/src/reagentai/ui/app.py @@ -180,7 +180,7 @@ def run_agent( if call.tool_name in ["smiles_to_image", "route_to_image"]: output: ImageOutput = call.content metadata = { - "title": output.description, + "title": output.title, "status": "done", } gr_message = { From bfaed40dc290e5dead53d9c8b4ae542d37fc8efe Mon Sep 17 00:00:00 2001 From: Kowalski1024 Date: Mon, 9 Jun 2025 08:55:23 +0200 Subject: [PATCH 2/6] [feat] add tabs to UI --- src/reagentai/agents/main/instructions.txt | 2 +- src/reagentai/ui/app.py | 56 +++++++++++----------- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/reagentai/agents/main/instructions.txt b/src/reagentai/agents/main/instructions.txt index 837671a..9ff6373 100644 --- a/src/reagentai/agents/main/instructions.txt +++ b/src/reagentai/agents/main/instructions.txt @@ -176,7 +176,7 @@ Expected steps from you: 2. Use `is_valid_smiles` to validate the SMILES of Ibuprofen. 3. Call `perform_retrosynth` with the Ibuprofen SMILES to find possible synthetic routes. 4. Process the output from `perform_retrosynth` to identify the synthetic routes. -5. Use `route_to_image` to generate an image of the retrosynthesis route. +5. Use `route_to_image` to generate an image of the retrosynthesis route wi 6. Describe the reaction steps, including the SMILES and customary names (if available) of the compounds involved. Example response: diff --git a/src/reagentai/ui/app.py b/src/reagentai/ui/app.py index ddf171f..229d966 100644 --- a/src/reagentai/ui/app.py +++ b/src/reagentai/ui/app.py @@ -23,33 +23,35 @@ def create_settings_panel( tuple: A tuple containing the model dropdown, usage counter, and tool display components. """ with gr.Column(scale=2, elem_id="col"): - gr.Markdown("### Model Settings") - model_dropdown = gr.Dropdown( - label="Select LLM Model", - choices=AVAILABLE_LLM_MODELS, - value=AVAILABLE_LLM_MODELS[0], - ) - usage_counter = gr.Number( - label="Total Token Usage", - value=0, - precision=0, - interactive=False, - visible=True, - ) - - gr.Examples( - examples=EXAMPLE_PROMPTS, - inputs=chat_input_component, - label="Example Prompts", - ) - - gr.Markdown("### Tool Usage History") - tool_display = gr.Chatbot( - type="messages", - label="Tool Usage", - layout="panel", - elem_id="tool_display", - ) + with gr.Tab("Settings"): + gr.Markdown("### Model Settings") + model_dropdown = gr.Dropdown( + label="Select LLM Model", + choices=AVAILABLE_LLM_MODELS, + value=AVAILABLE_LLM_MODELS[0], + ) + usage_counter = gr.Number( + label="Total Token Usage", + value=0, + precision=0, + interactive=False, + visible=True, + ) + + gr.Examples( + examples=EXAMPLE_PROMPTS, + inputs=chat_input_component, + label="Example Prompts", + examples_per_page=4, + ) + with gr.Tab("Tool Usage"): + gr.Markdown("### Tool Usage History") + tool_display = gr.Chatbot( + type="messages", + label="Tool Usage", + layout="panel", + elem_id="tool_display", + ) return model_dropdown, usage_counter, tool_display From 9f4a324dc613c5d6bca34097818c838119112aa2 Mon Sep 17 00:00:00 2001 From: Kowalski1024 Date: Mon, 9 Jun 2025 09:01:00 +0200 Subject: [PATCH 3/6] [fix] fix typo --- src/reagentai/agents/main/instructions.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/reagentai/agents/main/instructions.txt b/src/reagentai/agents/main/instructions.txt index 9ff6373..837671a 100644 --- a/src/reagentai/agents/main/instructions.txt +++ b/src/reagentai/agents/main/instructions.txt @@ -176,7 +176,7 @@ Expected steps from you: 2. Use `is_valid_smiles` to validate the SMILES of Ibuprofen. 3. Call `perform_retrosynth` with the Ibuprofen SMILES to find possible synthetic routes. 4. Process the output from `perform_retrosynth` to identify the synthetic routes. -5. Use `route_to_image` to generate an image of the retrosynthesis route wi +5. Use `route_to_image` to generate an image of the retrosynthesis route. 6. Describe the reaction steps, including the SMILES and customary names (if available) of the compounds involved. Example response: From e8fe2f5fdcedc6b39899c1dca69d2a4f78ef17b0 Mon Sep 17 00:00:00 2001 From: Kowalski1024 Date: Mon, 9 Jun 2025 09:02:15 +0200 Subject: [PATCH 4/6] [refactor] ruff formatting --- src/reagentai/tools/image.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/reagentai/tools/image.py b/src/reagentai/tools/image.py index 6e65f47..ad845e8 100644 --- a/src/reagentai/tools/image.py +++ b/src/reagentai/tools/image.py @@ -12,9 +12,7 @@ logger = logging.getLogger(__name__) -def smiles_to_image( - smiles: str, title: str, size: tuple[int, int] = (600, 300) -) -> ImageOutput: +def smiles_to_image(smiles: str, title: str, size: tuple[int, int] = (600, 300)) -> ImageOutput: """ Generate an image from a SMILES string. From 33c734fb935fd5b4b1a583943466e3f1c3fe41dd Mon Sep 17 00:00:00 2001 From: Kowalski1024 Date: Mon, 9 Jun 2025 09:07:15 +0200 Subject: [PATCH 5/6] [feat] add examples per page variable --- src/reagentai/constants.py | 3 ++- src/reagentai/ui/app.py | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/reagentai/constants.py b/src/reagentai/constants.py index 0b7b4d2..6dadc43 100644 --- a/src/reagentai/constants.py +++ b/src/reagentai/constants.py @@ -6,7 +6,7 @@ "gemini-2.5-flash-preview-04-17", ] AIZYNTHFINDER_CONFIG_PATH: str = "data/config.yml" -EXAMPLE_PROMPTS = [ +EXAMPLE_PROMPTS: list[str] = [ "Can u tell me the SMILES of Caffeine? And generate an image of the compound.", "How to synthesize Aspirin? Can u tell me the best steps to achieve this?", "Suggest a retrosynthesis for Ibuprofen. Show all molecule images from the best route.", @@ -15,6 +15,7 @@ "Convert this SMILES to a chemical name: CC(=O)OC1=CC=CC=C1C(=O)O", "Tell me the detailed properties of Gabapentin.", ] +EXAMPLES_PER_PAGE: int = 4 DEFAULT_LOG_LEVEL: int = INFO LOG_DIR: Path = Path("logs") diff --git a/src/reagentai/ui/app.py b/src/reagentai/ui/app.py index 229d966..669afee 100644 --- a/src/reagentai/ui/app.py +++ b/src/reagentai/ui/app.py @@ -6,7 +6,12 @@ from src.reagentai.agents.main.main_agent import MainAgent from src.reagentai.common.typing import ChatHistory -from src.reagentai.constants import APP_CSS, AVAILABLE_LLM_MODELS, EXAMPLE_PROMPTS +from src.reagentai.constants import ( + APP_CSS, + AVAILABLE_LLM_MODELS, + EXAMPLE_PROMPTS, + EXAMPLES_PER_PAGE, +) from src.reagentai.models.output import ImageOutput @@ -42,7 +47,7 @@ def create_settings_panel( examples=EXAMPLE_PROMPTS, inputs=chat_input_component, label="Example Prompts", - examples_per_page=4, + examples_per_page=EXAMPLES_PER_PAGE, ) with gr.Tab("Tool Usage"): gr.Markdown("### Tool Usage History") From 55548150a6f149d7f7c3efa6e559a3ce42ebb100 Mon Sep 17 00:00:00 2001 From: Kowalski1024 Date: Mon, 9 Jun 2025 09:09:06 +0200 Subject: [PATCH 6/6] [docs] change description to title --- src/reagentai/tools/image.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/reagentai/tools/image.py b/src/reagentai/tools/image.py index ad845e8..c289c00 100644 --- a/src/reagentai/tools/image.py +++ b/src/reagentai/tools/image.py @@ -22,7 +22,7 @@ def smiles_to_image(smiles: str, title: str, size: tuple[int, int] = (600, 300)) size (tuple[int, int]): The size of the image in pixels. Default is (600, 300). Returns: - ImageOutput: An object containing the file path to the generated image and its description. + ImageOutput: An object containing the file path and title of the generated image. Raises: ValueError: If the provided SMILES string is invalid. """ @@ -51,7 +51,7 @@ def route_to_image(route: Route, title: str) -> ImageOutput: title (str): A title for the generated image. Returns: - ImageOutput: An object containing the file path to the generated image and its description. + ImageOutput: An object containing the file path and title of the generated image. """ image = RouteImageFactory(route).image