Spaces:
Build error
Build error
jh000107
commited on
Commit
·
fd97b93
1
Parent(s):
cc9e3ea
Updating key part
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import os
|
2 |
import openai
|
3 |
from openai import OpenAI
|
4 |
-
from dotenv import load_dotenv
|
5 |
|
6 |
import re
|
7 |
import matplotlib.pyplot as plt
|
@@ -187,9 +187,16 @@ def get_completion(conversation, model="gpt-4-1106-preview"):
|
|
187 |
|
188 |
[{sample_output}]
|
189 |
"""
|
|
|
|
|
|
|
|
|
|
|
190 |
|
|
|
|
|
|
|
191 |
client = OpenAI()
|
192 |
-
openai.api_key = os.environ['OPENAI_KEY']
|
193 |
|
194 |
messages = [{"role": "user", "content": prompt}]
|
195 |
response = client.chat.completions.create(
|
|
|
1 |
import os
|
2 |
import openai
|
3 |
from openai import OpenAI
|
4 |
+
from dotenv import load_dotenv
|
5 |
|
6 |
import re
|
7 |
import matplotlib.pyplot as plt
|
|
|
187 |
|
188 |
[{sample_output}]
|
189 |
"""
|
190 |
+
load_dotenv()
|
191 |
+
openai_api_key = os.getenv('OPENAI_API_KEY')
|
192 |
+
|
193 |
+
if openai_api_key is None:
|
194 |
+
raise ValueError("No OpenAI API key found. Please set the OPENAI_API_KEY environment variable.")
|
195 |
|
196 |
+
|
197 |
+
openai.api_key = openai_api_key
|
198 |
+
|
199 |
client = OpenAI()
|
|
|
200 |
|
201 |
messages = [{"role": "user", "content": prompt}]
|
202 |
response = client.chat.completions.create(
|