Neurolingua commited on
Commit
9a053ad
·
verified ·
1 Parent(s): cbc123e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -43,6 +43,7 @@ Answer the question based on the above context: {question}
43
 
44
  @app.route('/whatsapp', methods=['POST'])
45
  def whatsapp_webhook():
 
46
  incoming_msg = request.values.get('Body', '').lower()
47
  sender = request.values.get('From')
48
  num_media = int(request.values.get('NumMedia', 0))
@@ -57,10 +58,11 @@ def whatsapp_webhook():
57
  # Handle image processing (disease/pest detection)
58
  filepath = convert_img(media_url, account_sid, auth_token)
59
  bd=extract_text_from_image(filepath)
60
- if bd=='':
61
- response_test=booktask(bd)
62
- # else 'none' not in filepath:
63
- # if predict_disease(filepath):
 
64
 
65
  response_text = predict_disease(filepath)
66
  elif predict_pest(filepath):
@@ -78,7 +80,8 @@ def whatsapp_webhook():
78
  'temperature' in incoming_msg.lower()):
79
  response_text = get_weather(incoming_msg.lower())
80
  elif 'bookkeeping' in incoming_msg:
81
- response_text = return_bookdata(incoming_msg)
 
82
  elif ('rates' in incoming_msg.lower()) or ('price' in incoming_msg.lower()) or (
83
  'market' in incoming_msg.lower()) or ('rate' in incoming_msg.lower()) or ('prices' in incoming_msg.lower()):
84
  rates = get_rates()
 
43
 
44
  @app.route('/whatsapp', methods=['POST'])
45
  def whatsapp_webhook():
46
+ global bookdata
47
  incoming_msg = request.values.get('Body', '').lower()
48
  sender = request.values.get('From')
49
  num_media = int(request.values.get('NumMedia', 0))
 
58
  # Handle image processing (disease/pest detection)
59
  filepath = convert_img(media_url, account_sid, auth_token)
60
  bd=extract_text_from_image(filepath)
61
+ if bd!='':
62
+ bookdata=booktask(bd+bookdata)
63
+ response_test="Your report for bookkeeping saved successfully."
64
+ elif 'none' not in filepath:
65
+ if predict_disease(filepath):
66
 
67
  response_text = predict_disease(filepath)
68
  elif predict_pest(filepath):
 
80
  'temperature' in incoming_msg.lower()):
81
  response_text = get_weather(incoming_msg.lower())
82
  elif 'bookkeeping' in incoming_msg:
83
+ bookdata=return_bookdata(incoming_msg,bookdata)
84
+ response_text = bookdata
85
  elif ('rates' in incoming_msg.lower()) or ('price' in incoming_msg.lower()) or (
86
  'market' in incoming_msg.lower()) or ('rate' in incoming_msg.lower()) or ('prices' in incoming_msg.lower()):
87
  rates = get_rates()