Spaces:
Sleeping
Sleeping
import google.generativeai as genai | |
import streamlit as st | |
# Function to authenticate with Gemini API | |
def authenticate_gemini(api_key): | |
try: | |
genai.configure(api_key=api_key) | |
model = genai.GenerativeModel(model_name="gemini-1.5-flash-latest") | |
return model | |
except Exception as e: | |
st.error(f"Error configuring Gemini API: {e}") | |
return None | |
# Function to generate a summary using the Gemini API | |
def generate_summary(text, model): | |
prompt = f"Can you summarize the following document in 100 words?\n\n{text}" | |
try: | |
response = model.generate_content(prompt) | |
return response.text | |
except Exception as e: | |
return f"Error generating summary: {str(e)}" | |