epalvarez commited on
Commit
c3f98dc
·
verified ·
1 Parent(s): a6645e0

Correct the way the OpenAI key is accessed by app.py from the HuggingFace Secrets: openai_api_key = os.environ.get("OpenAI_API_key_GL_Adv_Python_Project")

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -35,12 +35,13 @@ hf_space_dir = os.getcwd()
35
 
36
  #import os
37
  # Set your API key from an environment variable: get("OPENAI_API_KEY")
 
38
  # app.py should have access to the OpenAI key stored as a HuggingFace secret in the HuggingFace space where the app.py will be uploaded, by accessing it through the environment variables
39
  # openai_api_key = os.getenv("OpenAI_API_key_GL_Adv_Python_Project")
40
  # or:
41
- # openai_api_key = os.environ.get("OpenAI_API_key_GL_Adv_Python_Project")
42
  # or:
43
- openai_api_key = os.environ("OpenAI_API_key_GL_Adv_Python_Project") # environ is a dictionary with all the environment variables, so to access the value, provide the key
44
 
45
  # Set Up Your API Key: You'll need an API key from OpenAI. You can obtain one by signing up on the OpenAI website and navigating to your API keys in the dashboard.
46
  # This approach ensures that your API key remains secure and is not exposed in your code.
 
35
 
36
  #import os
37
  # Set your API key from an environment variable: get("OPENAI_API_KEY")
38
+ # environ is a dictionary with all the environment variables, so to access the value, provide the key
39
  # app.py should have access to the OpenAI key stored as a HuggingFace secret in the HuggingFace space where the app.py will be uploaded, by accessing it through the environment variables
40
  # openai_api_key = os.getenv("OpenAI_API_key_GL_Adv_Python_Project")
41
  # or:
42
+ openai_api_key = os.environ.get("OpenAI_API_key_GL_Adv_Python_Project")
43
  # or:
44
+ # openai_api_key = os.environ("OpenAI_API_key_GL_Adv_Python_Project") # this produces error while "starting" app.py in HuggingFace: TypeError: '_Environ' object is not callable
45
 
46
  # Set Up Your API Key: You'll need an API key from OpenAI. You can obtain one by signing up on the OpenAI website and navigating to your API keys in the dashboard.
47
  # This approach ensures that your API key remains secure and is not exposed in your code.