cfcooney commited on
Commit
0bf1803
·
verified ·
1 Parent(s): d0d8f33

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -1
app.py CHANGED
@@ -1,6 +1,7 @@
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
@@ -28,6 +29,31 @@ def list_model_downloads(task: str)-> str:
28
  """
29
  most_downloaded_model = next(iter(list_models(filter=task, sort="downloads", direction=-1)))
30
  return most_downloaded_model.modelId
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
 
33
  @tool
@@ -67,7 +93,7 @@ with open("prompts.yaml", 'r') as stream:
67
 
68
  agent = CodeAgent(
69
  model=model,
70
- tools=[final_answer, list_model_downloads], ## add your tools here (don't remove final answer)
71
  max_steps=6,
72
  verbosity_level=1,
73
  grammar=None,
 
1
  from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
  import datetime
3
  import requests
4
+ import random
5
  import pytz
6
  import yaml
7
  from tools.final_answer import FinalAnswerTool
 
29
  """
30
  most_downloaded_model = next(iter(list_models(filter=task, sort="downloads", direction=-1)))
31
  return most_downloaded_model.modelId
32
+
33
+
34
+ @tool
35
+ def get_email_template(sender: str, receiver: str)-> str:
36
+ """
37
+ A tool to generate an email template with an initial section addressing a person receiving the email and a
38
+ sign-off from the sender.
39
+ NOTE: the body of the email is not filled in here.
40
+ Args:
41
+ sender: The name of the person who is sending the email.
42
+ receiver: The name of the person who will receive the email.
43
+ """
44
+ greetings = ["Hello", "Hi", "Dear"]
45
+ signoffs = ["Kind regards", "Thanks", "Sincerely"]
46
+ greeting = random.choice(greetings)
47
+ signoff = random.choice(signoffs)
48
+ email_template = f"""\
49
+ {greeting} {receiver}, I hope you are well.
50
+
51
+
52
+ {signoff},
53
+ {sender}
54
+ """
55
+ return get_email_template
56
+
57
 
58
 
59
  @tool
 
93
 
94
  agent = CodeAgent(
95
  model=model,
96
+ tools=[final_answer, list_model_downloads, get_email_template], ## add your tools here (don't remove final answer)
97
  max_steps=6,
98
  verbosity_level=1,
99
  grammar=None,