Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,42 +1,61 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from coordinator.coordinator import Coordinator
|
| 3 |
-
from coordinator.
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
# Initialize Coordinator
|
| 6 |
coord = Coordinator()
|
| 7 |
|
| 8 |
-
def
|
| 9 |
-
"""
|
| 10 |
-
Takes the project brief and runs all steps automatically,
|
| 11 |
-
showing them sequentially in the output.
|
| 12 |
-
"""
|
| 13 |
output_text = ""
|
| 14 |
|
| 15 |
-
# Step 1:
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
output_text += "
|
| 19 |
-
|
|
|
|
|
|
|
| 20 |
output_text += f"- {t}\n"
|
| 21 |
|
| 22 |
-
# Step 2:
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
| 26 |
output_text += f"- {task} -> {agent}\n"
|
| 27 |
|
| 28 |
-
#
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
return output_text
|
| 32 |
|
| 33 |
with gr.Blocks() as demo:
|
| 34 |
-
gr.Markdown("## AI Project Coordinator
|
| 35 |
project_brief_input = gr.Textbox(lines=3, placeholder="Enter your project brief here...")
|
| 36 |
submit_button = gr.Button("Submit")
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
if __name__ == "__main__":
|
| 42 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from coordinator.coordinator import Coordinator
|
| 3 |
+
from coordinator.task_parser import parse_brief_with_reasoning
|
| 4 |
+
from coordinator.task_assigner import assign_tasks_with_reasoning
|
| 5 |
+
from frontend_agent.ui_generator import generate_react_component_llm
|
| 6 |
+
from backend_agent.api_generator import generate_backend_code_llm
|
| 7 |
|
|
|
|
| 8 |
coord = Coordinator()
|
| 9 |
|
| 10 |
+
def process_brief_with_reasoning(project_brief):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
output_text = ""
|
| 12 |
|
| 13 |
+
# Step 1: Parsing Tasks with reasoning
|
| 14 |
+
output_text += "### Step 1: Parsing Tasks\n"
|
| 15 |
+
parsing_result = parse_brief_with_reasoning(project_brief)
|
| 16 |
+
output_text += "**LLM Reasoning:**\n"
|
| 17 |
+
output_text += parsing_result["reasoning"] + "\n\n"
|
| 18 |
+
output_text += "**Parsed Tasks:**\n"
|
| 19 |
+
for t in parsing_result["tasks"]:
|
| 20 |
output_text += f"- {t}\n"
|
| 21 |
|
| 22 |
+
# Step 2: Assigning Tasks with reasoning
|
| 23 |
+
output_text += "\n### Step 2: Assigning Tasks\n"
|
| 24 |
+
assignment_result = assign_tasks_with_reasoning(parsing_result["tasks"])
|
| 25 |
+
output_text += "**LLM Reasoning:**\n"
|
| 26 |
+
output_text += assignment_result["reasoning"] + "\n\n"
|
| 27 |
+
output_text += "**Assigned Tasks:**\n"
|
| 28 |
+
for task, agent in assignment_result["assignments"].items():
|
| 29 |
output_text += f"- {task} -> {agent}\n"
|
| 30 |
|
| 31 |
+
# Step 3: Code Generation
|
| 32 |
+
output_text += "\n### Step 3: Code Generation\n"
|
| 33 |
+
for task, agent in assignment_result["assignments"].items():
|
| 34 |
+
output_text += f"\n#### {task} ({agent})\n"
|
| 35 |
+
if "frontend" in agent.lower():
|
| 36 |
+
code = generate_react_component_llm(task)
|
| 37 |
+
output_text += f"\n```jsx\n{code}\n```\n"
|
| 38 |
+
elif "backend" in agent.lower():
|
| 39 |
+
code = generate_backend_code_llm(task)
|
| 40 |
+
output_text += f"\n```python\n{code}\n```\n"
|
| 41 |
|
| 42 |
return output_text
|
| 43 |
|
| 44 |
with gr.Blocks() as demo:
|
| 45 |
+
gr.Markdown("## AI Project Coordinator - Step-by-Step Reasoning Log")
|
| 46 |
project_brief_input = gr.Textbox(lines=3, placeholder="Enter your project brief here...")
|
| 47 |
submit_button = gr.Button("Submit")
|
| 48 |
+
console_output = gr.Textbox(
|
| 49 |
+
label="Processing Log",
|
| 50 |
+
placeholder="LLM reasoning and outputs will appear here...",
|
| 51 |
+
lines=25
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
submit_button.click(
|
| 55 |
+
fn=process_brief_with_reasoning,
|
| 56 |
+
inputs=project_brief_input,
|
| 57 |
+
outputs=console_output
|
| 58 |
+
)
|
| 59 |
|
| 60 |
if __name__ == "__main__":
|
| 61 |
demo.launch()
|