curiouscurrent commited on
Commit
89a59ef
Β·
verified Β·
1 Parent(s): 6b6d94f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -48
app.py CHANGED
@@ -1,54 +1,35 @@
 
1
  import gradio as gr
2
- from chains.coordinator_chain import coordinator_chain
3
- from chains.frontend_chain import frontend_chain
4
- from chains.backend_chain import backend_chain
5
- from chains.review_chain import review_chain
6
-
7
-
8
- def ai_pipeline(brief):
9
- if not brief.strip():
10
- return "Please enter a valid project brief.", "", "", "", ""
11
-
12
- # Step 1 β€” Coordinator Agent
13
- tasks_json = coordinator_chain.run(brief)
14
-
15
- # Step 2 β€” Frontend Agent
16
- frontend_code = frontend_chain.run(tasks_json)
17
-
18
- # Step 3 β€” Backend Agent
19
- backend_code = backend_chain.run(tasks_json)
20
-
21
- # Step 4 β€” Review Agent
22
- review_notes = review_chain.run({
23
- "tasks": tasks_json,
24
- "frontend": frontend_code,
25
- "backend": backend_code
26
- })
27
-
28
- return tasks_json, frontend_code, backend_code, review_notes
29
-
30
-
31
- with gr.Blocks(title="AI Project Decomposer") as demo:
32
- gr.Markdown("# πŸ€– AI Project Decomposer (LangChain x HuggingFace)")
33
- gr.Markdown("Enter a project brief β€” the AI will split it into frontend/backend tasks and generate code!")
34
-
35
- brief = gr.Textbox(
36
- lines=6,
37
- label="Project Brief",
38
- placeholder="Example: Build a task management app with authentication and task sharing."
39
  )
40
 
41
- generate_btn = gr.Button("πŸš€ Generate Technical Plan")
42
-
43
- coordinator_out = gr.Code(label="🧠 Coordinator (Task Breakdown)", language="json")
44
- frontend_out = gr.Code(label="🎨 Frontend Agent (React Code)", language="javascript")
45
- backend_out = gr.Code(label="βš™οΈ Backend Agent (API + Schema)", language="python")
46
- review_out = gr.Textbox(label="πŸ” Review Agent Feedback", lines=6)
47
-
48
- generate_btn.click(
49
- ai_pipeline,
50
- inputs=brief,
51
- outputs=[coordinator_out, frontend_out, backend_out, review_out]
 
 
 
 
 
52
  )
53
 
54
  demo.launch()
 
1
+ # app.py
2
  import gradio as gr
3
+ import asyncio
4
+ from AI_Agent.coordinator import Coordinator
5
+
6
+ coord = Coordinator()
7
+
8
+ async def run_brief(brief):
9
+ result = await coord.run_task(brief)
10
+ return (
11
+ result["decomposition"]["tasks_text"],
12
+ "\n".join(result["retrieval"]["contexts"]),
13
+ result["reasoning"]["reasoning"],
14
+ result["synthesis"]["answer"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  )
16
 
17
+ def run_brief_sync(brief):
18
+ return asyncio.run(run_brief(brief))
19
+
20
+ with gr.Blocks() as demo:
21
+ gr.Markdown("## Multi-Chain AI Project Coordinator (HF-only)")
22
+ brief_input = gr.Textbox(label="Project Brief", placeholder="Enter your project brief here")
23
+ decomposition_output = gr.Textbox(label="Decomposed Tasks")
24
+ retrieval_output = gr.Textbox(label="Retrieved Contexts")
25
+ reasoning_output = gr.Textbox(label="Reasoning")
26
+ synthesis_output = gr.Textbox(label="Synthesis / Final Answer")
27
+
28
+ run_button = gr.Button("Run")
29
+ run_button.click(
30
+ run_brief_sync,
31
+ inputs=[brief_input],
32
+ outputs=[decomposition_output, retrieval_output, reasoning_output, synthesis_output]
33
  )
34
 
35
  demo.launch()