Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
-
import
|
4 |
|
5 |
# Set your OpenAI API key
|
6 |
-
|
7 |
|
8 |
jd_summary_global = "" # Global variable to store the job description summary
|
9 |
|
@@ -18,8 +18,8 @@ def process_jd(text):
|
|
18 |
prompt = f"Summarize the following job description into its job nature, responsibilities, and requirements:\n\n{text}"
|
19 |
|
20 |
# Uploading text to OpenAI
|
21 |
-
response =
|
22 |
-
jd_summary = response
|
23 |
jd_summary_global = jd_summary # Update the global variable
|
24 |
return jd_summary
|
25 |
except Exception as e:
|
@@ -42,8 +42,8 @@ def cv_rating(cv_data):
|
|
42 |
Rate the compatibility of the CV with the job description and provide strengths, weaknesses, and recommendations to strengthen the CV.
|
43 |
"""
|
44 |
# Uploading text to OpenAI
|
45 |
-
response =
|
46 |
-
cv_rating_global= response
|
47 |
return cv_rating_global
|
48 |
except Exception as e:
|
49 |
return str(e)
|
@@ -65,8 +65,8 @@ def create_cover_letter(additional_info):
|
|
65 |
Create a tailored cover letter based on the job description and CV data provided:
|
66 |
"""
|
67 |
# Uploading text to OpenAI
|
68 |
-
response =
|
69 |
-
return response
|
70 |
except Exception as e:
|
71 |
return str(e)
|
72 |
|
@@ -83,8 +83,8 @@ def interview_qa(additional_info):
|
|
83 |
Generate at least 10 interview questions and provide potential answers based on the CV data and additional information provided:
|
84 |
"""
|
85 |
# Uploading text to OpenAI
|
86 |
-
response =
|
87 |
-
return response
|
88 |
except Exception as e:
|
89 |
return str(e)
|
90 |
|
@@ -107,11 +107,10 @@ def suggest_cv_content(additional_info):
|
|
107 |
Additional Information: {additional_info}
|
108 |
"""
|
109 |
# Uploading text to OpenAI
|
110 |
-
response =
|
111 |
-
model="gpt-3.5-turbo",
|
112 |
messages=[{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": prompt}]
|
113 |
)
|
114 |
-
return response
|
115 |
except Exception as e:
|
116 |
return str(e)
|
117 |
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
+
from openai import OpenAI
|
4 |
|
5 |
# Set your OpenAI API key
|
6 |
+
client = OpenAI(api_key=os.environ['OPENAI_API_KEY'])
|
7 |
|
8 |
jd_summary_global = "" # Global variable to store the job description summary
|
9 |
|
|
|
18 |
prompt = f"Summarize the following job description into its job nature, responsibilities, and requirements:\n\n{text}"
|
19 |
|
20 |
# Uploading text to OpenAI
|
21 |
+
response = client.chat.completions.create(model="gpt-3.5-turbo", messages=[{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": prompt}])
|
22 |
+
jd_summary = response.choices[0].message.content.strip()
|
23 |
jd_summary_global = jd_summary # Update the global variable
|
24 |
return jd_summary
|
25 |
except Exception as e:
|
|
|
42 |
Rate the compatibility of the CV with the job description and provide strengths, weaknesses, and recommendations to strengthen the CV.
|
43 |
"""
|
44 |
# Uploading text to OpenAI
|
45 |
+
response = client.chat.completions.create(model="gpt-3.5-turbo", messages=[{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": prompt}])
|
46 |
+
cv_rating_global= response.choices[0].message.content.strip()
|
47 |
return cv_rating_global
|
48 |
except Exception as e:
|
49 |
return str(e)
|
|
|
65 |
Create a tailored cover letter based on the job description and CV data provided:
|
66 |
"""
|
67 |
# Uploading text to OpenAI
|
68 |
+
response = client.chat.completions.create(model="gpt-3.5-turbo", messages=[{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": prompt}])
|
69 |
+
return response.choices[0].message.content.strip()
|
70 |
except Exception as e:
|
71 |
return str(e)
|
72 |
|
|
|
83 |
Generate at least 10 interview questions and provide potential answers based on the CV data and additional information provided:
|
84 |
"""
|
85 |
# Uploading text to OpenAI
|
86 |
+
response = client.chat.completions.create(model="gpt-3.5-turbo", messages=[{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": prompt}])
|
87 |
+
return response.choices[0].message.content.strip()
|
88 |
except Exception as e:
|
89 |
return str(e)
|
90 |
|
|
|
107 |
Additional Information: {additional_info}
|
108 |
"""
|
109 |
# Uploading text to OpenAI
|
110 |
+
response = client.chat.completions.create(model="gpt-3.5-turbo",
|
|
|
111 |
messages=[{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": prompt}]
|
112 |
)
|
113 |
+
return response.choices[0].message.content.strip()
|
114 |
except Exception as e:
|
115 |
return str(e)
|
116 |
|