curiouscurrent commited on
Commit
5b91549
·
verified ·
1 Parent(s): a4d649d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -22
app.py CHANGED
@@ -1,42 +1,61 @@
1
  import gradio as gr
2
  from coordinator.coordinator import Coordinator
3
- from coordinator.task_assigner import assign_tasks as llm_assign
 
 
 
4
 
5
- # Initialize Coordinator
6
  coord = Coordinator()
7
 
8
- def process_brief(project_brief):
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: Parse tasks
16
- tasks = coord.run(project_brief) # returns dict {task: agent}, but only tasks for now
17
- parsed_tasks = list(tasks.keys())
18
- output_text += "### Step 1: Parsed Tasks\n"
19
- for t in parsed_tasks:
 
 
20
  output_text += f"- {t}\n"
21
 
22
- # Step 2: Assign tasks
23
- assignments = llm_assign(parsed_tasks)
24
- output_text += "\n### Step 2: Assigned Tasks\n"
25
- for task, agent in assignments.items():
 
 
 
26
  output_text += f"- {task} -> {agent}\n"
27
 
28
- # Future steps (Frontend/Backend generation) can be added here
29
- # output_text += "\n### Step 3: Frontend/Backend Code Generated\n..."
 
 
 
 
 
 
 
 
30
 
31
  return output_text
32
 
33
  with gr.Blocks() as demo:
34
- gr.Markdown("## AI Project Coordinator (Automatic Step-by-Step)")
35
  project_brief_input = gr.Textbox(lines=3, placeholder="Enter your project brief here...")
36
  submit_button = gr.Button("Submit")
37
- output_box = gr.Markdown()
38
-
39
- submit_button.click(fn=process_brief, inputs=project_brief_input, outputs=output_box)
 
 
 
 
 
 
 
 
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()