arif670 commited on
Commit
7ebdf88
·
verified ·
1 Parent(s): ef6c9f2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -2,9 +2,15 @@ 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 = {
 
2
  from docx import Document
3
  from openai import OpenAI
4
  import io
5
+ import os
6
 
7
  # Initialize OpenAI client
8
+ api_key = os.getenv("OPENAI_API_KEY") # Read API key from environment variable
9
+ if not api_key:
10
+ st.error("OpenAI API key not found. Please set the OPENAI_API_KEY environment variable.")
11
+ st.stop()
12
+
13
+ client = OpenAI(api_key=api_key)
14
 
15
  # Department and Role mapping
16
  DEPARTMENT_ROLES = {