Rehman1603 commited on
Commit
0fd2df7
·
verified ·
1 Parent(s): 62c55b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -43
app.py CHANGED
@@ -41,7 +41,6 @@ def update_csv_files():
41
 
42
  # Check the status and get the response data
43
  if response.status_code == 200:
44
- print("Login successful!")
45
  access_token = response.json()['access_token']
46
  else:
47
  return f"Failed to log in: {response.status_code}"
@@ -84,7 +83,6 @@ def update_csv_files():
84
  def initialize_embedding():
85
  global vectorstore
86
  # Initialize the embedding function
87
-
88
 
89
  # Load CSV files
90
  file_paths = [
@@ -133,44 +131,7 @@ Generate the response according to the user's query:
133
  ⭕ Note: If at any stage you wish to go back to the previous menu, type back, and to go to the main menu, type main menu.
134
  ⭕ Note: If you want to change the language, type and send 'change language.'
135
  💁🏻♂️ Help: If you need any help, you can call us at +923269498569."
136
- - If the user enters a specific number (1-7), give the following responses:
137
- - If the user enters only 1, give the following response:
138
- If you are interested in insights related to your business, please find the available reports below:
139
- -> Profit Loss Report: Detailed analysis of your financial performance.
140
- -> Stock Report: Overview of your current inventory status.
141
- -> Sales Report: Summary of sales activities.
142
- -> Purchase Report: Insights into procurement activities.
143
- -> Trending Item Report: Highlights of popular products in demand.
144
- - If the user enters only 2, give the following response:
145
- For strategic planning and inventory management, consider the following forecasts:
146
- -> Sales Forecast: Projected sales for upcoming periods.
147
- -> Product Sales Forecast: Expected sales performance of specific products.
148
- - If the user enters only 3, give the following response:
149
- -> You have expressed interest in identifying the best-selling item. Please allow me to provide you with detailed insights.
150
- - If the user enters only 4, give the following response:
151
- -> Feel free to ask any questions regarding the status of your business. I’m here to assist you.
152
- - If the user enters only 5, give the following response:
153
- For inquiries or further assistance, please send your query to:
154
- -> Contact Number: +923269498569
155
- - If the user enters only 6, give the following response:
156
- Your feedback is invaluable to us. Kindly share your thoughts and suggestions at:
157
- -> Contact Number: +923269498569
158
- - If the user enters only 7, give the following response:
159
- -> Check out our latest offers and promotions to maximize your business potential.
160
- - **Fallback**: If the query doesn't match a greeting or a specific command (1-7), provide a professional and clean response based on the user's question.
161
- When answering based on retrieved documents, make sure to exclude unnecessary metadata (like document IDs) and display only the relevant content. For example, extract the actual report details such as sales, purchases, and other key information without showing raw document metadata.
162
- Example response for a "purchase report":
163
- "It seems like you're asking about the purchase report. Here's what I found:
164
- - Total Purchase (including tax): 3150.00
165
- - Total Purchase (excluding tax): 3150.00
166
- - Purchase Due: 3150.00
167
- - Shipping Charges: 0.00
168
- - Additional Expenses: 0.00
169
- - Sales Total (including tax): 1000000000000953067.33
170
- - Sales Total (excluding tax): 1000000000000945928.50"
171
- Ensure the information is formatted clearly and no irrelevant document information (such as IDs or metadata) is displayed.
172
- Context: {retrieved_documents}
173
- Question: {query}
174
  """
175
  prompt = PromptTemplate(
176
  input_variables=['retrieved_documents', 'query'],
@@ -191,7 +152,9 @@ Question: {query}
191
  # Define Gradio UI
192
  with gr.Blocks() as demo:
193
  chatbot = gr.Chatbot(label="AI Chat")
194
- query = gr.Textbox(label="Ask anything!")
 
 
195
  initialize_button = gr.Button("Initialize Embeddings")
196
  update_csv_button = gr.Button("Update CSV Files")
197
 
@@ -200,8 +163,8 @@ with gr.Blocks() as demo:
200
 
201
  query.submit(on_query, [query, chatbot], [chatbot, query])
202
 
203
- initialize_button.click(initialize_embedding, outputs=None)
204
- update_csv_button.click(update_csv_files, outputs=None)
205
 
206
  # Launch Gradio App
207
  demo.launch()
 
41
 
42
  # Check the status and get the response data
43
  if response.status_code == 200:
 
44
  access_token = response.json()['access_token']
45
  else:
46
  return f"Failed to log in: {response.status_code}"
 
83
  def initialize_embedding():
84
  global vectorstore
85
  # Initialize the embedding function
 
86
 
87
  # Load CSV files
88
  file_paths = [
 
131
  ⭕ Note: If at any stage you wish to go back to the previous menu, type back, and to go to the main menu, type main menu.
132
  ⭕ Note: If you want to change the language, type and send 'change language.'
133
  💁🏻♂️ Help: If you need any help, you can call us at +923269498569."
134
+ - If the user enters a specific number (1-7), give the following responses...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  """
136
  prompt = PromptTemplate(
137
  input_variables=['retrieved_documents', 'query'],
 
152
  # Define Gradio UI
153
  with gr.Blocks() as demo:
154
  chatbot = gr.Chatbot(label="AI Chat")
155
+ query = gr.Textbox(label="Ask anything!", placeholder="Type your question here")
156
+ initialize_status = gr.Textbox(label="Status", visible=False)
157
+ update_csv_status = gr.Textbox(label="Status", visible=False)
158
  initialize_button = gr.Button("Initialize Embeddings")
159
  update_csv_button = gr.Button("Update CSV Files")
160
 
 
163
 
164
  query.submit(on_query, [query, chatbot], [chatbot, query])
165
 
166
+ initialize_button.click(initialize_embedding, outputs=initialize_status)
167
+ update_csv_button.click(update_csv_files, outputs=update_csv_status)
168
 
169
  # Launch Gradio App
170
  demo.launch()