AhmedEwis commited on
Commit
2d06113
1 Parent(s): 24bfff8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -6
app.py CHANGED
@@ -58,14 +58,26 @@ def construct_index(directory_path):
58
  #import streamlit as st
59
  # Include other necessary imports here
60
 
 
 
 
 
61
  def ask_ai(query):
62
- index = GPTSimpleVectorIndex.load_from_disk('index.json')
63
- response = index.query(query, response_mode="compact")
64
- return response.response
65
-
66
- iface = gr.Interface(fn=ask_ai, inputs="text", outputs="text", title="The following is a conversation with a human called Shegardi. Shegardi is helpful, precise, truthful, and very friendly.  Also, Shegardi is an employee of Warba Bank, located in Kuwait. Shegardi will only use the information provided to him. ",
 
 
 
 
 
 
 
 
 
67
  description="Enter a question and get an answer from Shegardi.")
68
-
69
  iface.launch()
70
 
71
 
@@ -74,3 +86,4 @@ iface.launch()
74
 
75
 
76
 
 
 
58
  #import streamlit as st
59
  # Include other necessary imports here
60
 
61
+ def is_query_about_cashback(query):
62
+ cashback_keywords = ["cashback", "calculate", "calculation", "reward", "points"]
63
+ return any(word.lower() in query.lower() for word in cashback_keywords)
64
+
65
  def ask_ai(query):
66
+ if is_query_about_cashback(query):
67
+ # Extract the required information from the query or ask the user for more information if needed
68
+ segment = input("Enter your card segment: ")
69
+ total_spent = float(input("Enter your total spent amount: "))
70
+ international_transactions = float(input("Enter your international transactions amount: "))
71
+ local_transactions = float(input("Enter your local transactions amount: "))
72
+
73
+ cashback = cashback_calculator(segment, total_spent, international_transactions, local_transactions)
74
+ return f"The cashback amount for your card is: {cashback:.2f}"
75
+ else:
76
+ index = GPTSimpleVectorIndex.load_from_disk('index.json')
77
+ response = index.query(query, response_mode="compact")
78
+ return response.response
79
+ iface = gr.Interface(fn=ask_ai, inputs=["text", "text", "number", "number", "number"], outputs="text", title="The following is a conversation with a human called Shegardi. Shegardi is helpful, precise, truthful, and very friendly. Also, Shegardi is an employee of Warba Bank, located in Kuwait. Shegardi will only use the information provided to him.",
80
  description="Enter a question and get an answer from Shegardi.")
 
81
  iface.launch()
82
 
83
 
 
86
 
87
 
88
 
89
+