Spaces:
Sleeping
Sleeping
File size: 725 Bytes
b609913 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
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)}"
|