Skip to content

Commit 35b9295

Browse files
author
John Dutchover
committed
remove local env
1 parent 5f06075 commit 35b9295

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

app/main.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
import os
23

34
import marvin
@@ -9,18 +10,25 @@
910
from routers import facts, poems, translate
1011

1112
marvin.settings.llm_model = "openai/gpt-3.5-turbo"
13+
14+
# Check if the OpenAI API key is already set in environment variables
1215
marvin_openai_api_key = os.environ.get("MARVIN_OPENAI_API_KEY")
1316

14-
if not marvin_openai_api_key:
17+
if marvin_openai_api_key is None:
1518
# Load the API key from .env if not set in the environment
1619
load_dotenv()
20+
21+
# Retrieve the API key from the loaded .env file
1722
marvin_openai_api_key = os.getenv("MARVIN_OPENAI_API_KEY")
1823

19-
if marvin_openai_api_key:
24+
if marvin_openai_api_key is not None:
2025
marvin.settings.openai.api_key = marvin_openai_api_key
2126
else:
22-
raise ValueError("main.py OpenAI API key is not set.")
27+
logging.warning("OpenAI API key is not set. Some functionality may be limited.")
2328

29+
# Set up logging
30+
logging.basicConfig(level=logging.INFO)
31+
logger = logging.getLogger(__name__)
2432

2533
# Create FastAPI instance
2634
app = FastAPI()

0 commit comments

Comments
 (0)