Spaces:
Sleeping
Sleeping
import streamlit as st | |
import os | |
from dotenv import load_dotenv | |
from langchain_community.llms import OpenAI | |
from langchain_google_genai import ChatGoogleGenerativeAI | |
# Load environment variables | |
load_dotenv() | |
def suggest_projects(skills, roles, topics, level, difficulty,model, domain, industry): | |
prompt = f""" | |
Based on the following information, suggest relevant projects: | |
- Skills: {skills} | |
- Roles: {roles} | |
- Topics: {topics} | |
- Level of Understanding: {level} | |
- Difficulty: {difficulty} | |
""" | |
if domain: | |
prompt += f"\n- Domain: {domain}" | |
if industry: | |
prompt += f"\n- Industry: {industry}" | |
prompt += "\n\nSuggested Projects:" | |
if model == "Open AI": | |
llm = OpenAI(temperature=0.7, openai_api_key=st.secrets["OPENAI_API_KEY"]) | |
projects = llm(prompt) | |
elif model == "Gemini": | |
llm = ChatGoogleGenerativeAI(model="gemini-pro", google_api_key=st.secrets["GOOGLE_API_KEY"]) | |
projects = llm.invoke(prompt) | |
projects = projects.content | |
return projects | |
def app(): | |
st.title("Project Suggestions") | |
if 'analysis' in st.session_state: | |
analysis = st.session_state['analysis'] | |
st.header("Select AI:") | |
model = st.radio("Model", [ "Gemini","Open AI",]) | |
st.write("Selected option:", model) | |
st.write("Job Description Analysis:") | |
st.text(analysis) | |
# Parse the analysis (assuming it returns JSON-like structure) | |
analysis_data = eval(analysis) # Convert string to dictionary | |
# Extract the details from analysis | |
skills = analysis_data.get("Skills", "") | |
roles = analysis_data.get("Roles", "") | |
topics = analysis_data.get("Topics", "") | |
level = analysis_data.get("Level of Understanding", "") | |
difficulty = analysis_data.get("Difficulty", "") | |
domain = analysis_data.get("domain", "") | |
industry = analysis_data.get("industry", "") | |
# Optional fields for domain and industry | |
# domain = st.text_input("Optional: Domain") | |
# industry = st.text_input("Optional: Industry") | |
# Suggest projects based on analysis | |
if st.button("Suggest Projects"): | |
projects = suggest_projects(skills, roles, topics, level, difficulty,model, domain, industry) | |
st.write("Suggested Projects:") | |
st.text(projects) | |
st.session_state['projects'] = projects.split('\n') | |
else: | |
st.error("Please go to the Job Description Analysis page first to analyze a job description.") | |