Spaces:
Sleeping
Sleeping
formatted the response and added readme.md steps
Browse files- README.md +36 -0
- src/get_response.py +25 -6
- src/main.py +12 -9
README.md
CHANGED
@@ -1 +1,37 @@
|
|
1 |
# genai-interview-assistant
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# genai-interview-assistant
|
2 |
+
# Interview Assistant
|
3 |
+
|
4 |
+
This application uses Cohere's NLP capabilities to simulate an interviewee responding to interview questions. Users can input their resume and a job description, and then ask questions to get detailed and structured answers based on the provided context.
|
5 |
+
|
6 |
+
## Features
|
7 |
+
|
8 |
+
- Input resume and job description
|
9 |
+
- Ask questions based on the provided context
|
10 |
+
- Get detailed and structured answers generated by Cohere
|
11 |
+
- View all questions and answers in a scrollable format
|
12 |
+
- Clear context and Q&A to start a new session
|
13 |
+
- Follow the me on GitHub and LinkedIn
|
14 |
+
|
15 |
+
## Setup
|
16 |
+
|
17 |
+
1. Clone the repository:
|
18 |
+
```bash
|
19 |
+
git clone https://github.com/rrrreddy/interview-assistant.git
|
20 |
+
cd interview-assistant
|
21 |
+
```
|
22 |
+
2. Install the required packages:
|
23 |
+
```bash
|
24 |
+
pip install -r requirements.txt
|
25 |
+
```
|
26 |
+
3. Create a .env file in the root directory with your Cohere API key:
|
27 |
+
```
|
28 |
+
COHERE_API_KEY=your-cohere-api-key
|
29 |
+
```
|
30 |
+
4. Run the application:
|
31 |
+
|
32 |
+
```
|
33 |
+
streamlit run app.py
|
34 |
+
```
|
35 |
+
|
36 |
+
|
37 |
+
|
src/get_response.py
CHANGED
@@ -11,21 +11,40 @@ cohere_client = cohere.Client(cohere_api_key)
|
|
11 |
|
12 |
# Function to store the initial context (resume and job description)
|
13 |
def store_context(resume_text, job_description):
|
14 |
-
|
15 |
-
return context
|
16 |
|
17 |
-
|
18 |
-
# Function to answer questions based on the stored context and a new question
|
19 |
def answer_questions(context, question):
|
20 |
prompt = (
|
|
|
|
|
21 |
f"{context}"
|
22 |
f"Question:\n"
|
23 |
f"{question}\n\n"
|
24 |
-
"Answer:"
|
25 |
)
|
26 |
response = cohere_client.generate(
|
27 |
model='command-xlarge-nightly',
|
28 |
prompt=prompt,
|
29 |
max_tokens=500 # Adjust max_tokens to a higher value as needed
|
30 |
)
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
# Function to store the initial context (resume and job description)
|
13 |
def store_context(resume_text, job_description):
|
14 |
+
return f"Resume:\n{resume_text}\n\nJob Description:\n{job_description}\n\n"
|
|
|
15 |
|
16 |
+
# Enhanced function to answer questions based on the stored context and a new question
|
|
|
17 |
def answer_questions(context, question):
|
18 |
prompt = (
|
19 |
+
f"You are an interviewee being asked questions based on your resume and a job description. "
|
20 |
+
f"Provide a detailed and structured response to the following question.\n\n"
|
21 |
f"{context}"
|
22 |
f"Question:\n"
|
23 |
f"{question}\n\n"
|
24 |
+
"Answer as if you are the interviewee:"
|
25 |
)
|
26 |
response = cohere_client.generate(
|
27 |
model='command-xlarge-nightly',
|
28 |
prompt=prompt,
|
29 |
max_tokens=500 # Adjust max_tokens to a higher value as needed
|
30 |
)
|
31 |
+
|
32 |
+
# Format the response in a structured way
|
33 |
+
detailed_response = response.generations[0].text.strip()
|
34 |
+
formatted_response = format_response(detailed_response)
|
35 |
+
return formatted_response
|
36 |
+
|
37 |
+
def format_response(detailed_response):
|
38 |
+
# Here we add basic formatting, such as headings and bold points
|
39 |
+
formatted_response = ""
|
40 |
+
lines = detailed_response.split('\n')
|
41 |
+
|
42 |
+
for line in lines:
|
43 |
+
if line.strip().endswith(':'):
|
44 |
+
# Heading
|
45 |
+
formatted_response += f"### {line.strip()}\n"
|
46 |
+
elif line.strip():
|
47 |
+
# Regular bullet points
|
48 |
+
formatted_response += f"- **{line.strip()}**\n"
|
49 |
+
|
50 |
+
return formatted_response
|
src/main.py
CHANGED
@@ -1,10 +1,6 @@
|
|
1 |
import streamlit as st
|
2 |
from src.get_response import store_context, answer_questions
|
3 |
|
4 |
-
@st.cache_data
|
5 |
-
def get_context(resume_text, job_description):
|
6 |
-
return store_context(resume_text, job_description)
|
7 |
-
|
8 |
def initialize_session_state():
|
9 |
if "context" not in st.session_state:
|
10 |
st.session_state.context = None
|
@@ -18,7 +14,7 @@ def input_resume_and_job_description():
|
|
18 |
|
19 |
if st.button("Submit Resume and Job Description"):
|
20 |
if resume_input.strip() and job_description_input.strip():
|
21 |
-
st.session_state.context =
|
22 |
st.session_state.qa_pairs = [] # Clear previous Q&A pairs when new context is submitted
|
23 |
st.success("Context stored successfully. You can now ask questions.")
|
24 |
st.rerun()
|
@@ -42,7 +38,7 @@ def display_qa_pairs():
|
|
42 |
st.subheader("Questions and Answers:")
|
43 |
for i, (question, answer) in enumerate(st.session_state.qa_pairs):
|
44 |
st.write(f"**Q{i+1}:** {question}")
|
45 |
-
st.
|
46 |
|
47 |
def clear_context_and_qa():
|
48 |
if st.button("Clear Context and Q&A"):
|
@@ -51,9 +47,16 @@ def clear_context_and_qa():
|
|
51 |
st.success("Context and Q&A cleared. Please enter new resume and job description.")
|
52 |
st.rerun()
|
53 |
|
|
|
|
|
|
|
|
|
|
|
54 |
def run_app():
|
55 |
-
st.title("
|
56 |
-
st.write("This app uses Cohere's NLP capabilities to answer questions based on your resume and job description.")
|
|
|
|
|
57 |
|
58 |
initialize_session_state()
|
59 |
|
@@ -65,4 +68,4 @@ def run_app():
|
|
65 |
display_qa_pairs()
|
66 |
clear_context_and_qa()
|
67 |
|
68 |
-
st.write("Designed by Raghu")
|
|
|
1 |
import streamlit as st
|
2 |
from src.get_response import store_context, answer_questions
|
3 |
|
|
|
|
|
|
|
|
|
4 |
def initialize_session_state():
|
5 |
if "context" not in st.session_state:
|
6 |
st.session_state.context = None
|
|
|
14 |
|
15 |
if st.button("Submit Resume and Job Description"):
|
16 |
if resume_input.strip() and job_description_input.strip():
|
17 |
+
st.session_state.context = store_context(resume_input, job_description_input)
|
18 |
st.session_state.qa_pairs = [] # Clear previous Q&A pairs when new context is submitted
|
19 |
st.success("Context stored successfully. You can now ask questions.")
|
20 |
st.rerun()
|
|
|
38 |
st.subheader("Questions and Answers:")
|
39 |
for i, (question, answer) in enumerate(st.session_state.qa_pairs):
|
40 |
st.write(f"**Q{i+1}:** {question}")
|
41 |
+
st.markdown(answer, unsafe_allow_html=True)
|
42 |
|
43 |
def clear_context_and_qa():
|
44 |
if st.button("Clear Context and Q&A"):
|
|
|
47 |
st.success("Context and Q&A cleared. Please enter new resume and job description.")
|
48 |
st.rerun()
|
49 |
|
50 |
+
def add_social_links():
|
51 |
+
st.sidebar.title("Follow Me")
|
52 |
+
st.sidebar.write("[GitHub](https://github.com/rrrreddy)")
|
53 |
+
st.sidebar.write("[LinkedIn](https://www.linkedin.com/in/raghu-konda/)")
|
54 |
+
|
55 |
def run_app():
|
56 |
+
st.title("Interview Assistant")
|
57 |
+
st.write("This app uses Cohere's NLP capabilities to simulate an interviewee and answer questions based on your resume and job description.")
|
58 |
+
|
59 |
+
add_social_links()
|
60 |
|
61 |
initialize_session_state()
|
62 |
|
|
|
68 |
display_qa_pairs()
|
69 |
clear_context_and_qa()
|
70 |
|
71 |
+
st.write("Designed by Raghu!")
|