streamsgemini / analyze.py
ombhojane's picture
Upload 4 files
fc364c3 verified
import streamlit as st
import json
import google.generativeai as genai
def app():
# Configure Google Generative AI
genai.configure(api_key="AIzaSyD-61G3GhSY97O-X2AlpXGv1MYBBMRFmwg")
# Streamlit UI
st.title("Analysis of Responses")
uploaded_file = st.file_uploader("Choose a JSON file", type="json")
if uploaded_file is not None:
# Load the JSON file
data = json.load(uploaded_file)
# Set up the model configuration
generation_config = {
"temperature": 0.9,
"top_p": 1,
"top_k": 1,
"max_output_tokens": 2048,
}
safety_settings = [
{
"category": "HARM_CATEGORY_HARASSMENT",
"threshold": "BLOCK_MEDIUM_AND_ABOVE"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"threshold": "BLOCK_MEDIUM_AND_ABOVE"
},
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"threshold": "BLOCK_MEDIUM_AND_ABOVE"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"threshold": "BLOCK_MEDIUM_AND_ABOVE"
},
]
model = genai.GenerativeModel(model_name="gemini-1.0-pro",
generation_config=generation_config,
safety_settings=safety_settings)
# UI to trigger processing
if st.button("Generate Content"):
# Adjust the following line to match how you extract prompts from your JSON data
prompt_parts = f"Given an individual's career aspirations, core values, strengths, preferences, and skills, provide a comprehensive analysis that identifies key strengths, aligns these with career values, and suggests career paths. Then, recommend the top 5 job descriptions that would be a perfect fit based on the analysis. Here are the details: {data}"
response = model.generate_content(prompt_parts)
# Display the response
st.write("Generated Content:")
st.write(response.text)