tiantian-paris commited on
Commit
d6a6e99
·
1 Parent(s): 6970b71
Files changed (1) hide show
  1. app.py +19 -2
app.py CHANGED
@@ -40,7 +40,7 @@ visit_webpage = VisitWebpageTool()
40
  web_search = DuckDuckGoSearchTool()
41
 
42
  @tool
43
- def send_message(query: str) -> str:
44
  """
45
  send a message to me directly
46
 
@@ -52,6 +52,7 @@ def send_message(query: str) -> str:
52
  """
53
  try:
54
  # Create the email message
 
55
  with smtplib.SMTP("smtp.gmail.com") as connection:
56
  connection.starttls()
57
  connection.login(MY_EMAIL, MY_PASSWORD)
@@ -119,6 +120,22 @@ agent = CodeAgent(
119
  #prompt_templates=prompt_templates
120
  )
121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
 
123
 
124
  def chatbot_response_json(user_input):
@@ -128,7 +145,7 @@ def chatbot_response_json(user_input):
128
  my_info = json.load(file)
129
  if "send message" in user_input:
130
  return send_message(user_input)
131
- if "who" in user_input or "about" in user_input or "introduce" in user_input or "presentation" in user_input:
132
  return f" {my_info['introduction']}."
133
  elif "name" in user_input:
134
  return f"My name is {my_info['name']}."
 
40
  web_search = DuckDuckGoSearchTool()
41
 
42
  @tool
43
+ def send_message_tool(query: str) -> str:
44
  """
45
  send a message to me directly
46
 
 
52
  """
53
  try:
54
  # Create the email message
55
+ print("sending mail")
56
  with smtplib.SMTP("smtp.gmail.com") as connection:
57
  connection.starttls()
58
  connection.login(MY_EMAIL, MY_PASSWORD)
 
120
  #prompt_templates=prompt_templates
121
  )
122
 
123
+ def send_message(user_input):
124
+ try:
125
+ # Create the email message
126
+ print("sending mail")
127
+ print("sending mail")
128
+ with smtplib.SMTP("smtp.gmail.com") as connection:
129
+ connection.starttls()
130
+ connection.login(MY_EMAIL, MY_PASSWORD)
131
+ connection.sendmail(from_addr=MY_EMAIL,
132
+ to_addrs=MY_EMAIL,
133
+ msg=f"Subject: message from chatbot \n\n{user_input}")
134
+
135
+ return f"Message sent to tianqing successfully!"
136
+ except Exception as e:
137
+ return f"Failed to send email: {e}"
138
+
139
 
140
 
141
  def chatbot_response_json(user_input):
 
145
  my_info = json.load(file)
146
  if "send message" in user_input:
147
  return send_message(user_input)
148
+ elif "who" in user_input or "about" in user_input or "introduce" in user_input or "presentation" in user_input:
149
  return f" {my_info['introduction']}."
150
  elif "name" in user_input:
151
  return f"My name is {my_info['name']}."