Neurolingua commited on
Commit
a6765a2
1 Parent(s): 29191e5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -3,7 +3,7 @@ from twilio.twiml.messaging_response import MessagingResponse
3
  from twilio.rest import Client
4
  import os
5
  import shutil
6
- from other_function import ConversationBufferMemory,generate_response,get_weather,get_rates,get_news,convert_img,predict_disease,predict_pest, download_and_save_as_txt,respond_pdf
7
  from bs4 import BeautifulSoup
8
  import requests
9
  from requests.auth import HTTPBasicAuth
@@ -24,7 +24,7 @@ if not os.path.exists(UPLOAD_FOLDER):
24
  os.makedirs(UPLOAD_FOLDER)
25
 
26
  app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
27
-
28
  conversation_memory = ConversationBufferMemory(max_size=0)
29
 
30
  account_sid = os.environ.get('TWILIO_ACCOUNT_SID')
@@ -56,7 +56,10 @@ def whatsapp_webhook():
56
  if content_type.startswith('image/'):
57
  # Handle image processing (disease/pest detection)
58
  filepath = convert_img(media_url, account_sid, auth_token)
59
- if 'none' not in filepath:
 
 
 
60
  if predict_disease(filepath):
61
 
62
  response_text = predict_disease(filepath)
@@ -75,7 +78,7 @@ def whatsapp_webhook():
75
  'temperature' in incoming_msg.lower()):
76
  response_text = get_weather(incoming_msg.lower())
77
  elif 'bookkeeping' in incoming_msg:
78
- response_text = "Please provide the details you'd like to record."
79
  elif ('rates' in incoming_msg.lower()) or ('price' in incoming_msg.lower()) or (
80
  'market' in incoming_msg.lower()) or ('rate' in incoming_msg.lower()) or ('prices' in incoming_msg.lower()):
81
  rates = get_rates()
 
3
  from twilio.rest import Client
4
  import os
5
  import shutil
6
+ from other_function import ConversationBufferMemory,generate_response,get_weather,get_rates,get_news,convert_img,predict_disease,predict_pest, download_and_save_as_txt,respond_pdf,extract_text_from_image,booktask,return_bookdata
7
  from bs4 import BeautifulSoup
8
  import requests
9
  from requests.auth import HTTPBasicAuth
 
24
  os.makedirs(UPLOAD_FOLDER)
25
 
26
  app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
27
+ bookdata=''
28
  conversation_memory = ConversationBufferMemory(max_size=0)
29
 
30
  account_sid = os.environ.get('TWILIO_ACCOUNT_SID')
 
56
  if content_type.startswith('image/'):
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)
 
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()