Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -411,7 +411,10 @@ def clean_response(response_text):
|
|
411 |
cleaned_response = re.sub(r'page_content=".*?"\),?', '', cleaned_response, flags=re.DOTALL)
|
412 |
cleaned_response = re.sub(r'\[.*?\]', '', cleaned_response, flags=re.DOTALL) # Remove content in brackets
|
413 |
cleaned_response = re.sub(r'\s+', ' ', cleaned_response).strip()
|
|
|
|
|
414 |
return cleaned_response
|
|
|
415 |
|
416 |
def generate_answer(message, choice, retrieval_mode, selected_model):
|
417 |
logging.debug(f"generate_answer called with choice: {choice} and retrieval_mode: {retrieval_mode}")
|
@@ -453,7 +456,7 @@ def generate_answer(message, choice, retrieval_mode, selected_model):
|
|
453 |
logging.debug(f"Phi-3.5 Prompt: {prompt}")
|
454 |
|
455 |
response = selected_model(prompt, **{
|
456 |
-
"max_new_tokens":
|
457 |
"return_full_text": False,
|
458 |
"temperature": 0.7, # Adjusted to avoid cutting off
|
459 |
"do_sample": True, # Allow sampling to increase response diversity
|
|
|
411 |
cleaned_response = re.sub(r'page_content=".*?"\),?', '', cleaned_response, flags=re.DOTALL)
|
412 |
cleaned_response = re.sub(r'\[.*?\]', '', cleaned_response, flags=re.DOTALL) # Remove content in brackets
|
413 |
cleaned_response = re.sub(r'\s+', ' ', cleaned_response).strip()
|
414 |
+
#Remove any unwanted follow-up questions or unnecessary text
|
415 |
+
cleaned_response = re.sub(r'Question:.*\nAnswer:', '', response_text, flags=re.DOTALL).strip()
|
416 |
return cleaned_response
|
417 |
+
|
418 |
|
419 |
def generate_answer(message, choice, retrieval_mode, selected_model):
|
420 |
logging.debug(f"generate_answer called with choice: {choice} and retrieval_mode: {retrieval_mode}")
|
|
|
456 |
logging.debug(f"Phi-3.5 Prompt: {prompt}")
|
457 |
|
458 |
response = selected_model(prompt, **{
|
459 |
+
"max_new_tokens": 128, # Increased to handle longer responses
|
460 |
"return_full_text": False,
|
461 |
"temperature": 0.7, # Adjusted to avoid cutting off
|
462 |
"do_sample": True, # Allow sampling to increase response diversity
|