alex-i07 commited on
Commit
4bbe0d4
·
1 Parent(s): 29ec968

EveningWatch Agent, initial commit

Browse files
Files changed (3) hide show
  1. Gradio_UI.py +17 -3
  2. app.py +12 -7
  3. prompts.yaml +3 -0
Gradio_UI.py CHANGED
@@ -264,11 +264,17 @@ class GradioUI:
264
  with gr.Blocks(fill_height=True) as demo:
265
  stored_messages = gr.State([])
266
  file_uploads_log = gr.State([])
 
 
 
 
 
 
267
  chatbot = gr.Chatbot(
268
  label="Agent",
269
  type="messages",
270
  avatar_images=(
271
- None,
272
  "https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/communication/Alfred.png",
273
  ),
274
  resizeable=True,
@@ -283,6 +289,7 @@ class GradioUI:
283
  [upload_file, file_uploads_log],
284
  [upload_status, file_uploads_log],
285
  )
 
286
  text_input = gr.Textbox(lines=1, label="Chat Message")
287
  text_input.submit(
288
  self.log_user_message,
@@ -290,7 +297,14 @@ class GradioUI:
290
  [stored_messages, text_input],
291
  ).then(self.interact_with_agent, [stored_messages, chatbot], [chatbot])
292
 
293
- demo.launch(debug=True, share=True, **kwargs)
 
 
 
 
 
 
294
 
 
295
 
296
- __all__ = ["stream_to_gradio", "GradioUI"]
 
264
  with gr.Blocks(fill_height=True) as demo:
265
  stored_messages = gr.State([])
266
  file_uploads_log = gr.State([])
267
+ gr.Markdown(
268
+ """
269
+ # EveningWatch Agent
270
+ Hello, friend! I can help you find movie or series to watch in the evening. Just use examples or make your own request!
271
+ """
272
+ )
273
  chatbot = gr.Chatbot(
274
  label="Agent",
275
  type="messages",
276
  avatar_images=(
277
+ "https://huggingface.co/avatars/12374769a98026bc588d4ee6540083c3.svg",
278
  "https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/communication/Alfred.png",
279
  ),
280
  resizeable=True,
 
289
  [upload_file, file_uploads_log],
290
  [upload_status, file_uploads_log],
291
  )
292
+
293
  text_input = gr.Textbox(lines=1, label="Chat Message")
294
  text_input.submit(
295
  self.log_user_message,
 
297
  [stored_messages, text_input],
298
  ).then(self.interact_with_agent, [stored_messages, chatbot], [chatbot])
299
 
300
+ submit_btn = gr.Button(value="Submit")
301
+ txt_msg = submit_btn.click(
302
+ self.log_user_message,
303
+ [text_input, file_uploads_log],
304
+ [stored_messages, text_input],
305
+ ).then(self.interact_with_agent, [stored_messages, chatbot], [chatbot])
306
+ examples = gr.Examples(examples=[['Recommend me any good movie'], ['Suggest some famous new movie with Rebecca Ferguson'],['Want a long interesting series of premiered not late than 10 years ago']], inputs=text_input)
307
 
308
+ demo.launch(debug=True, share=True, **kwargs)
309
 
310
+ __all__ = ["stream_to_gradio", "GradioUI"]
app.py CHANGED
@@ -1,22 +1,26 @@
1
- from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
 
2
  import datetime
3
  import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
 
 
7
 
8
  from Gradio_UI import GradioUI
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
- def my_cutom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
13
  #Keep this format for the description / args / args description but feel free to modify the tool
14
  """A tool that does nothing yet
15
  Args:
16
  arg1: the first argument
17
  arg2: the second argument
18
  """
19
- return "What magic will you build ?"
 
20
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -33,8 +37,10 @@ def get_current_time_in_timezone(timezone: str) -> str:
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
36
-
 
37
  final_answer = FinalAnswerTool()
 
38
  model = HfApiModel(
39
  max_tokens=2096,
40
  temperature=0.5,
@@ -51,7 +57,7 @@ with open("prompts.yaml", 'r') as stream:
51
 
52
  agent = CodeAgent(
53
  model=model,
54
- tools=[final_answer], ## add your tools here (don't remove final answer)
55
  max_steps=6,
56
  verbosity_level=1,
57
  grammar=None,
@@ -61,5 +67,4 @@ agent = CodeAgent(
61
  prompt_templates=prompt_templates
62
  )
63
 
64
-
65
- GradioUI(agent).launch()
 
1
+ from smolagents import CodeAgent, HfApiModel,load_tool,tool
2
+ import os
3
  import datetime
4
  import requests
5
  import pytz
6
  import yaml
7
  from tools.final_answer import FinalAnswerTool
8
+ from tools.visit_webpage import VisitWebpageTool
9
+ from tools.web_search import DuckDuckGoSearchTool
10
 
11
  from Gradio_UI import GradioUI
12
 
13
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
14
  @tool
15
+ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
16
  #Keep this format for the description / args / args description but feel free to modify the tool
17
  """A tool that does nothing yet
18
  Args:
19
  arg1: the first argument
20
  arg2: the second argument
21
  """
22
+
23
+ return "Str"
24
 
25
  @tool
26
  def get_current_time_in_timezone(timezone: str) -> str:
 
37
  except Exception as e:
38
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
39
 
40
+ web_search = DuckDuckGoSearchTool()
41
+ visit_webpage = VisitWebpageTool()
42
  final_answer = FinalAnswerTool()
43
+
44
  model = HfApiModel(
45
  max_tokens=2096,
46
  temperature=0.5,
 
57
 
58
  agent = CodeAgent(
59
  model=model,
60
+ tools=[web_search, visit_webpage, final_answer], ## add your tools here (don't remove final answer)
61
  max_steps=6,
62
  verbosity_level=1,
63
  grammar=None,
 
67
  prompt_templates=prompt_templates
68
  )
69
 
70
+ GradioUI(agent).launch()
 
prompts.yaml CHANGED
@@ -9,6 +9,9 @@
9
  These print outputs will then appear in the 'Observation:' field, which will be available as input for the next step.
10
  In the end you have to return a final answer using the `final_answer` tool.
11
 
 
 
 
12
  Here are a few examples using notional tools:
13
  ---
14
  Task: "Generate an image of the oldest person in this document."
 
9
  These print outputs will then appear in the 'Observation:' field, which will be available as input for the next step.
10
  In the end you have to return a final answer using the `final_answer` tool.
11
 
12
+ If user requests mentions any movie or series you must provide small description of this movie and series from the internet.
13
+ In the final answer append one or two sentences friendly saying why user should watch this movie.
14
+
15
  Here are a few examples using notional tools:
16
  ---
17
  Task: "Generate an image of the oldest person in this document."