Spaces:
Runtime error
Runtime error
Commit
•
348e071
1
Parent(s):
f5689ce
prompt update
Browse files- qa_engine/qa_engine.py +6 -9
qa_engine/qa_engine.py
CHANGED
@@ -304,23 +304,20 @@ class QAEngine():
|
|
304 |
|
305 |
logger.info('Running LLM chain')
|
306 |
question_processed = QAEngine._preprocess_question(question)
|
307 |
-
|
308 |
-
answer = self.llm_chain.run(question=question_processed, context=context)
|
309 |
-
|
310 |
-
answer_step_2 = self.llm_model(
|
311 |
f"""
|
312 |
<|im_start|>system
|
313 |
-
Given
|
314 |
<|im_end|>
|
315 |
<|im_start|>user
|
316 |
<question>{question_processed}</question>
|
317 |
-
<answer>{answer}</answer>
|
318 |
<|im_end|>
|
319 |
<|im_start|>assistant
|
320 |
"""
|
321 |
)
|
322 |
-
|
323 |
-
|
|
|
324 |
response.set_answer(answer_postprocessed)
|
325 |
logger.info('Received answer')
|
326 |
|
@@ -329,9 +326,9 @@ Given the question provided below, review the answer, and update it based on com
|
|
329 |
sep = '\n' + '-' * 100
|
330 |
logger.info(f'question len: {len(question)} {sep}')
|
331 |
logger.info(f'question: {question} {sep}')
|
|
|
332 |
logger.info(f'answer len: {len(response.get_answer())} {sep}')
|
333 |
logger.info(f'answer original: {answer} {sep}')
|
334 |
-
logger.info(f'answer step 2: {answer_step_2} {sep}')
|
335 |
logger.info(f'answer postprocessed: {response.get_answer()} {sep}')
|
336 |
logger.info(f'{response.get_sources_as_text()} {sep}')
|
337 |
logger.info(f'messages_contex: {messages_context} {sep}')
|
|
|
304 |
|
305 |
logger.info('Running LLM chain')
|
306 |
question_processed = QAEngine._preprocess_question(question)
|
307 |
+
question_processed = self.llm_model(
|
|
|
|
|
|
|
308 |
f"""
|
309 |
<|im_start|>system
|
310 |
+
Given a user's query that is vague or broad, your task is to refine and rephrase the query to make it more specific and targeted, ultimately returning only the refined question. <|im_end|>
|
311 |
<|im_end|>
|
312 |
<|im_start|>user
|
313 |
<question>{question_processed}</question>
|
|
|
314 |
<|im_end|>
|
315 |
<|im_start|>assistant
|
316 |
"""
|
317 |
)
|
318 |
+
|
319 |
+
answer = self.llm_chain.run(question=question_processed, context=context)
|
320 |
+
answer_postprocessed = QAEngine._postprocess_answer(answer)
|
321 |
response.set_answer(answer_postprocessed)
|
322 |
logger.info('Received answer')
|
323 |
|
|
|
326 |
sep = '\n' + '-' * 100
|
327 |
logger.info(f'question len: {len(question)} {sep}')
|
328 |
logger.info(f'question: {question} {sep}')
|
329 |
+
logger.info(f'question processed: {question} {sep}')
|
330 |
logger.info(f'answer len: {len(response.get_answer())} {sep}')
|
331 |
logger.info(f'answer original: {answer} {sep}')
|
|
|
332 |
logger.info(f'answer postprocessed: {response.get_answer()} {sep}')
|
333 |
logger.info(f'{response.get_sources_as_text()} {sep}')
|
334 |
logger.info(f'messages_contex: {messages_context} {sep}')
|