DenverJones commited on
Commit
d636e38
·
verified ·
1 Parent(s): 03cd7e0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -4
app.py CHANGED
@@ -1,6 +1,6 @@
1
  from smolagents import CodeAgent, HfApiModel, tool
2
  import yaml
3
- from Gradio_UI import GradioUI
4
 
5
  # Define a tool to generate motivational quotes
6
  @tool
@@ -35,9 +35,28 @@ agent = CodeAgent(
35
  verbosity_level=1,
36
  name="MotivationAgent",
37
  description="An agent that provides motivational quotes to inspire users.",
38
- prompt_templates=prompt_templates,
39
  )
40
 
41
- # Launch the Gradio UI
42
- GradioUI(agent).launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
 
1
  from smolagents import CodeAgent, HfApiModel, tool
2
  import yaml
3
+ import gradio as gr
4
 
5
  # Define a tool to generate motivational quotes
6
  @tool
 
35
  verbosity_level=1,
36
  name="MotivationAgent",
37
  description="An agent that provides motivational quotes to inspire users.",
38
+ prompt_templates=prompt_templates
39
  )
40
 
41
+ # Define chat function
42
+ def chat_with_agent(user_input, history):
43
+ if not user_input.strip():
44
+ return history + [[user_input, "Please enter a message to start the conversation!"]]
45
+
46
+ response = agent.run(user_input)
47
+ history.append([user_input, response])
48
+ return history
49
+
50
+ # Create Gradio Chat UI
51
+ with gr.Blocks() as demo:
52
+ gr.Markdown("### Welcome to MotivationAgent! 🌟\nType a message to receive a motivational quote or an uplifting response.")
53
+
54
+ chatbot = gr.Chatbot(label="MotivationAgent")
55
+ user_input = gr.Textbox(placeholder="Ask me for motivation... (e.g., 'I need inspiration')")
56
+
57
+ submit_btn = gr.Button("Send")
58
+ submit_btn.click(chat_with_agent, inputs=[user_input, chatbot], outputs=chatbot)
59
+
60
+ demo.launch()
61
+
62