MCPcopy Create free account
hub / github.com/google/adk-samples / _init_llm

Function _init_llm

python/agents/invoice-processing/eval/eval.py:74–96  ·  view source on GitHub ↗

Initialize LLM model. Returns None if unavailable.

()

Source from the content-addressed store, hash-verified

72
73# LLM configuration (only used when LLM evaluation is enabled)
74def _init_llm() -> Optional["GenerativeModel"]:
75 """Initialize LLM model. Returns None if unavailable."""
76 if not _LLM_AVAILABLE:
77 return None
78
79 # Load .env from project root
80 env_file = PROJECT_ROOT / ".env"
81 if not env_file.exists():
82 env_file = SCRIPT_DIR / ".env"
83 if env_file.exists():
84 load_dotenv(env_file)
85 else:
86 load_dotenv()
87
88 project_id = os.getenv("PROJECT_ID")
89 location = os.getenv("LOCATION", "us-central1")
90 model_name = os.getenv("GEMINI_FLASH_MODEL", "gemini-2.5-flash")
91
92 if not project_id:
93 return None
94
95 aiplatform.init(project=project_id, location=location)
96 return GenerativeModel(model_name)
97
98
99# Hardcoded fallback — used only when no master data is provided

Callers 1

mainFunction · 0.85

Calls 1

initMethod · 0.80

Tested by

no test coverage detected