williamagyapong commited on
Commit
24eb598
·
verified ·
1 Parent(s): 792cfef

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +13 -7
main.py CHANGED
@@ -90,11 +90,15 @@ def respond(query_str: str):
90
  response = "hello, I don't have a brain yet"
91
  return response
92
 
93
- def process_user_msg(message, mobile):
94
  response = str(generateResponse(message))
95
  parsed_trans_data = parse_multiple_transactions(response)
96
  # return None, parsed_trans_data, response
97
  logging.info(f"\nAnswer: {response}\n")
 
 
 
 
98
 
99
  intent = parsed_trans_data[0]['intent'].lower()
100
  trans_type = parsed_trans_data[0]['transaction_type'].lower()
@@ -157,10 +161,11 @@ def hook():
157
 
158
  messenger.send_message(message=f"{response}", recipient_id=mobile)
159
  else:
160
- firestore_msg1, parsed_trans_data1, response1 = process_user_msg(message, mobile)
161
- messenger_reply_button(mobile, parsed_trans_data1)
 
162
 
163
- messenger.send_message(f"Raw Response: {response1}, \n \n Parsed Response: {parsed_trans_data1}, \n \n Final Response: {firestore_msg1}", recipient_id=mobile)
164
 
165
  elif message_type == "audio":
166
  audio = messenger.get_audio(data)
@@ -173,9 +178,10 @@ def hook():
173
  transcribed_message = transcript.text
174
 
175
  # logging.info(f"\nAudio: {audio}\n")
176
- messenger_reply_button(mobile, transcribed_message)
177
- firestore_msg1, parsed_trans_data1, response1 = process_user_msg(transcribed_message, mobile)
178
- messenger.send_message(message=f"Raw Response: {response1}, \n \n Parsed Response: {parsed_trans_data1}, \n \n Final Response: {firestore_msg1}", recipient_id=mobile)
 
179
  elif message_type == "interactive":
180
  message_response = messenger.get_interactive_response(data)
181
  interactive_type = message_response.get("type")
 
90
  response = "hello, I don't have a brain yet"
91
  return response
92
 
93
+ def process_user_msg(message):
94
  response = str(generateResponse(message))
95
  parsed_trans_data = parse_multiple_transactions(response)
96
  # return None, parsed_trans_data, response
97
  logging.info(f"\nAnswer: {response}\n")
98
+ return response, parsed_trans_data
99
+
100
+
101
+ def process_intent(response, parsed_trans_data, mobile):
102
 
103
  intent = parsed_trans_data[0]['intent'].lower()
104
  trans_type = parsed_trans_data[0]['transaction_type'].lower()
 
161
 
162
  messenger.send_message(message=f"{response}", recipient_id=mobile)
163
  else:
164
+ # firestore_msg1, parsed_trans_data1, response1 = process_user_msg(message, mobile)
165
+ response, parsed_trans_data = process_user_msg(message)
166
+ messenger_reply_button(mobile, f"Raw Response: {response}, \n \n Parsed Response: {parsed_trans_data}")
167
 
168
+ # messenger.send_message(f"Raw Response: {response1}, \n \n Parsed Response: {parsed_trans_data1}, \n \n Final Response: {firestore_msg1}", recipient_id=mobile)
169
 
170
  elif message_type == "audio":
171
  audio = messenger.get_audio(data)
 
178
  transcribed_message = transcript.text
179
 
180
  # logging.info(f"\nAudio: {audio}\n")
181
+ response, parsed_trans_data = process_user_msg(message)
182
+ messenger_reply_button(mobile, f"Raw Response: {response}, \n \n Parsed Response: {parsed_trans_data}")
183
+ # firestore_msg1, parsed_trans_data1, response1 = process_user_msg(transcribed_message, mobile)
184
+ # messenger.send_message(message=f"Raw Response: {response1}, \n \n Parsed Response: {parsed_trans_data1}, \n \n Final Response: {firestore_msg1}", recipient_id=mobile)
185
  elif message_type == "interactive":
186
  message_response = messenger.get_interactive_response(data)
187
  interactive_type = message_response.get("type")