Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -5,7 +5,7 @@ from dotenv import load_dotenv
|
|
5 |
from heyoo import WhatsApp
|
6 |
import assemblyai as aai
|
7 |
import openai
|
8 |
-
from utility import parse_multiple_transactions
|
9 |
from google.cloud import firestore
|
10 |
|
11 |
|
@@ -131,8 +131,24 @@ def hook():
|
|
131 |
print("Response:", response)
|
132 |
logging.info(f"\nAnswer: {response}\n")
|
133 |
# Handle cases where response is not a valid image path
|
134 |
-
messenger.send_message(message=f"{response}
|
135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
# elif message_type == "audio":
|
137 |
# audio = messenger.get_audio(data)
|
138 |
# audio_id, mime_type = audio["id"], audio["mime_type"]
|
|
|
5 |
from heyoo import WhatsApp
|
6 |
import assemblyai as aai
|
7 |
import openai
|
8 |
+
from utility import parse_multiple_transactions, create_transaction
|
9 |
from google.cloud import firestore
|
10 |
|
11 |
|
|
|
131 |
print("Response:", response)
|
132 |
logging.info(f"\nAnswer: {response}\n")
|
133 |
# Handle cases where response is not a valid image path
|
134 |
+
# messenger.send_message(message=f"{response}", recipient_id=mobile)
|
135 |
+
|
136 |
+
intent = parsed_trans_data[0]['intent'].lower()
|
137 |
+
if intent == 'create':
|
138 |
+
if create_transaction(mobile, parsed_trans_data):
|
139 |
+
firestore_msg = "Transaction recorded successfully!"
|
140 |
+
else:
|
141 |
+
firestore_msg = "Sorry, could not record transaction!"
|
142 |
+
elif intent == 'update': # handle update
|
143 |
+
pass
|
144 |
+
elif intent == 'delete': # handle delete
|
145 |
+
pass
|
146 |
+
else:
|
147 |
+
firestore_msg = f'The detected intent, {intent}, is not currently supported!'
|
148 |
+
|
149 |
+
messenger.send_message(message=f"{response},\n\n {firestore_msg}", recipient_id=mobile)
|
150 |
+
|
151 |
+
|
152 |
# elif message_type == "audio":
|
153 |
# audio = messenger.get_audio(data)
|
154 |
# audio_id, mime_type = audio["id"], audio["mime_type"]
|