Cristobal299 commited on
Commit
d4989f5
·
verified ·
1 Parent(s): 5c0804f

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -15,11 +15,11 @@ if not openai_api_key:
15
  openai.api_key = openai_api_key
16
 
17
  def improve_code(user_code, language):
18
- if startup_error:
19
- return f"Error: {startup_error}"
20
  """
21
  Sends the user code to OpenAI GPT model and asks for an improved version.
22
  """
 
 
23
  system_prompt = f"You are an expert {language} developer. Refactor and improve the following code. Keep the same functionality but make it cleaner, more efficient and well commented."
24
  messages = [
25
  {"role": "system", "content": system_prompt},
 
15
  openai.api_key = openai_api_key
16
 
17
  def improve_code(user_code, language):
 
 
18
  """
19
  Sends the user code to OpenAI GPT model and asks for an improved version.
20
  """
21
+ if not openai_api_key:
22
+ return "Error: OpenAI API key not set. Please set the OPENAI_API_KEY environment variable."
23
  system_prompt = f"You are an expert {language} developer. Refactor and improve the following code. Keep the same functionality but make it cleaner, more efficient and well commented."
24
  messages = [
25
  {"role": "system", "content": system_prompt},