Neurolingua commited on
Commit
85cb515
1 Parent(s): e5ecf3c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -11
app.py CHANGED
@@ -16,15 +16,7 @@ if not os.path.exists(UPLOAD_FOLDER):
16
  os.makedirs(UPLOAD_FOLDER)
17
 
18
  conversation_memory = ConversationBufferMemory(max_size=6)
19
- def handle_rates(sender, incoming_msg, chat_history):
20
- def callback(result):
21
- response_text = generate_response(incoming_msg + ' data ' + result, chat_history)
22
- conversation_memory.add_to_memory({"user": incoming_msg, "assistant": response_text})
23
- send_message(sender, response_text)
24
-
25
- result = get_rates()
26
- callback(result)
27
- # Initialize the Flask app
28
  account_sid = os.environ.get('TWILIO_ACCOUNT_SID')
29
  auth_token = os.environ.get('TWILIO_AUTH_TOKEN')
30
  client = Client(account_sid, auth_token)
@@ -76,8 +68,9 @@ def whatsapp_webhook():
76
  elif 'bookkeeping' in incoming_msg:
77
  response_text = "Please provide the details you'd like to record."
78
  elif ('rates' in incoming_msg.lower()) or ('price' in incoming_msg.lower()) or ('market' in incoming_msg.lower()) or ('rate' in incoming_msg.lower()) or ('prices' in incoming_msg.lower()):
79
- handle_rates(sender, incoming_msg, chat_history)
80
- return '', 204
 
81
  else:
82
  # Generate response considering the chat history
83
  response_text = generate_response(incoming_msg, chat_history)
 
16
  os.makedirs(UPLOAD_FOLDER)
17
 
18
  conversation_memory = ConversationBufferMemory(max_size=6)
19
+
 
 
 
 
 
 
 
 
20
  account_sid = os.environ.get('TWILIO_ACCOUNT_SID')
21
  auth_token = os.environ.get('TWILIO_AUTH_TOKEN')
22
  client = Client(account_sid, auth_token)
 
68
  elif 'bookkeeping' in incoming_msg:
69
  response_text = "Please provide the details you'd like to record."
70
  elif ('rates' in incoming_msg.lower()) or ('price' in incoming_msg.lower()) or ('market' in incoming_msg.lower()) or ('rate' in incoming_msg.lower()) or ('prices' in incoming_msg.lower()):
71
+ rates=get_rates()
72
+ response_text = generate_response(incoming_msg+'data is '+rates, chat_history)
73
+
74
  else:
75
  # Generate response considering the chat history
76
  response_text = generate_response(incoming_msg, chat_history)