File tree Expand file tree Collapse file tree 1 file changed +6
-24
lines changed
atomic-examples/fastapi-memory/fastapi_memory/lib Expand file tree Collapse file tree 1 file changed +6
-24
lines changed Original file line number Diff line number Diff line change @@ -13,30 +13,12 @@ def get_api_key() -> str:
1313 ValueError: If OPENAI_API_KEY environment variable is not set
1414 """
1515 api_key = os .getenv ("OPENAI_API_KEY" )
16- if api_key :
17- return api_key
18-
19- # Fallback: Try to load from local .env or monorepo quickstart .env
20- # This is for development convenience in the atomic-monorepo
21- from pathlib import Path
22-
23- search_paths = [
24- Path (".env" ),
25- Path (".." ) / "quickstart" / ".env" ,
26- ]
27-
28- for env_path in search_paths :
29- if env_path .exists ():
30- try :
31- content = env_path .read_text (encoding = "utf-8" )
32- for line in content .splitlines ():
33- line = line .strip ()
34- if line .startswith ("OPENAI_API_KEY=" ):
35- return line .split ("=" , 1 )[1 ].strip ().strip ('"' ).strip ("'" )
36- except Exception :
37- continue
38-
39- raise ValueError ("OPENAI_API_KEY environment variable is required. " "Please set it or create a .env file." )
16+ if not api_key :
17+ raise ValueError (
18+ "OPENAI_API_KEY environment variable is required. "
19+ "Please set it in your environment before running the application."
20+ )
21+ return api_key
4022
4123
4224# Constants
You can’t perform that action at this time.
0 commit comments