Update app.py
Browse files226 unmodified lines22722822923023123223323423523623723823924024124224323 unmodified lines267268269270271272273274275226 unmodified lineslogging.info(f"Generated Response (first line): {first_line}")yield responseelse:if model == "@cf/meta/llama-3.1-8b-instruct":# Use Cloudflare APIembed = get_embeddings()if os.path.exists("faiss_database"):database = FAISS.load_local("faiss_database", embed, allow_dangerous_deserialization=True)retriever = database.as_retriever()relevant_docs = retriever.get_relevant_documents(message)context_str = "\n".join([doc.page_content for doc in relevant_docs])else:context_str = "No documents available."for partial_response in get_response_from_cloudflare(prompt="", context=context_str, query=message, num_calls=num_calls, temperature=temperature, search_type="pdf"):first_line = partial_response.split('\n')[0] if partial_response else ''logging.info(f"Generated Response (first line): {first_line}")23 unmodified linesmodel = "@cf/meta/llama-3.1-8b-instruct"if search_type == "pdf":instruction = f"""Using the following context:{context}Write a detailed and complete research document that fulfills the following user request: '{query}'"""else: # web searchinstruction = f"""Using the following context:{context}226 unmodified lines22722822923023123223323423523623723823924024124224323 unmodified lines267268269270271272273274275226 unmodified lineslogging.info(f"Generated Response (first line): {first_line}")yield responseelse:embed = get_embeddings()if os.path.exists("faiss_database"):database = FAISS.load_local("faiss_database", embed, allow_dangerous_deserialization=True)retriever = database.as_retriever()relevant_docs = retriever.get_relevant_documents(message)context_str = "\n".join([doc.page_content for doc in relevant_docs])else:context_str = "No documents available."if model == "@cf/meta/llama-3.1-8b-instruct":# Use Cloudflare APIfor partial_response in get_response_from_cloudflare(prompt="", context=context_str, query=message, num_calls=num_calls, temperature=temperature, search_type="pdf"):first_line = partial_response.split('\n')[0] if partial_response else ''logging.info(f"Generated Response (first line): {first_line}")23 unmodified linesmodel = "@cf/meta/llama-3.1-8b-instruct"if search_type == "pdf":instruction = f"""Using the following context from the PDF documents:{context}Write a detailed and complete response that answers the following user question: '{query}'"""else: # web searchinstruction = f"""Using the following context:{context}
app.py+11-11