Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from coordinator.coordinator import Coordinator | |
| from coordinator.task_parser import parse_brief_with_reasoning | |
| from coordinator.task_assigner import assign_tasks_with_reasoning | |
| from frontend_agent.ui_generator import generate_react_component_llm | |
| from backend_agent.api_generator import generate_backend_code_llm | |
| from frontend_agent.ui_generator import generate_react_component_llm | |
| coord = Coordinator() | |
| def process_brief_with_reasoning(project_brief): | |
| output_text = "" | |
| # Step 1: Parsing Tasks with reasoning | |
| output_text += "### Step 1: Parsing Tasks\n" | |
| parsing_result = parse_brief_with_reasoning(project_brief) | |
| output_text += "**LLM Reasoning:**\n" | |
| output_text += parsing_result["reasoning"] + "\n\n" | |
| output_text += "**Parsed Tasks:**\n" | |
| for t in parsing_result["tasks"]: | |
| output_text += f"- {t}\n" | |
| # Step 2: Assigning Tasks with reasoning | |
| output_text += "\n### Step 2: Assigning Tasks\n" | |
| assignment_result = assign_tasks_with_reasoning(parsing_result["tasks"]) | |
| output_text += "**LLM Reasoning:**\n" | |
| output_text += assignment_result["reasoning"] + "\n\n" | |
| output_text += "**Assigned Tasks:**\n" | |
| for task, agent in assignment_result["assignments"].items(): | |
| output_text += f"- {task} -> {agent}\n" | |
| # Step 3: Code Generation | |
| output_text += "\n### Step 3: Code Generation\n" | |
| for task, agent in assignment_result["assignments"].items(): | |
| output_text += f"\n#### {task} ({agent})\n" | |
| if "frontend" in agent.lower(): | |
| code = generate_react_component_llm(task) | |
| output_text += f"\n```jsx\n{code}\n```\n" | |
| elif "backend" in agent.lower(): | |
| code = generate_backend_code_llm(task) | |
| output_text += f"\n```python\n{code}\n```\n" | |
| return output_text | |
| with gr.Blocks() as demo: | |
| gr.Markdown("## AI Project Coordinator - Step-by-Step Reasoning Log") | |
| project_brief_input = gr.Textbox(lines=3, placeholder="Enter your project brief here...") | |
| submit_button = gr.Button("Submit") | |
| console_output = gr.Textbox( | |
| label="Processing Log", | |
| placeholder="LLM reasoning and outputs will appear here...", | |
| lines=25 | |
| ) | |
| submit_button.click( | |
| fn=process_brief_with_reasoning, | |
| inputs=project_brief_input, | |
| outputs=console_output | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |