artintel235 commited on
Commit
f918386
·
verified ·
1 Parent(s): c139381

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -2
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 within the function
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(