File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change
1
+ import logging
1
2
import os
2
3
3
4
import marvin
9
10
from routers import facts , poems , translate
10
11
11
12
marvin .settings .llm_model = "openai/gpt-3.5-turbo"
13
+
14
+ # Check if the OpenAI API key is already set in environment variables
12
15
marvin_openai_api_key = os .environ .get ("MARVIN_OPENAI_API_KEY" )
13
16
14
- if not marvin_openai_api_key :
17
+ if marvin_openai_api_key is None :
15
18
# Load the API key from .env if not set in the environment
16
19
load_dotenv ()
20
+
21
+ # Retrieve the API key from the loaded .env file
17
22
marvin_openai_api_key = os .getenv ("MARVIN_OPENAI_API_KEY" )
18
23
19
- if marvin_openai_api_key :
24
+ if marvin_openai_api_key is not None :
20
25
marvin .settings .openai .api_key = marvin_openai_api_key
21
26
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 ." )
23
28
29
+ # Set up logging
30
+ logging .basicConfig (level = logging .INFO )
31
+ logger = logging .getLogger (__name__ )
24
32
25
33
# Create FastAPI instance
26
34
app = FastAPI ()
You can’t perform that action at this time.
0 commit comments