Rahul-8799 commited on
Commit
2c797e9
·
verified ·
1 Parent(s): c9d170c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -22
app.py CHANGED
@@ -1,28 +1,31 @@
1
  import gradio as gr
2
- from utils.run_pipeline_and_save import run_pipeline_and_save
3
  from utils.zip_output import zip_output
4
 
5
- import os
6
- os.environ["PYTORCH_SDP_ATTENTION"] = "math"
7
-
8
- def run_agents(prompt):
9
- if not prompt.strip():
10
- return "Please enter a prompt.", None, None
11
  chat_log, final_output = run_pipeline_and_save(prompt)
12
- log_str = "\n\n".join([f"### {list(item.keys())[0]}\n{list(item.values())[0]}" for item in chat_log])
13
- zip_path = zip_output()
14
- return log_str, zip_path, "output/agent_log.json"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
- iface = gr.Interface(
17
- fn=run_agents,
18
- inputs=gr.Textbox(lines=10, label="Enter your product idea prompt"),
19
- outputs=[
20
- gr.Textbox(label="Agent Conversation Log", lines=20),
21
- gr.File(label="Download UI Files (ZIP)"),
22
- gr.File(label="Download Agent Log (JSON)"),
23
- ],
24
- title="Multi-Agent UI Generator",
25
- )
26
 
27
- if __name__ == "__main__":
28
- iface.launch()
 
1
  import gradio as gr
2
+ from utils.langgraph_pipeline import run_pipeline_and_save
3
  from utils.zip_output import zip_output
4
 
5
+ def handle_run(prompt):
 
 
 
 
 
6
  chat_log, final_output = run_pipeline_and_save(prompt)
7
+ return (
8
+ [(f"{agent}", msg) for step in chat_log for agent, msg in step.items()],
9
+ "output/index.html",
10
+ "output/agent_log.json",
11
+ zip_output()
12
+ )
13
+
14
+ with gr.Blocks() as demo:
15
+ gr.Markdown("# 🔗 Multi-Agent Collaboration with LangGraph")
16
+
17
+ prompt_input = gr.Textbox(label="Enter your prompt", lines=4, placeholder="Describe your product idea...")
18
+ submit_btn = gr.Button("Run Agents")
19
+
20
+ chatbox = gr.Chatbot(label="Agent Conversation Log")
21
+ html_out = gr.File(label="index.html")
22
+ log_out = gr.File(label="Agent Log")
23
+ zip_out = gr.File(label="ZIP Output")
24
 
25
+ submit_btn.click(
26
+ fn=handle_run,
27
+ inputs=prompt_input,
28
+ outputs=[chatbox, html_out, log_out, zip_out]
29
+ )
 
 
 
 
 
30
 
31
+ demo.launch()