Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -154,13 +154,13 @@ def answer_question(context, question):
|
|
| 154 |
return "Please enter your Question"
|
| 155 |
|
| 156 |
messages = [
|
| 157 |
-
{"role": "system", "content": "You are a helpful assistant who can answer questions based on the given context."},
|
| 158 |
-
|
| 159 |
{"role": "user", "content": f"Context: {context}\n Question: {question}"}
|
| 160 |
]
|
| 161 |
|
| 162 |
response = qa_pipeline(messages, max_new_tokens=256)[0]['generated_text']
|
| 163 |
-
return response
|
| 164 |
except Exception as e:
|
| 165 |
logger.error(f"Q&A failed: {str(e)}")
|
| 166 |
return f"Error occurred during Q&A process: {str(e)}"
|
|
|
|
| 154 |
return "Please enter your Question"
|
| 155 |
|
| 156 |
messages = [
|
| 157 |
+
# {"role": "system", "content": "You are a helpful assistant who can answer questions based on the given context."},
|
| 158 |
+
{"role":"system", "content": SYSTEM_MESSAGE},
|
| 159 |
{"role": "user", "content": f"Context: {context}\n Question: {question}"}
|
| 160 |
]
|
| 161 |
|
| 162 |
response = qa_pipeline(messages, max_new_tokens=256)[0]['generated_text']
|
| 163 |
+
return response[1]['content']
|
| 164 |
except Exception as e:
|
| 165 |
logger.error(f"Q&A failed: {str(e)}")
|
| 166 |
return f"Error occurred during Q&A process: {str(e)}"
|