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