Created
January 30, 2026 15:28
-
-
Save rpappalax/93d2ec47f0067fcc7d9877409f70dc70 to your computer and use it in GitHub Desktop.
app/llm/vertex_init.py
This file contains hidden or 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 logging | |
| import vertexai | |
| from app.common.config import Settings | |
| _INITIALIZED = False | |
| def init_vertex(settings: Settings) -> None: | |
| """Initialize Vertex AI once per process.""" | |
| global _INITIALIZED | |
| if _INITIALIZED: | |
| return | |
| project = settings.require_project() | |
| vertexai.init(project=project, location=settings.gcp_location) | |
| logging.getLogger(__name__).info( | |
| "Vertex AI initialized (project=%s, location=%s).", | |
| project, | |
| settings.gcp_location, | |
| ) | |
| _INITIALIZED = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment