rajeshthangaraj1 commited on
Commit
bfd4ce4
·
verified ·
1 Parent(s): 2949f22

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -3,6 +3,7 @@ import google.generativeai as genai
3
  import os
4
  import PyPDF2 as pdf
5
  from dotenv import load_dotenv
 
6
 
7
  load_dotenv()
8
  genai.configure(api_key=os.getenv('GOOGLE_API_KEY'))
@@ -49,8 +50,8 @@ if submit:
49
  response = get_gemeni_response(input_prompt.format(text=text, jd=jd))
50
 
51
  try:
52
- # Parse the response into a dictionary
53
- response_dict = eval(response) # Be cautious with eval; use safer alternatives if possible
54
 
55
  # Display structured output
56
  st.subheader("Job Description Match")
@@ -62,7 +63,7 @@ if submit:
62
  st.subheader("Profile Summary")
63
  st.text(response_dict["Profile Summary"])
64
 
65
- except Exception as e:
66
  st.error("Error parsing response. Check the response format.")
67
  st.write(response) # Display raw response for debugging
68
  else:
 
3
  import os
4
  import PyPDF2 as pdf
5
  from dotenv import load_dotenv
6
+ import json # Import json module for safe parsing
7
 
8
  load_dotenv()
9
  genai.configure(api_key=os.getenv('GOOGLE_API_KEY'))
 
50
  response = get_gemeni_response(input_prompt.format(text=text, jd=jd))
51
 
52
  try:
53
+ # Parse the response using json.loads
54
+ response_dict = json.loads(response) # Use json.loads instead of eval
55
 
56
  # Display structured output
57
  st.subheader("Job Description Match")
 
63
  st.subheader("Profile Summary")
64
  st.text(response_dict["Profile Summary"])
65
 
66
+ except json.JSONDecodeError:
67
  st.error("Error parsing response. Check the response format.")
68
  st.write(response) # Display raw response for debugging
69
  else: