Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,54 +1,35 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
| 3 |
-
from
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 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 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|