MohammedNasser commited on
Commit
4851309
1 Parent(s): 6c6890f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -193,16 +193,16 @@ def validate_pdf(pdf):
193
  return "الملف صالح للدردشة", True
194
 
195
  def upload_pdf(pdf_file):
196
- global vectorstore, chain,chathistory
197
  chathistory = []
198
  data = load_pdf(pdf_file)
199
  vectorstore = prepare_vectorstore(data)
200
- chain = create_chain(vectorstore)
201
  return "تم تحميل الملف بنجاح !", True
202
 
203
 
204
  def chat(user_input):
205
- global chain, chathistory
206
 
207
 
208
  prompt = f"""
@@ -211,10 +211,10 @@ def chat(user_input):
211
  - Your answer directly reflects the content of the document.
212
  - If the requested information is not available in the document, clearly state that in Arabic.
213
  - Keep your response concise yet comprehensive, addressing the question fully.
214
- - Always respond only in a professional and well-versed Arabic Language.
215
  Question: {user_input}.
216
  """
217
-
218
  response = chain({"question": prompt})
219
  assistant_response = response["answer"]
220
 
 
193
  return "الملف صالح للدردشة", True
194
 
195
  def upload_pdf(pdf_file):
196
+ global vectorstore, chathistory
197
  chathistory = []
198
  data = load_pdf(pdf_file)
199
  vectorstore = prepare_vectorstore(data)
200
+
201
  return "تم تحميل الملف بنجاح !", True
202
 
203
 
204
  def chat(user_input):
205
+ global chathistory, vectorstore
206
 
207
 
208
  prompt = f"""
 
211
  - Your answer directly reflects the content of the document.
212
  - If the requested information is not available in the document, clearly state that in Arabic.
213
  - Keep your response concise yet comprehensive, addressing the question fully.
214
+ - Respond only in a professional and well-versed Arabic Language.
215
  Question: {user_input}.
216
  """
217
+ chain = create_chain(vectorstore)
218
  response = chain({"question": prompt})
219
  assistant_response = response["answer"]
220