Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -193,16 +193,16 @@ def validate_pdf(pdf):
|
|
| 193 |
return "الملف صالح للدردشة", True
|
| 194 |
|
| 195 |
def upload_pdf(pdf_file):
|
| 196 |
-
global vectorstore,
|
| 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
|
| 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 |
-
-
|
| 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 |
|