Update app.py
Browse files490 unmodified lines4914924934944954964972 unmodified lines5005015025035045055065 unmodified lines51251351451551651751816 unmodified lines5355365375385395405415421 unmodified line544545546547548549550551490 unmodified linesyield final_summaryelse:yield "Unable to generate a response. Please try a different query."else:try:embed = get_embeddings()2 unmodified linesif os.path.exists("faiss_database"):pdf_database = FAISS.load_local("faiss_database", embed, allow_dangerous_deserialization=True)if os.path.exists("office_faiss_database"):office_database = FAISS.load_local("office_faiss_database", embed, allow_dangerous_deserialization=True)5 unmodified linesif pdf_database:pdf_retriever = pdf_database.as_retriever(search_kwargs={"k": 10})all_relevant_docs.extend(pdf_retriever.get_relevant_documents(message))if office_database:office_retriever = office_database.as_retriever(search_kwargs={"k": 10})all_relevant_docs.extend(office_retriever.get_relevant_documents(message))16 unmodified lines# Process Excel documentsif excel_docs:if model == "gemini-1.5-flash":for chunk in get_response_from_gemini(message, excel_context, "excel", num_calls, temperature):yield chunkelse:for response in get_response_from_excel(message, model, excel_context, num_calls, temperature):1 unmodified line# Process other documents (PDF, Word)if other_docs:if model == "gemini-1.5-flash":for chunk in get_response_from_gemini(message, other_context, "pdf", num_calls, temperature):yield chunkelif model == "@cf/meta/llama-3.1-8b-instruct":for response in get_response_from_cloudflare(prompt="", context=other_context, query=message, num_calls=num_calls, temperature=temperature, search_type="document"):490 unmodified lines4914924934944954964972 unmodified lines5005015025035045055065 unmodified lines51251351451551651751816 unmodified lines5355365375385395405415425431 unmodified line545546547548549550551552553490 unmodified linesyield final_summaryelse:yield "Unable to generate a response. Please try a different query."else:try:embed = get_embeddings()2 unmodified linesif os.path.exists("faiss_database"):pdf_database = FAISS.load_local("faiss_database", embed, allow_dangerous_deserialization=True)if os.path.exists("office_faiss_database"):office_database = FAISS.load_local("office_faiss_database", embed, allow_dangerous_deserialization=True)5 unmodified linesif pdf_database:pdf_retriever = pdf_database.as_retriever(search_kwargs={"k": 10})all_relevant_docs.extend(pdf_retriever.get_relevant_documents(message))if office_database:office_retriever = office_database.as_retriever(search_kwargs={"k": 10})all_relevant_docs.extend(office_retriever.get_relevant_documents(message))16 unmodified lines# Process Excel documentsif excel_docs:file_type = "excel"if model == "gemini-1.5-flash":for chunk in get_response_from_gemini(message, model, selected_docs, file_type, num_calls, temperature):yield chunkelse:for response in get_response_from_excel(message, model, excel_context, num_calls, temperature):1 unmodified line# Process other documents (PDF, Word)if other_docs:file_type = "pdf"if model == "gemini-1.5-flash":for chunk in get_response_from_gemini(message, model, selected_docs, file_type, num_calls, temperature):yield chunkelif model == "@cf/meta/llama-3.1-8b-instruct":for response in get_response_from_cloudflare(prompt="", context=other_context, query=message, num_calls=num_calls, temperature=temperature, search_type="document"):
app.py+7-5