Spaces:
Build error
Build error
Update app.py
Browse files127 unmodified lines1281291301311321331349 unmodified lines1441451461471481491501 unmodified line1521531541551561571583 unmodified lines162163164165166167168127 unmodified linesdescription="List of sources to cite. Should be an URL of the source.")def get_response_from_pdf(query):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)# Clean the responseclean_text = re.sub(r'<s>\[INST\].*?\[/INST\]\s*', '', generated_text, flags=re.DOTALL)1 unmodified linereturn clean_textdef get_response_with_search(query):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)# Clean the responseclean_text = re.sub(r'<s>\[INST\].*?\[/INST\]\s*', '', generated_text, flags=re.DOTALL)127 unmodified lines1281291301311321331349 unmodified lines1441451461471481491501 unmodified line1521531541551561571583 unmodified lines162163164165166167168127 unmodified linesdescription="List of sources to cite. Should be an URL of the source.")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, temperature=temperature, repetition_penalty=repetition_penalty)# Clean the responseclean_text = re.sub(r'<s>\[INST\].*?\[/INST\]\s*', '', generated_text, flags=re.DOTALL)1 unmodified linereturn clean_textdef 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, temperature=temperature, repetition_penalty=repetition_penalty)# Clean the responseclean_text = re.sub(r'<s>\[INST\].*?\[/INST\]\s*', '', generated_text, flags=re.DOTALL)
app.py+4-4