arif670 commited on
Commit
ef6c9f2
·
verified ·
1 Parent(s): 18781f8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -1,8 +1,11 @@
1
  import streamlit as st
2
  from docx import Document
3
- import openai
4
  import io
5
 
 
 
 
6
  # Department and Role mapping
7
  DEPARTMENT_ROLES = {
8
  "Construction": [
@@ -41,7 +44,7 @@ def generate_jd_with_openai(department, role):
41
  """
42
 
43
  try:
44
- response = openai.ChatCompletion.create(
45
  model="gpt-3.5-turbo",
46
  messages=[
47
  {"role": "system", "content": "You are a professional HR consultant specializing in construction industry job descriptions."},
@@ -50,7 +53,7 @@ def generate_jd_with_openai(department, role):
50
  temperature=0.7,
51
  max_tokens=1000
52
  )
53
- return response['choices'][0]['message']['content']
54
  except Exception as e:
55
  st.error(f"Error generating job description: {str(e)}")
56
  return None
 
1
  import streamlit as st
2
  from docx import Document
3
+ from openai import OpenAI
4
  import io
5
 
6
+ # Initialize OpenAI client
7
+ client = OpenAI(api_key="YOUR_OPENAI_API_KEY") # Replace with your OpenAI API key
8
+
9
  # Department and Role mapping
10
  DEPARTMENT_ROLES = {
11
  "Construction": [
 
44
  """
45
 
46
  try:
47
+ response = client.chat.completions.create(
48
  model="gpt-3.5-turbo",
49
  messages=[
50
  {"role": "system", "content": "You are a professional HR consultant specializing in construction industry job descriptions."},
 
53
  temperature=0.7,
54
  max_tokens=1000
55
  )
56
+ return response.choices[0].message.content
57
  except Exception as e:
58
  st.error(f"Error generating job description: {str(e)}")
59
  return None