Last active
March 15, 2024 20:00
-
-
Save izikeros/5bfad1731b8a67eb7ceed792138a09ed to your computer and use it in GitHub Desktop.
[azure openai config] Configure azure openai with data from .env file #openai #llm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import openai | |
from dotenv import find_dotenv | |
from dotenv import load_dotenv | |
def configure_openai(): | |
# Configure OpenAI using load dotenv and find .env file | |
env_file = find_dotenv() | |
load_dotenv(env_file, verbose=True, override=True) | |
openai.api_type = "azure" | |
openai.api_key = os.getenv("OPENAI_API_KEY") | |
openai.api_base = os.getenv("OPENAI_API_BASE") | |
openai.api_version = os.getenv("OPENAI_API_VERSION") | |
completion_deployment_name = os.getenv("OPENAI_QA_DEPLOYMENT_NAME") | |
print(f"using {completion_deployment_name}") | |
return openai, completion_deployment_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment