curiouscurrent commited on
Commit
93c7ffa
·
verified ·
1 Parent(s): 1c6c663

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -8
app.py CHANGED
@@ -1,35 +1,52 @@
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()
 
 
1
  import gradio as gr
2
  import asyncio
3
  from AI_Agent.coordinator import Coordinator
4
 
5
+ # Initialize coordinator
6
  coord = Coordinator()
7
 
8
+ # Async function to run the entire pipeline
9
  async def run_brief(brief):
10
  result = await coord.run_task(brief)
11
  return (
12
+ result["decomposition"]["tasks_text"], # Decomposed tasks
13
+ result["assignment"]["assigned_tasks_text"], # Assigned tasks
14
+ "\n".join(result["retrieval"]["contexts"]), # Retrieved contexts
15
+ result["reasoning"]["reasoning"], # Reasoning
16
+ result["synthesis"]["answer"] # Final synthesis
17
  )
18
 
19
+ # Wrapper to run async function synchronously for Gradio
20
  def run_brief_sync(brief):
21
  return asyncio.run(run_brief(brief))
22
 
23
+ # Build Gradio interface
24
  with gr.Blocks() as demo:
25
  gr.Markdown("## Multi-Chain AI Project Coordinator (HF-only)")
26
+
27
+ brief_input = gr.Textbox(
28
+ label="Project Brief",
29
+ placeholder="Enter your project brief here",
30
+ lines=2
31
+ )
32
+
33
  decomposition_output = gr.Textbox(label="Decomposed Tasks")
34
+ assignment_output = gr.Textbox(label="Assigned Tasks (Frontend/Backend)")
35
  retrieval_output = gr.Textbox(label="Retrieved Contexts")
36
  reasoning_output = gr.Textbox(label="Reasoning")
37
  synthesis_output = gr.Textbox(label="Synthesis / Final Answer")
38
 
39
+ run_button = gr.Button("Run Pipeline")
40
  run_button.click(
41
  run_brief_sync,
42
  inputs=[brief_input],
43
+ outputs=[
44
+ decomposition_output,
45
+ assignment_output,
46
+ retrieval_output,
47
+ reasoning_output,
48
+ synthesis_output
49
+ ]
50
  )
51
 
52
  demo.launch()