Update app.py
Browse files127 unmodified lines1281291301311311321331349 unmodified lines1441451461471471481491501 unmodified line1521531541551551561571583 unmodified lines162163164165165166167168127 unmodified lines description="List of sources to cite. Should be an URL of the source." )
def get_response_from_pdf(query):def get_response_from_pdf(query, temperature=0.7, repetition_penalty=1.1): embed = get_embeddings() if os.path.exists("faiss_database"): database = FAISS.load_local("faiss_database", embed, allow_dangerous_deserialization=True)9 unmodified linesWrite a detailed and complete response that answers the following user question: '{query}'Do not include a list of sources in your response. [/INST]"""
generated_text = generate_chunked_response(prompt) generated_text = generate_chunked_response(prompt, temperature=temperature, repetition_penalty=repetition_penalty)
# Clean the response clean_text = re.sub(r'<s>\[INST\].*?\[/INST\]\s*', '', generated_text, flags=re.DOTALL)1 unmodified line
return clean_text
def get_response_with_search(query):def get_response_with_search(query, temperature=0.7, repetition_penalty=1.1): search_results = duckduckgo_search(query) context = "\n".join(f"{result['title']}\n{result['body']}\nSource: {result['href']}\n" for result in search_results if 'body' in result)3 unmodified linesWrite a detailed and complete research document that fulfills the following user request: '{query}'After writing the document, please provide a list of sources used in your response. [/INST]""" generated_text = generate_chunked_response(prompt) generated_text = generate_chunked_response(prompt, temperature=temperature, repetition_penalty=repetition_penalty) # Clean the response clean_text = re.sub(r'<s>\[INST\].*?\[/INST\]\s*', '', generated_text, flags=re.DOTALL)app.py+4-4