Update app.py
Browse files352 unmodified lines35335435535635735835936036136225 unmodified lines388389390391392393394395396397398399400401402403352 unmodified linesexcept Exception as e:return f"An error occurred during summarization: {str(e)}"import osimport google.generativeai as genaidef get_response_from_gemini(query, context, file_type, num_calls=1, temperature=0.2):# Configure the Gemini APIgenai.configure(api_key=os.environ["GEMINI_API_KEY"])25 unmodified linesfull_prompt = f"{system_instruction}\n\nContext:\n{context}\n\nUser query: {query}"for _ in range(num_calls):try:# Generate content with streaming enabledresponse = model.generate_content(full_prompt, stream=True)for chunk in response:if chunk.text:yield chunk.textexcept Exception as e:yield f"An error occurred with the Gemini model: {str(e)}. Please try again."def get_response_from_excel(query, model, context, num_calls=3, temperature=0.2):logging.info(f"Getting response from Excel using model: {model}")352 unmodified lines35335435535635735825 unmodified lines384385386387388389390391392393394395396397398399400401402403404352 unmodified linesexcept Exception as e:return f"An error occurred during summarization: {str(e)}"def get_response_from_gemini(query, context, file_type, num_calls=1, temperature=0.2):# Configure the Gemini APIgenai.configure(api_key=os.environ["GEMINI_API_KEY"])25 unmodified linesfull_prompt = f"{system_instruction}\n\nContext:\n{context}\n\nUser query: {query}"full_response = ""for _ in range(num_calls):try:# Generate content with streaming enabledresponse = model.generate_content(full_prompt, stream=True)for chunk in response:if chunk.text:full_response += chunk.textyield full_response # Yield the accumulated response so farexcept Exception as e:yield f"An error occurred with the Gemini model: {str(e)}. Please try again."if not full_response:yield "No response generated from the Gemini model."def get_response_from_excel(query, model, context, num_calls=3, temperature=0.2):logging.info(f"Getting response from Excel using model: {model}")
app.py+6-5