diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5447340..c355dbb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,7 +39,7 @@ repos: - id: yamllint exclude: pre-commit-config.yaml - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.12.3" + rev: "v0.12.4" hooks: - id: ruff-format - id: ruff-check diff --git a/packages/manugen-ai/src/manugen_ai/agents/ai_science_writer/sub_agents/reviewer/agent.py b/packages/manugen-ai/src/manugen_ai/agents/ai_science_writer/sub_agents/reviewer/agent.py index d96629a..20ac91b 100644 --- a/packages/manugen-ai/src/manugen_ai/agents/ai_science_writer/sub_agents/reviewer/agent.py +++ b/packages/manugen-ai/src/manugen_ai/agents/ai_science_writer/sub_agents/reviewer/agent.py @@ -5,32 +5,36 @@ import os from google.adk.agents import Agent, LoopAgent -from google.adk.tools import FunctionTool -from manugen_ai.agents.meta_agent import ResilientToolAgent -from manugen_ai.tools.tools import exit_loop +from manugen_ai.agents.meta_agent import StopChecker from manugen_ai.utils import get_llm # Environment-driven model names MODEL_NAME = os.environ.get("MANUGENAI_MODEL_NAME") LLM = get_llm(MODEL_NAME) -COMPLETION_PHRASE = "THE AGENT HAS COMPLETED THE TASK." +COMPLETION_PHRASE = "TASK COMPLETED!" agent_review_loop = Agent( model=LLM, name="review_and_decide", - description="Critique full markdown and decide if it's final.", - instruction=""" + description="Critique full markdown and decide if it's finalized.", + instruction=f""" You receive content from the user. Your job: 1. Provide a concise bullet-list of any changes needed. -2. If **no** changes are needed (content is publication-ready), call the tool `exit_loop` instead of returning bullets. + - Use clear, actionable language. + - Focus on clarity, coherence, and scientific rigor. + - If changes are needed, return a list of feedback bullets. + - Don't go overboard, try to keep it concise and reasonable when it comes to updates. + - Do NOT provide guidance about new topics. You are to stick to only the topic areas within the content. +2. If **no** changes are needed (content is publication-ready), response ONLY with "{COMPLETION_PHRASE}" instead of returning bullets. -Return either: -- A JSON list of feedback bullets, -- Or invoke `exit_loop` (via the FunctionTool) to end the loop. +Return ONLY ONE of the following. +DO NOT return both! +1. A list of feedback bullets for use with revision. +2. Or respond with ONLY "{COMPLETION_PHRASE}" to indicate the content is ready for publication +If you respond with "{COMPLETION_PHRASE}", do not include any additional text or commentary. """, - tools=[FunctionTool(func=exit_loop)], output_key="feedback", ) @@ -39,14 +43,20 @@ model=LLM, name="refine_manuscript", description="Apply feedback to revise the manuscript.", - instruction=""" + instruction=f""" You receive: - Content from the user. -- feedback: a list of bullets in {feedback} +- feedback: a list of bullets in {{feedback}} Revise the content accordingly and return *only* updated content. +You MUST return actual content, not instructions or commentary about the content. +Do not add additional headers which are not in the original content. +Do not include "{COMPLETION_PHRASE}" in the output. +Do not include a header about the feedback. Do NOT return additional commentary, JSON, or metadata. ONLY return the revised content. +The revised content should be in markdown format and not include any additional +wrappers (such as backticks ```) or formatting besides what was provided in the original content. """, output_key="refined_md", ) @@ -55,10 +65,11 @@ root_agent = LoopAgent( name="reviewer_agent", description="Iteratively review and refine the manuscript until publication-ready.", - # Use ResilientToolAgent so missing-tool errors auto-retry up to N times sub_agents=[ - ResilientToolAgent(agent_review_loop, max_retries=2), - ResilientToolAgent(agent_refine, max_retries=2), + agent_review_loop, + agent_refine, + # use stopchecker to check if the work is completed. + StopChecker(context_variable="feedback", completion_phrase=COMPLETION_PHRASE), ], max_iterations=5, # safety cap ) diff --git a/packages/manugen-ai/src/manugen_ai/utils.py b/packages/manugen-ai/src/manugen_ai/utils.py index 2fc1384..26ee68b 100644 --- a/packages/manugen-ai/src/manugen_ai/utils.py +++ b/packages/manugen-ai/src/manugen_ai/utils.py @@ -99,7 +99,7 @@ def get_llm(model_name: str, **kwargs): elif model_name.startswith("gemini-"): return model_name - raise ValueError(f"Unknown model name: {model_name}") + raise ValueError(f"Unknown model name: {model_name if model_name else ''}") def prepare_ollama_models_for_adk_state() -> None: diff --git a/packages/manugen-ai/tests/conftest.py b/packages/manugen-ai/tests/conftest.py index 9c5cb12..7c9daa1 100644 --- a/packages/manugen-ai/tests/conftest.py +++ b/packages/manugen-ai/tests/conftest.py @@ -2,6 +2,7 @@ conftest for pytest fixutres and related """ +import os import pathlib import tempfile from typing import Any, Generator @@ -9,6 +10,12 @@ import pytest +@pytest.fixture(autouse=True, scope="session") +def set_model_name_env(): + os.environ["MANUGENAI_MODEL_NAME"] = "openai/llama3.2:3b" + os.environ["MANUGENAI_FIGURE_MODEL_NAME"] = "openai/llama3.2:3b" + + @pytest.fixture def temp_markdown_dir() -> Generator[ pathlib.Path, diff --git a/packages/manugen-ai/tests/reports/revise_content.ipynb b/packages/manugen-ai/tests/reports/revise_content.ipynb new file mode 100644 index 0000000..8b6c5ae --- /dev/null +++ b/packages/manugen-ai/tests/reports/revise_content.ipynb @@ -0,0 +1,719 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "1b289fe9-e26f-4656-bf9b-10abd5b4b3e9", + "metadata": {}, + "source": [ + "# Demonstrate agentic output for `enhance_with_related_work`\n", + "\n", + "The goal of this notebook is to help demonstrate agentic output from this project.\n", + "We can use this output to observe through review that the work is acting as we think it\n", + "should." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "8c299b61-9775-4573-9270-e589eccc8cde", + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Invalid config for agent figure_agent: output_schema cannot co-exist with agent transfer configurations. Setting disallow_transfer_to_parent=True, disallow_transfer_to_peers=True\n", + "Invalid config for agent request_interpreter_agent: output_schema cannot co-exist with agent transfer configurations. Setting disallow_transfer_to_parent=True, disallow_transfer_to_peers=True\n" + ] + } + ], + "source": [ + "from IPython.display import Image, display\n", + "from manugen_ai.agents.ai_science_writer.sub_agents.reviewer.agent import root_agent\n", + "from manugen_ai.utils import build_mermaid, run_agent_workflow" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "34d2d841-fa5d-4569-89ad-1fbc2bcc6d1a", + "metadata": {}, + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAA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RWMhIyIii8ZCRkREFo2FjIiILBoLGRERWTQWMiIismgsZEREZNFYyIiIyKKxkBERkUVjISMiIovGQkZERBaNhYyIiCwav1iTqExTlKijiUYrraR2ECrjjFkKAChqrJuFjKgMM97DtNPHk+3UzkHlg6IgXe0MRERERERERERERERERERERERERERERET0WP8Pe05E0CmmY2QAAAAASUVORK5CYII=", + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "# show our loop as a mermaid diagram\n", + "_, PNG = build_mermaid(root_agent)\n", + "display(Image(PNG))" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "ad740e9e-ad63-4de5-83df-8fc85fdf69e5", + "metadata": {}, + "outputs": [], + "source": [ + "# generate some example data\n", + "markdown_outline = \"\"\"\n", + "It was a dark and stormy night.\n", + "\"\"\"" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "cb715374-b56c-4e04-bb8c-3309856f0149", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[92m16:35:06 - LiteLLM:INFO\u001b[0m: utils.py:3043 - \n", + "LiteLLM completion() model= command-r:latest; provider = openai\n", + "INFO:LiteLLM:\n", + "LiteLLM completion() model= command-r:latest; provider = openai\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "Initial prompt:\n", + "----------------------\n", + "User: \n", + " Enhance this draft of my scientific article.\n", + "\n", + " Draft:\n", + " ```\n", + " \n", + "It was a dark and stormy night.\n", + "\n", + " ```\n", + " \n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:httpx:HTTP Request: POST http://localhost:11434/v1/chat/completions \"HTTP/1.1 200 OK\"\n", + "\u001b[92m16:35:18 - LiteLLM:INFO\u001b[0m: cost_calculator.py:655 - selected model name for cost calculation: openai/command-r:latest\n", + "INFO:LiteLLM:selected model name for cost calculation: openai/command-r:latest\n", + "\u001b[92m16:35:18 - LiteLLM:INFO\u001b[0m: cost_calculator.py:655 - selected model name for cost calculation: openai/command-r:latest\n", + "INFO:LiteLLM:selected model name for cost calculation: openai/command-r:latest\n", + "\u001b[92m16:35:18 - LiteLLM:INFO\u001b[0m: utils.py:3043 - \n", + "LiteLLM completion() model= command-r:latest; provider = openai\n", + "INFO:LiteLLM:\n", + "LiteLLM completion() model= command-r:latest; provider = openai\n", + "\u001b[92m16:35:18 - LiteLLM:INFO\u001b[0m: cost_calculator.py:655 - selected model name for cost calculation: openai/command-r:latest\n", + "INFO:LiteLLM:selected model name for cost calculation: openai/command-r:latest\n", + "\u001b[92m16:35:18 - LiteLLM:INFO\u001b[0m: cost_calculator.py:655 - selected model name for cost calculation: command-r:latest\n", + "INFO:LiteLLM:selected model name for cost calculation: command-r:latest\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "Final response:\n", + "************************\n", + "agent review_and_decide : \n", + "\n", + "- Remove the introductory sentence to focus on the purpose and findings of your research. \n", + "- Provide clarity on the scientific methodology, data collection, and analysis techniques.\n", + "- Ensure all references are cited accurately and consistently following an established style guide.\n", + "- Define any technical terms or abbreviations for easier understanding.\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:httpx:HTTP Request: POST http://localhost:11434/v1/chat/completions \"HTTP/1.1 200 OK\"\n", + "\u001b[92m16:35:27 - LiteLLM:INFO\u001b[0m: cost_calculator.py:655 - selected model name for cost calculation: openai/command-r:latest\n", + "INFO:LiteLLM:selected model name for cost calculation: openai/command-r:latest\n", + "\u001b[92m16:35:27 - LiteLLM:INFO\u001b[0m: cost_calculator.py:655 - selected model name for cost calculation: openai/command-r:latest\n", + "INFO:LiteLLM:selected model name for cost calculation: openai/command-r:latest\n", + "\u001b[92m16:35:27 - LiteLLM:INFO\u001b[0m: utils.py:3043 - \n", + "LiteLLM completion() model= command-r:latest; provider = openai\n", + "INFO:LiteLLM:\n", + "LiteLLM completion() model= command-r:latest; provider = openai\n", + "\u001b[92m16:35:27 - LiteLLM:INFO\u001b[0m: cost_calculator.py:655 - selected model name for cost calculation: openai/command-r:latest\n", + "INFO:LiteLLM:selected model name for cost calculation: openai/command-r:latest\n", + "\u001b[92m16:35:27 - LiteLLM:INFO\u001b[0m: cost_calculator.py:655 - selected model name for cost calculation: command-r:latest\n", + "INFO:LiteLLM:selected model name for cost calculation: command-r:latest\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "Final response:\n", + "************************\n", + "agent refine_manuscript : \n", + "\n", + "## Research Focus:\n", + "\n", + "\n", + "Exploring Atmospheric Conditions during Stormy Nights: An Empirical Study\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:httpx:HTTP Request: POST http://localhost:11434/v1/chat/completions \"HTTP/1.1 200 OK\"\n", + "\u001b[92m16:35:35 - LiteLLM:INFO\u001b[0m: cost_calculator.py:655 - selected model name for cost calculation: openai/command-r:latest\n", + "INFO:LiteLLM:selected model name for cost calculation: openai/command-r:latest\n", + "\u001b[92m16:35:35 - LiteLLM:INFO\u001b[0m: cost_calculator.py:655 - selected model name for cost calculation: openai/command-r:latest\n", + "INFO:LiteLLM:selected model name for cost calculation: openai/command-r:latest\n", + "\u001b[92m16:35:35 - LiteLLM:INFO\u001b[0m: utils.py:3043 - \n", + "LiteLLM completion() model= command-r:latest; provider = openai\n", + "INFO:LiteLLM:\n", + "LiteLLM completion() model= command-r:latest; provider = openai\n", + "\u001b[92m16:35:35 - LiteLLM:INFO\u001b[0m: cost_calculator.py:655 - selected model name for cost calculation: openai/command-r:latest\n", + "INFO:LiteLLM:selected model name for cost calculation: openai/command-r:latest\n", + "\u001b[92m16:35:35 - LiteLLM:INFO\u001b[0m: cost_calculator.py:655 - selected model name for cost calculation: command-r:latest\n", + "INFO:LiteLLM:selected model name for cost calculation: command-r:latest\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "Final response:\n", + "************************\n", + "agent review_and_decide : \n", + "\n", + "TASK COMPLETED!\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:httpx:HTTP Request: POST http://localhost:11434/v1/chat/completions \"HTTP/1.1 200 OK\"\n", + "\u001b[92m16:35:43 - LiteLLM:INFO\u001b[0m: cost_calculator.py:655 - selected model name for cost calculation: openai/command-r:latest\n", + "INFO:LiteLLM:selected model name for cost calculation: openai/command-r:latest\n", + "\u001b[92m16:35:43 - LiteLLM:INFO\u001b[0m: cost_calculator.py:655 - selected model name for cost calculation: openai/command-r:latest\n", + "INFO:LiteLLM:selected model name for cost calculation: openai/command-r:latest\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "Final response:\n", + "************************\n", + "agent refine_manuscript : \n", + "\n", + "## Research Focus:\n", + "\n", + "Exploring Atmospheric Conditions during Stormy Nights: An Empirical Study\n", + "\n", + "\n", + "Intermediate response:\n", + "----------------------\n", + "agent stop_checker : \n", + "\n", + "Function calls: []\n", + "Actions: skip_summarization=None state_delta={} artifact_delta={} transfer_to_agent=None escalate=True requested_auth_configs={}\n", + "\n", + "\n", + "Final output:\n", + "----------------------\n", + "Final output: ## Research Focus:\n", + "\n", + "Exploring Atmospheric Conditions during Stormy Nights: An Empirical Study\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\u001b[92m16:35:43 - LiteLLM:INFO\u001b[0m: cost_calculator.py:655 - selected model name for cost calculation: openai/command-r:latest\n", + "INFO:LiteLLM:selected model name for cost calculation: openai/command-r:latest\n", + "\u001b[92m16:35:43 - LiteLLM:INFO\u001b[0m: cost_calculator.py:655 - selected model name for cost calculation: command-r:latest\n", + "INFO:LiteLLM:selected model name for cost calculation: command-r:latest\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "Final response:\n", + "************************\n", + "agent agent_school : \n", + "\n", + "[agent_school]\n", + "\n", + "To begin summarizing the CytoTable project, I will apply some best practices from \"Ten simple rules for structuring papers\" as outlined in the provided paper. Here is my attempt at summarizing the key points:\n", + "\n", + "Title: \"Cytotomic Analysis and Data Table Management\"\n", + "\n", + "Abstract:\n", + "Background: Cytometry is a crucial tool in biological research, enabling comprehensive analysis of cells. The CytoTable project provides a framework for efficient data management.\n", + "\n", + "Results: A sample README exists, detailing the methods for cytometric analysis.\n", + "\n", + "Discussion: Our goal is to extract relevant information from this README and summarize it into an abstract. We will revisit and revise this summary using best practices for scientific paper structuring.\n", + "\n", + "\n", + "Here are some guidelines for revising the abstract in a loop:\n", + "\n", + "\n", + "• Maintain a clear title and concise abstract.\n", + "• Provide sufficient background information or context.\n", + "• Clearly outline results, emphasizing primary findings.\n", + "• Discuss implications or future research directions as needed.\n", + "\n", + "Which area would you like to revise first?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "Final response:\n", + "************************\n", + "agent agent_writer : \n", + "\n", + "Dear user,\n", + "\n", + "As agent_writer, I can try to create a more accurate and comprehensive scientific paper abstract based on the provided content. Here is the revised version:\n", + "\n", + "Title: \"Cytotomic Analysis and Data Table Management\"\n", + "\n", + "Abstract:\n", + "This study presents a framework for efficient cytometric analysis and data table management using the CytoTable project. The CytoTable repository provides a sample README that outlines the methods and approaches used in this field, which focus on biological research applications.\n", + "\n", + "Results:\n", + "The sample README details the methods for cytometric analysis, enabling researchers to extract relevant information from biological samples.\n", + "\n", + "Discussion:\n", + "Our goal is to provide an abstract highlighting the key aspects of the research, including cytometry, data tables, and analysis methods. We aim to summarize the CytoTable project in a concise and accurate manner, ensuring that the abstract provides sufficient context for readers interested in this field.\n", + "\n", + "Please let me know if you would like me to revise any specific section or area within the loop.\n", + "\n", + "\n", + "Here is the revised version:\n", + "\n", + "Title: \"Cytotomic Analysis and Data Table Management\"\n", + "\n", + "Abstract:\n", + "This study presents a framework for efficient cytometric analysis and data table management using the CytoTable project. The CytoTable repository provides a sample README that outlines the methods and approaches used in this field, which focus on biological research applications.\n", + "\n", + "Results:\n", + "The sample README details the methods for cytometric analysis, enabling researchers to extract relevant information from biological samples.\n", + "\n", + "\n", + "Discussion:\n", + "Our goal is to provide an abstract highlighting the key aspects of the research, including cytometry, data tables, and analysis methods. We aim to summarize the CytoTable project in a concise and accurate manner, ensuring that the abstract provides sufficient context for readers interested in this field.\n", + "\n", + "What would you like me to change next?\n", + "\n", + "\n", + "\n", + "Please let me know if you would like me to proceed with further revisions or changes.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "Final response:\n", + "************************\n", + "agent agent_editor : \n", + "\n", + "To identify specific suggestions for improvement, I need to exit the provided abstract. This is because the current version of the abstract seems sufficient for its length and adequately addresses the topic, given the context.\n", + "\n", + "However, upon reviewing the document again, I can provide a few specific suggestions:\n", + "\n", + "- Add more concrete information about the importance or broader impact of the CytoTable project in the \"Background\" section.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "Final response:\n", + "************************\n", + "agent agent_refiner : \n", + "\n", + "Based on the provided feedback and guidelines, I will refine the abstract within a loop.\n", + "\n", + "\n", + "Here is the revised version:\n", + "\n", + "\n", + "Title: \"Cytotomic Analysis and Data Table Management\"\n", + "\n", + "\n", + "Abstract:\n", + "Background: Cytometry is a crucial tool in biological research, enabling comprehensive analysis of cells. The CytoTable project provides a framework for efficient data management, addressing key challenges in cytometric analysis. This study aims to provide an overview of the CytoTable project's contributions to improving data quality and workflow.\n", + "\n", + "\n", + "Results: A sample README exists, detailing the methods for cytometric analysis. The README highlights the importance of precise data handling in biological research applications.\n", + "\n", + "\n", + "Discussion:\n", + "Our goal is to provide a concise summary of the CytoTable project's objectives, emphasizing key aspects such as data management, cytometry, and analysis methods. We aim to summarize our understanding of the CytoTable project in an accessible manner, providing context for readers interested in this field.\n", + "\n", + "\n", + "Here are some guidelines for revising the abstract in a loop:\n", + "\n", + "\n", + "• Maintain a clear title and concise abstract.\n", + "• Provide sufficient background information or context (added \"and broader impact\")\n", + "• Clearly outline results, emphasizing primary findings\n", + "• Discuss implications or future research directions as needed\n", + "\n", + "\n", + "Which area would you like to revise next?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "Final response:\n", + "************************\n", + "agent agent_editor : \n", + "\n", + "To continue refining the abstract within a loop, I suggest revising the Results section. The current version states that a sample README exists, detailing the methods for cytometric analysis, but it seems that no actual data are provided or analyzed in the given context.\n", + "\n", + "Here's a possible revision to add more detail to the Results section:\n", + "\n", + "Results:\n", + "A sample README is provided within the CytoTable repository, detailing the methods and approaches used in this field. The README highlights the importance of precise data handling in biological research applications ([tool_call] could be utilized to extract relevant information from this README).\n", + "\n", + "Using this tool call allows for a more concrete representation of the results, while also following the guidelines provided.\n", + "\n", + "This revised section aims to add more detail and provide a clearer overview of the experimental design and methods used in the CytoTable project.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "Final response:\n", + "************************\n", + "agent agent_refiner : \n", + "\n", + "Based on the critique and suggested revision:\n", + "\n", + "\n", + "Here is the refined version:\n", + "\n", + "\n", + "Title: \"Cytotomic Analysis and Data Table Management\"\n", + "\n", + "\n", + "Abstract:\n", + "Background: Cytometry is a crucial tool in biological research, enabling comprehensive analysis of cells. The CytoTable project provides a framework for efficient data management, addressing key challenges in cytometric analysis. This study aims to provide an overview of the CytoTable project's contributions to improving data quality and workflow.\n", + "\n", + "\n", + "Results:\n", + "A sample README is provided within the CytoTable repository, detailing the methods and approaches used in this field. The README highlights the importance of precise data handling in biological research applications ([tool_call] could be utilized to extract relevant information from this README).\n", + "\n", + "Using this tool call allows for a more concrete representation of the results, while also following the guidelines provided.\n", + "\n", + "\n", + "Discussion:\n", + "Our goal is to provide a concise summary of the CytoTable project's objectives, emphasizing key aspects such as data management, cytometry, and analysis methods. We aim to summarize our understanding of the CytoTable project in an accessible manner, providing context for readers interested in this field.\n", + "\n", + "\n", + "Here are some guidelines for revising the abstract in a loop:\n", + "\n", + "\n", + "• Maintain a clear title and concise abstract.\n", + "• Provide sufficient background information or context (added \"and broader impact\")\n", + "• Clearly outline results, emphasizing primary findings\n", + "• Discuss implications or future research directions as needed\n", + "\n", + "\n", + "Which area would you like to revise next?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "Final response:\n", + "************************\n", + "agent agent_editor : \n", + "\n", + "I'd like to revisit the Discussion section. The current version seems to be mostly about providing a summary of the project's objectives and context. However, it might be beneficial to explicitly mention how the project contributes to the broader field of biological research and its potential impact.\n", + "\n", + "To achieve this, I suggest adding a sentence that highlights the significance or relevance of the CytoTable project in the Discussion section.\n", + "\n", + "Here's a possible revised version:\n", + "\n", + "Discussion:\n", + "Our goal is to provide a concise summary of the CytoTable project's objectives, emphasizing key aspects such as data management, cytometry, and analysis methods. We aim to summarize our understanding of the CytoTable project in an accessible manner, providing context for readers interested in this field. Furthermore, we highlight the significance of this project in addressing key challenges and improving workflows in biological research, with potential implications for advancing our knowledge and applications.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "Final response:\n", + "************************\n", + "agent agent_refiner : \n", + "\n", + "Based on the critique and suggested revision:\n", + "\n", + "\n", + "Here is the refined version:\n", + "\n", + "\n", + "Title: \"Cytotomic Analysis and Data Table Management\"\n", + "\n", + "\n", + "Abstract:\n", + "Background: Cytometry is a crucial tool in biological research, enabling comprehensive analysis of cells. The CytoTable project provides a framework for efficient data management, addressing key challenges in cytometric analysis. This study aims to provide an overview of the CytoTable project's contributions to improving data quality and workflow.\n", + "\n", + "\n", + "Results:\n", + "A sample README is provided within the CytoTable repository, detailing the methods and approaches used in this field. The README highlights the importance of precise data handling in biological research applications ([tool_call] could be utilized to extract relevant information from this README).\n", + "\n", + "Using this tool call allows for a more concrete representation of the results, while also following the guidelines provided.\n", + "\n", + "\n", + "Discussion:\n", + "Our goal is to provide a concise summary of the CytoTable project's objectives, emphasizing key aspects such as data management, cytometry, and analysis methods. We aim to summarize our understanding of the CytoTable project in an accessible manner, providing context for readers interested in this field. Furthermore, we highlight the significance of this project in addressing key challenges and improving workflows in biological research, with potential implications for advancing our knowledge and applications.\n", + "\n", + "\n", + "Here are some guidelines for revising the abstract in a loop:\n", + "\n", + "\n", + "• Maintain a clear title and concise abstract.\n", + "• Provide sufficient background information or context (added \"and broader impact\")\n", + "• Clearly outline results, emphasizing primary findings\n", + "• Discuss implications or future research directions as needed\n", + "\n", + "\n", + "Which area would you like to revise next?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "Final response:\n", + "************************\n", + "agent agent_editor : \n", + "\n", + "I'd like to revise the Title section. The current title is clear and concise, but it might be beneficial to make it more catchy and attention-grabbing.\n", + "\n", + "Here's a possible revised version:\n", + "\n", + "Title: \"Unlocking Efficient Cytometric Analysis with CytoTable: A Framework for Data Quality and Workflow\"\n", + "\n", + "This revised title adds more descriptive language to highlight the key benefits of using the CytoTable project, making it more appealing to potential readers.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "Final response:\n", + "************************\n", + "agent agent_refiner : \n", + "\n", + "Based on the critique and suggested revision:\n", + "\n", + "\n", + "Here is the refined version:\n", + "\n", + "\n", + "Title: \"Unlocking Efficient Cytometric Analysis with CytoTable: A Framework for Data Quality and Workflow\"\n", + "\n", + "\n", + "Abstract:\n", + "Background: Cytometry is a crucial tool in biological research, enabling comprehensive analysis of cells. The CytoTable project provides a framework for efficient data management, addressing key challenges in cytometric analysis. This study aims to provide an overview of the CytoTable project's contributions to improving data quality and workflow.\n", + "\n", + "\n", + "Results:\n", + "A sample README is provided within the CytoTable repository, detailing the methods and approaches used in this field. The README highlights the importance of precise data handling in biological research applications ([tool_call] could be utilized to extract relevant information from this README).\n", + "\n", + "Using this tool call allows for a more concrete representation of the results, while also following the guidelines provided.\n", + "\n", + "\n", + "Discussion:\n", + "Our goal is to provide a concise summary of the CytoTable project's objectives, emphasizing key aspects such as data management, cytometry, and analysis methods. We aim to summarize our understanding of the CytoTable project in an accessible manner, providing context for readers interested in this field. Furthermore, we highlight the significance of this project in addressing key challenges and improving workflows in biological research, with potential implications for advancing our knowledge and applications.\n", + "\n", + "\n", + "Here are some guidelines for revising the abstract in a loop:\n", + "\n", + "\n", + "• Maintain a clear title and concise abstract.\n", + "• Provide sufficient background information or context (added \"and broader impact\")\n", + "• Clearly outline results, emphasizing primary findings\n", + "• Discuss implications or future research directions as needed\n", + "\n", + "\n", + "Which area would you like to revise next?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "Final response:\n", + "************************\n", + "agent agent_editor : \n", + "\n", + "All the way finished!\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "Final response:\n", + "************************\n", + "agent agent_refiner : \n", + "\n", + "Here is the final improved document:\n", + "\n", + "\n", + "Title: \"Unlocking Efficient Cytometric Analysis with CytoTable: A Framework for Data Quality and Workflow\"\n", + "\n", + "\n", + "Abstract:\n", + "Background: Cytometry is a crucial tool in biological research, enabling comprehensive analysis of cells. The CytoTable project provides a framework for efficient data management, addressing key challenges in cytometric analysis. This study aims to provide an overview of the CytoTable project's contributions to improving data quality and workflow.\n", + "\n", + "\n", + "Results:\n", + "A sample README is provided within the CytoTable repository, detailing the methods and approaches used in this field. The README highlights the importance of precise data handling in biological research applications ([tool_call] could be utilized to extract relevant information from this README).\n", + "\n", + "Using this tool call allows for a more concrete representation of the results, while also following the guidelines provided.\n", + "\n", + "\n", + "Discussion:\n", + "Our goal is to provide a concise summary of the CytoTable project's objectives, emphasizing key aspects such as data management, cytometry, and analysis methods. We aim to summarize our understanding of the CytoTable project in an accessible manner, providing context for readers interested in this field. Furthermore, we highlight the significance of this project in addressing key challenges and improving workflows in biological research, with potential implications for advancing our knowledge and applications.\n", + "\n", + "\n", + "Intermediate response:\n", + "----------------------\n", + "agent stop_checker : \n", + "\n", + "Function calls: []\n", + "Actions: skip_summarization=None state_delta={} artifact_delta={} transfer_to_agent=None escalate=True requested_auth_configs={}\n", + "\n", + "\n", + "Final output:\n", + "----------------------\n", + "Final output: Here is the final improved document:\n", + "\n", + "\n", + "Title: \"Unlocking Efficient Cytometric Analysis with CytoTable: A Framework for Data Quality and Workflow\"\n", + "\n", + "\n", + "Abstract:\n", + "Background: Cytometry is a crucial tool in biological research, enabling comprehensive analysis of cells. The CytoTable project provides a framework for efficient data management, addressing key challenges in cytometric analysis. This study aims to provide an overview of the CytoTable project's contributions to improving data quality and workflow.\n", + "\n", + "\n", + "Results:\n", + "A sample README is provided within the CytoTable repository, detailing the methods and approaches used in this field. The README highlights the importance of precise data handling in biological research applications ([tool_call] could be utilized to extract relevant information from this README).\n", + "\n", + "Using this tool call allows for a more concrete representation of the results, while also following the guidelines provided.\n", + "\n", + "\n", + "Discussion:\n", + "Our goal is to provide a concise summary of the CytoTable project's objectives, emphasizing key aspects such as data management, cytometry, and analysis methods. We aim to summarize our understanding of the CytoTable project in an accessible manner, providing context for readers interested in this field. Furthermore, we highlight the significance of this project in addressing key challenges and improving workflows in biological research, with potential implications for advancing our knowledge and applications.\n" + ] + } + ], + "source": [ + "APP_NAME = \"app\"\n", + "USER_ID = \"user\"\n", + "SESSION_ID = \"001\"\n", + "final_output, session_state, output_events = await run_agent_workflow(\n", + " agent=root_agent,\n", + " prompt=f\"\"\"\n", + " Enhance this draft of my scientific article.\n", + " \n", + " Draft:\n", + " ```\n", + " {markdown_outline}\n", + " ```\n", + " \"\"\",\n", + " app_name=APP_NAME,\n", + " user_id=USER_ID,\n", + " session_id=SESSION_ID,\n", + " verbose=True,\n", + ")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.10" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/packages/manugen-ai/tests/test_agents.py b/packages/manugen-ai/tests/test_agents.py index cd5f473..9264399 100644 --- a/packages/manugen-ai/tests/test_agents.py +++ b/packages/manugen-ai/tests/test_agents.py @@ -3,7 +3,7 @@ """ import pytest -from manugen_ai.agents.capitalizer.agent import root_agent +from manugen_ai.agents.capitalizer.agent import root_agent as capitalizer_agent from manugen_ai.utils import run_agent_workflow @@ -17,7 +17,7 @@ async def test_agent_capitalizer(): # retry 5 times for attempt in range(5): _, session_state, _ = await run_agent_workflow( - agent=root_agent, + agent=capitalizer_agent, prompt=""" this is a sentence to correct """, @@ -32,3 +32,45 @@ async def test_agent_capitalizer(): # Final attempt failed, raise assertion assert "output" in session_state.keys() assert session_state["output"] == expected_output + + +@pytest.mark.asyncio +async def test_agent_reviewer(): + """ + Test the reviewer agent to ensure it can loop and improve text + """ + + # localized imports to help with agent env setting + from manugen_ai.agents.ai_science_writer.sub_agents.reviewer.agent import ( + COMPLETION_PHRASE as review_agent_COMPLETION_PHRASE, + ) + from manugen_ai.agents.ai_science_writer.sub_agents.reviewer.agent import ( + root_agent as review_agent, + ) + + # we attempt multiple times to ensure the agent can loop and improve the text + for attempt in range(5): + _, session_state, output_events = await run_agent_workflow( + agent=review_agent, + prompt=""" + Please improve the following text: + + It was a dark and stormy night. + """, + app_name="app", + user_id="user", + session_id="0001", + # note: use `uv run pytest -s` to view the verbose stdout + verbose=True, + ) + + # check that we received feedback and that the completion phrase was used. + if ( + "feedback" in session_state + and session_state["feedback"] == review_agent_COMPLETION_PHRASE + ): + break + if attempt == 4: + raise AssertionError( + "Final attempt failed, completion phrase not found or does not match expected output." + ) diff --git a/packages/manugen-ai/tests/test_tools.py b/packages/manugen-ai/tests/test_tools.py index c5c7ba0..d28e5bc 100644 --- a/packages/manugen-ai/tests/test_tools.py +++ b/packages/manugen-ai/tests/test_tools.py @@ -1,3 +1,7 @@ +""" +Tests for custom tools +""" + import pathlib from types import SimpleNamespace