GT5557 commited on
Commit
badb59e
·
verified ·
1 Parent(s): 0647808

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -2
app.py CHANGED
@@ -49,5 +49,33 @@ agent = CodeAgent(
49
  )
50
 
51
 
52
- from smolagents import GradioUI
53
- GradioUI(agent).launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  )
50
 
51
 
52
+ import gradio as gr
53
+
54
+ def handle_query(query):
55
+ # This calls your agent and returns the generator/answer
56
+ yield agent.run(query)
57
+
58
+ # Minimalist UI compatible with Gradio 4, 5, and 6
59
+ with gr.Blocks() as demo:
60
+ gr.Markdown("# Agentic AI - Final Project")
61
+ chatbot = gr.Chatbot(label="Agent") # No 'type' argument = No crash
62
+ msg = gr.Textbox(label="Enter your task:")
63
+ clear = gr.Button("Clear")
64
+
65
+ def user(user_message, history):
66
+ return "", history + [[user_message, None]]
67
+
68
+ def bot(history):
69
+ # Access the last message sent by user
70
+ user_message = history[-1][0]
71
+ # Get response from your agent
72
+ bot_message = agent.run(user_message)
73
+ history[-1][1] = bot_message
74
+ yield history
75
+
76
+ msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
77
+ bot, chatbot, chatbot
78
+ )
79
+ clear.click(lambda: None, None, chatbot, queue=False)
80
+
81
+ demo.launch()