Create app4.py
Browse files
app4.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from langchain_community.llms import OpenAI
|
| 3 |
+
from langchain_google_genai import ChatGoogleGenerativeAI
|
| 4 |
+
st.set_page_config(layout="wide")
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
# Function to handle AI invocation and response
|
| 8 |
+
def analyze_job_description(topic, model ):
|
| 9 |
+
prompt = (
|
| 10 |
+
f"As an HR Manager, I need you to analyze the following job description and identify the key technical skills, nice-to-have skills, must-have skills, and soft skills required for the role: {topic}. "
|
| 11 |
+
"The post should be concise, informative, and suitable for a professional audience. "
|
| 12 |
+
"List top 5 points for technical skills, nice-to-have skills, must-have skills, and soft skills required for the role."
|
| 13 |
+
)
|
| 14 |
+
if model == "Open AI":
|
| 15 |
+
llm = OpenAI(openai_api_key=st.secrets["OPENAI_API_KEY"])
|
| 16 |
+
response = llm(prompt)
|
| 17 |
+
return response
|
| 18 |
+
elif model == "Gemini":
|
| 19 |
+
llm = ChatGoogleGenerativeAI(model="gemini-pro", google_api_key=st.secrets["YOUR_GEMINI_API_KEY"])
|
| 20 |
+
result = llm.invoke(prompt)
|
| 21 |
+
return result.content
|
| 22 |
+
|
| 23 |
+
def main():
|
| 24 |
+
st.title("JD Analysis")
|
| 25 |
+
# Radio selection for AI model
|
| 26 |
+
st.header("Select AI:")
|
| 27 |
+
model = st.radio("Model", ["Open AI", "Gemini"])
|
| 28 |
+
st.write("Selected option:", model)
|
| 29 |
+
|
| 30 |
+
# Text area for job description input
|
| 31 |
+
with st.form("my_form"):
|
| 32 |
+
topic = st.text_area("Copy Paste the JD here:")
|
| 33 |
+
submitted = st.form_submit_button("Analyze Now")
|
| 34 |
+
if submitted and topic:
|
| 35 |
+
result = analyze_job_description(topic, model )
|
| 36 |
+
st.info(result)
|
| 37 |
+
elif submitted and not topic:
|
| 38 |
+
st.error("Please enter a JD details to analyze.")
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
if __name__ == "__main__":
|
| 42 |
+
main()
|