Update app.py
Browse files276 unmodified lines277278279280281282283284285286287288289290276 unmodified linesfull_response = generate_chunked_response(model, formatted_prompt)# Extract only the part after the specific sentenceanswer_pattern = r"Provide a concise and direct answer to the question without mentioning the web search or these instructions:([\s\S]*)"match = re.search(answer_pattern, full_response, re.IGNORECASE)if match:answer = match.group(1).strip()else:# If the specific sentence is not found, return the full responseanswer = full_response.strip()if not web_search:276 unmodified lines277278279280281282283284285286287288289290291292293294295296276 unmodified linesfull_response = generate_chunked_response(model, formatted_prompt)# Extract only the part after the last occurrence of a prompt-like sentenceanswer_patterns = [r"Provide a concise and direct answer to the question without mentioning the web search or these instructions:",r"Provide a concise and direct answer to the question:",r"Answer:"]for pattern in answer_patterns:match = re.split(pattern, full_response, flags=re.IGNORECASE)if len(match) > 1:answer = match[-1].strip()breakelse:# If no pattern is found, return the full responseanswer = full_response.strip()if not web_search:
app.py+12-6