Skip to content

Commit

Permalink
remove local env
Browse files Browse the repository at this point in the history
  • Loading branch information
John Dutchover committed Mar 27, 2024
1 parent 5f06075 commit 35b9295
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import os

import marvin
Expand All @@ -9,18 +10,25 @@
from routers import facts, poems, translate

marvin.settings.llm_model = "openai/gpt-3.5-turbo"

# Check if the OpenAI API key is already set in environment variables
marvin_openai_api_key = os.environ.get("MARVIN_OPENAI_API_KEY")

if not marvin_openai_api_key:
if marvin_openai_api_key is None:
# Load the API key from .env if not set in the environment
load_dotenv()

# Retrieve the API key from the loaded .env file
marvin_openai_api_key = os.getenv("MARVIN_OPENAI_API_KEY")

if marvin_openai_api_key:
if marvin_openai_api_key is not None:
marvin.settings.openai.api_key = marvin_openai_api_key
else:
raise ValueError("main.py OpenAI API key is not set.")
logging.warning("OpenAI API key is not set. Some functionality may be limited.")

# Set up logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

# Create FastAPI instance
app = FastAPI()
Expand Down

0 comments on commit 35b9295

Please sign in to comment.