Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,12 +10,16 @@ st.markdown("Get job interview ready by practicing questions at your pace.")
|
|
| 10 |
|
| 11 |
def generate_questions(role, topic, num_questions, difficulty):
|
| 12 |
prompt = (
|
| 13 |
-
f"Generate {num_questions} {topic.lower()} interview questions for a {role} position at difficulty level {difficulty}."
|
| 14 |
)
|
| 15 |
try:
|
| 16 |
response = llm.invoke(prompt)
|
| 17 |
questions = response.content.split('\n')
|
| 18 |
questions = [q.strip() for q in questions if q.strip()]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
return questions if questions else []
|
| 20 |
except Exception as e:
|
| 21 |
st.error(f"Error generating questions: {str(e)}")
|
|
|
|
| 10 |
|
| 11 |
def generate_questions(role, topic, num_questions, difficulty):
|
| 12 |
prompt = (
|
| 13 |
+
f"Generate exactly {num_questions} {topic.lower()} interview questions for a {role} position at difficulty level {difficulty}."
|
| 14 |
)
|
| 15 |
try:
|
| 16 |
response = llm.invoke(prompt)
|
| 17 |
questions = response.content.split('\n')
|
| 18 |
questions = [q.strip() for q in questions if q.strip()]
|
| 19 |
+
|
| 20 |
+
if len(questions) > num_questions:
|
| 21 |
+
questions = questions[:num_questions]
|
| 22 |
+
|
| 23 |
return questions if questions else []
|
| 24 |
except Exception as e:
|
| 25 |
st.error(f"Error generating questions: {str(e)}")
|