Shrees0507 commited on
Commit
6b16251
·
verified ·
1 Parent(s): de79232

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -3,9 +3,10 @@ from openai import OpenAI
3
  import gradio as gr
4
 
5
  # Retrieve API key from environment variable
6
- os.environ['OPENAI_API_KEY'] = 'sk-proj-EDY3jlWEqNq4xkGk0inbT3BlbkFJKbN26l1g02vd16B11Ksb'
7
  api_key = os.environ.get('sk-proj-EDY3jlWEqNq4xkGk0inbT3BlbkFJKbN26l1g02vd16B11Ksb')
8
- print(api_key)
 
 
9
 
10
  client = OpenAI(api_key=api_key)
11
 
@@ -28,3 +29,4 @@ def predict(message, history):
28
  yield partial_message
29
 
30
  gr.ChatInterface(predict).launch()
 
 
3
  import gradio as gr
4
 
5
  # Retrieve API key from environment variable
 
6
  api_key = os.environ.get('sk-proj-EDY3jlWEqNq4xkGk0inbT3BlbkFJKbN26l1g02vd16B11Ksb')
7
+
8
+ if api_key is None:
9
+ raise ValueError("Please set the environment variable 'OPENAI_API_KEY' with your OpenAI API key.")
10
 
11
  client = OpenAI(api_key=api_key)
12
 
 
29
  yield partial_message
30
 
31
  gr.ChatInterface(predict).launch()
32
+