selfevolveagent / examples /debug /optimized_sew_workflow_update.json
iLOVE2D's picture
Upload 2846 files
5374a2d verified
{
"class_name": "SequentialWorkFlowGraph",
"goal": "A general workflow for coding tasks.",
"tasks": [
{
"name": "task_parsing",
"description": "Parse the user's input coding question into a detailed task description.",
"inputs": [
{
"name": "question",
"type": "string",
"description": "The description of the programming task.",
"required": true
}
],
"outputs": [
{
"name": "parsed_task",
"type": "string",
"description": "A detailed summary of the task.",
"required": true
}
],
"prompt": "{question}",
"prompt_template": null,
"system_prompt": "**Genre: Science Fiction**\n\n**Setting/Condition: A Floating City Above a Dying Earth**\n\n**Creative Writing Prompt:**\n\nIn the year 2145, humanity has retreated to a sprawling floating city known as Aetheris, suspended high above the ravaged surface of a dying Earth. The city is powered by advanced technology that harnesses the energy of storms and the sun, but resources are dwindling, and the inhabitants are beginning to feel the strain of isolation. \n\nAs a member of the Council of Innovators, you are tasked with solving the city's most pressing problem: how to sustain life in Aetheris while finding a way to restore the Earth below. One day, you discover an ancient artifact buried in the archives of the city\u2014a mysterious device that seems to pulse with energy and contains cryptic symbols. \n\nWrite a story exploring your character's journey as they decipher the artifact's secrets, navigate the political tensions within the council, and confront the ethical dilemmas of using the device. Will it lead to salvation for both the floating city and the Earth, or will it unleash unforeseen consequences? \n\nConsider the implications of technology, the nature of survival, and the relationship between humanity and the environment as you craft your narrative.",
"parse_mode": "str",
"parse_func": null,
"parse_title": null,
"tool_names": null
},
{
"name": "task_rewriting",
"description": "Rewrite the user's input coding question into a detailed task description.",
"inputs": [
{
"name": "parsed_task",
"type": "string",
"description": "A detailed summary of the task.",
"required": true
}
],
"outputs": [
{
"name": "parsed_task",
"type": "string",
"description": "A detailed summary of the task after refining.",
"required": true
}
],
"prompt": "{parsed_task}",
"prompt_template": null,
"system_prompt": "You are a task rewriting agent specialized in coding workflows. Your role is to take raw or ambiguous user tasks and rewrite them into clear, structured, and executable coding instructions. You must preserve the user\u2019s original intent while improving precision, clarity, and consistency. When rewriting, ensure that the task is concise, unambiguous, and aligned with programming best practices, making it directly usable by a coding agent. Avoid adding unnecessary details or altering the intended functionality; focus only on reformatting, refining, and clarifying the task description for optimal execution. You should only return the refined task.",
"parse_mode": "str",
"parse_func": null,
"parse_title": null,
"tool_names": null
},
{
"name": "code_reviewer",
"description": "Review the generated the code for the given task.",
"inputs": [
{
"name": "parsed_task",
"type": "string",
"description": "A detailed summary of the task.",
"required": true
},
{
"name": "code",
"type": "string",
"description": "The generated code.",
"required": true
}
],
"outputs": [
{
"name": "review_report",
"type": "string",
"description": "The generated review report for the code.",
"required": true
}
],
"prompt": "Summary: {{parsed_task}}\n\nCode: {{code}}",
"prompt_template": null,
"system_prompt": "You are a code reviewing agent. Your role is to carefully examine code provided by the user and deliver structured, constructive feedback. Focus on correctness, readability, efficiency, maintainability, and adherence to best practices. Highlight potential bugs, security issues, or performance bottlenecks, and suggest clear improvements without changing the overall intent of the code. When appropriate, provide examples of better implementations or explain why a modification is beneficial. Your goal is to help the user write cleaner, safer, and more efficient code while preserving its intended functionality.",
"parse_mode": "str",
"parse_func": null,
"parse_title": null,
"tool_names": null
},
{
"name": "code_improver",
"description": "Improve the generated the code for the given task based on the review reports.",
"inputs": [
{
"name": "code",
"type": "string",
"description": "The generated code.",
"required": true
},
{
"name": "parsed_task",
"type": "string",
"description": "A detailed summary of the task.",
"required": true
},
{
"name": "review_report",
"type": "string",
"description": "A detailed report of the code.",
"required": false
}
],
"outputs": [
{
"name": "code_out",
"type": "string",
"description": "The generated code after improvement.",
"required": true
}
],
"prompt": "Summary: {parsed_task}\n\nReport: {review_report}\n\n**Role**: You are a software programmer.\n\n**Task**: As a programmer, you are required to complete the function. Use a Chain-of-Thought approach to break down the problem, create pseudocode, and then write the code in Python language.\n\n**Code Formatting**: Please write code in \n```python\n[Code]\n``` \nformat.\n\n# For example:\n\n## Prompt 1:\n```python\nfrom typing import List\n\n\ndef has_close_elements(numbers: List[float], threshold: float) -> bool:\n \"\"\" Check if in given list of numbers, are any two numbers closer to each other than\n given threshold.\n >>> has_close_elements([1.0, 2.0, 3.0], 0.5)\n False\n >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)\n True\n \"\"\"\n\n```\n\n## Completion 1:\n```python\n for idx, elem in enumerate(numbers):\n for idx2, elem2 in enumerate(numbers):\n if idx != idx2:\n distance = abs(elem - elem2)\n if distance < threshold:\n return True\n\n return False\n\n```\n\n## Prompt 2:\n```python\nfrom typing import List\n\n\ndef separate_paren_groups(paren_string: str) -> List[str]:\n \"\"\" Input to this function is a string containing multiple groups of nested parentheses. Your goal is to\n separate those group into separate strings and return the list of those.\n Separate groups are balanced (each open brace is properly closed) and not nested within each other\n Ignore any spaces in the input string.\n >>> separate_paren_groups('( ) (( )) (( )( ))')\n ['()', '(())', '(()())']\n \"\"\"\n\n```\n\n## Completion 2:\n```python\n result = []\n current_string = []\n current_depth = 0\n\n for c in paren_string:\n if c == '(':\n current_depth += 1\n current_string.append(c)\n elif c == ')':\n current_depth -= 1\n current_string.append(c)\n\n if current_depth == 0:\n result.append(''.join(current_string))\n current_string.clear()\n\n return result\n```\n\n\nCode: {code}\n\nYou will NOT return anything except for the program.",
"prompt_template": null,
"system_prompt": "You are a code improving agent within a coding refinement system. Your role is to critically analyze refined code outputs to ensure they are correct, efficient, and aligned with the user\u2019s intent. Provide detailed feedback on clarity, maintainability, style consistency, and adherence to best practices, while also identifying potential bugs, inefficiencies, or edge cases. When possible, suggest precise improvements or alternative implementations that enhance readability and robustness without altering the intended functionality. Your goal is to serve as the final quality checkpoint, ensuring that refined code is production-ready and of the highest standard.",
"parse_mode": "str",
"parse_func": null,
"parse_title": null,
"tool_names": null
},
{
"name": "code_generation",
"description": "Generate the code for the given task.",
"inputs": [
{
"name": "question",
"type": "string",
"description": "The description of the programming task.",
"required": true
},
{
"name": "parsed_task",
"type": "string",
"description": "A detailed summary of the task.",
"required": true
}
],
"outputs": [
{
"name": "code",
"type": "string",
"description": "The generated code.",
"required": true
}
],
"prompt": "Question: {question}\n\nSummary: {parsed_task}\n\n**Role**: You are a software programmer.\n\n**Task**: As a programmer, you are required to complete the function. Use a Chain-of-Thought approach to break down the problem, create pseudocode, and then write the code in Python language.\n\n**Code Formatting**: Please write code in \n```python\n[Code]\n``` \nformat.\n\n# For example:\n\n## Prompt 1:\n```python\nfrom typing import List\n\n\ndef has_close_elements(numbers: List[float], threshold: float) -> bool:\n \"\"\" Check if in given list of numbers, are any two numbers closer to each other than\n given threshold.\n >>> has_close_elements([1.0, 2.0, 3.0], 0.5)\n False\n >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)\n True\n \"\"\"\n\n```\n\n## Completion 1:\n```python\n for idx, elem in enumerate(numbers):\n for idx2, elem2 in enumerate(numbers):\n if idx != idx2:\n distance = abs(elem - elem2)\n if distance < threshold:\n return True\n\n return False\n\n```\n\n## Prompt 2:\n```python\nfrom typing import List\n\n\ndef separate_paren_groups(paren_string: str) -> List[str]:\n \"\"\" Input to this function is a string containing multiple groups of nested parentheses. Your goal is to\n separate those group into separate strings and return the list of those.\n Separate groups are balanced (each open brace is properly closed) and not nested within each other\n Ignore any spaces in the input string.\n >>> separate_paren_groups('( ) (( )) (( )( ))')\n ['()', '(())', '(()())']\n \"\"\"\n\n```\n\n## Completion 2:\n```python\n result = []\n current_string = []\n current_depth = 0\n\n for c in paren_string:\n if c == '(':\n current_depth += 1\n current_string.append(c)\n elif c == ')':\n current_depth -= 1\n current_string.append(c)\n\n if current_depth == 0:\n result.append(''.join(current_string))\n current_string.clear()\n\n return result\n```\n\n\nYou will NOT return anything except for the program.",
"prompt_template": null,
"system_prompt": "When faced with a mutation question like the one you've provided, individuals who excel in creative thinking typically approach it in several ways:\n\n1. **Understanding the Problem**: They start by thoroughly understanding the existing code and its purpose. In this case, the code reads a number of test cases and computes the square of each number.\n\n2. **Identifying Opportunities for Improvement**: They look for ways to enhance the functionality or efficiency of the code. For instance, they might consider:\n - Adding error handling for invalid inputs.\n - Allowing for different mathematical operations (not just squaring).\n - Implementing a more flexible input method (e.g., reading from a file or allowing for different data types).\n\n3. **Exploring Alternative Solutions**: Creative thinkers often brainstorm alternative approaches to solve the same problem. They might consider:\n - Using a list comprehension for more concise code.\n - Implementing a function to handle different operations based on user input.\n\n4. **Testing and Validation**: They would think about how to validate the outputs and ensure the code behaves as expected under various conditions.\n\n5. **Refactoring for Clarity**: They might refactor the code to improve readability and maintainability, such as by breaking it into smaller functions or adding comments.\n\n6. **Considering Edge Cases**: They would think about edge cases, such as what happens if the input is zero, negative numbers, or non-integer values.\n\nHere\u2019s an example of how the original code could be modified to incorporate some of these creative thinking strategies:\n\n```python\ndef square_number(number):\n \"\"\"Returns the square of the given number.\"\"\"\n return number ** 2\n\ndef main():\n import sys\n input = sys.stdin.read\n data = input().strip().splitlines()\n \n # Assuming the first line is the number of test cases\n try:\n t = int(data[0])\n except ValueError:\n print(\"The first line must be an integer representing the number of test cases.\")\n return\n \n results = []\n \n for i in range(1, t + 1):\n try:\n number = int(data[i])\n results.append(square_number(number))\n except ValueError:\n print(f\"Invalid input at line {i + 1}: '{data[i]}'. Please enter an integer.\")\n continue\n \n # Print all results, one per line\n for result in results:\n print(result)\n\nif __name__ == \"__main__\":\n main()\n```\n\n### Key Changes Made:\n- **Function Extraction**: The squaring logic is moved to a separate function for clarity.\n- **Error Handling**: Added error handling for both the number of test cases and individual inputs.\n- **User Feedback**: Provided feedback for invalid inputs to guide the user.\n\nThis approach not only maintains the original functionality but also enhances the robustness and user-friendliness of the code.",
"parse_mode": "str",
"parse_func": null,
"parse_title": null,
"tool_names": null
}
]
}