Spaces:
Sleeping
Sleeping
williamagyapong
commited on
Update main.py
Browse files
main.py
CHANGED
@@ -6,7 +6,7 @@ from dotenv import load_dotenv
|
|
6 |
from heyoo import WhatsApp
|
7 |
import assemblyai as aai
|
8 |
import openai
|
9 |
-
from utility import generateResponse, parse_multiple_transactions, create_inventory, create_sale, read_datalake
|
10 |
from google.cloud import firestore
|
11 |
import ast
|
12 |
|
@@ -132,13 +132,13 @@ def process_intent(parsed_trans_data, mobile):
|
|
132 |
trans_type = parsed_trans_data[0]['transaction_type'].lower()
|
133 |
|
134 |
if intent == 'create':
|
135 |
-
if trans_type
|
136 |
if create_inventory(mobile, parsed_trans_data):
|
137 |
firestore_msg = "Transaction recorded successfully!"
|
138 |
else:
|
139 |
firestore_msg = "Sorry, could not record transaction!"
|
140 |
|
141 |
-
elif trans_type
|
142 |
if create_sale(mobile, parsed_trans_data):
|
143 |
firestore_msg = "Transaction recorded successfully!"
|
144 |
else:
|
@@ -148,7 +148,12 @@ def process_intent(parsed_trans_data, mobile):
|
|
148 |
pass
|
149 |
|
150 |
elif intent == 'delete':
|
151 |
-
|
|
|
|
|
|
|
|
|
|
|
152 |
|
153 |
# elif intent == 'read':
|
154 |
# response = str(read_datalake(mobile, message))
|
|
|
6 |
from heyoo import WhatsApp
|
7 |
import assemblyai as aai
|
8 |
import openai
|
9 |
+
from utility import generateResponse, parse_multiple_transactions, create_inventory, create_sale, read_datalake, delete_transaction
|
10 |
from google.cloud import firestore
|
11 |
import ast
|
12 |
|
|
|
132 |
trans_type = parsed_trans_data[0]['transaction_type'].lower()
|
133 |
|
134 |
if intent == 'create':
|
135 |
+
if trans_type in ('purchase', 'purchases', 'inventory'):
|
136 |
if create_inventory(mobile, parsed_trans_data):
|
137 |
firestore_msg = "Transaction recorded successfully!"
|
138 |
else:
|
139 |
firestore_msg = "Sorry, could not record transaction!"
|
140 |
|
141 |
+
elif trans_type in ('sale', 'sales'):
|
142 |
if create_sale(mobile, parsed_trans_data):
|
143 |
firestore_msg = "Transaction recorded successfully!"
|
144 |
else:
|
|
|
148 |
pass
|
149 |
|
150 |
elif intent == 'delete':
|
151 |
+
item = parsed_trans_data[0]['details']['item']
|
152 |
+
item_deleted = delete_transaction(mobile, parsed_trans_data)
|
153 |
+
if item_deleted:
|
154 |
+
firestore_msg = f"You successfully deleted {item} from {trans_type}!"
|
155 |
+
else:
|
156 |
+
firestore_msg = f"Sorry, could not delete the {item} from {trans_type}!"
|
157 |
|
158 |
# elif intent == 'read':
|
159 |
# response = str(read_datalake(mobile, message))
|