Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -12,9 +12,8 @@ def get_api_key():
|
|
12 |
|
13 |
# Function to interact with the OpenAI API with streaming
|
14 |
def generate_response(prompt, model_name, api_key, extra_instructions=""):
|
15 |
-
openai.api_key = api_key
|
16 |
try:
|
17 |
-
client = openai.OpenAI() # Instantiate OpenAI client
|
18 |
|
19 |
messages = [{"role": "user", "content": prompt + "\n" + extra_instructions}]
|
20 |
stream = client.chat.completions.create(
|
|
|
12 |
|
13 |
# Function to interact with the OpenAI API with streaming
|
14 |
def generate_response(prompt, model_name, api_key, extra_instructions=""):
|
|
|
15 |
try:
|
16 |
+
client = openai.OpenAI(api_key=api_key) # Instantiate OpenAI client with api_key
|
17 |
|
18 |
messages = [{"role": "user", "content": prompt + "\n" + extra_instructions}]
|
19 |
stream = client.chat.completions.create(
|