How to Configure Hiring Agent to Use Ollama or Google Gemini
Configure Hiring Agent to use Ollama or Google Gemini by setting the LLM_PROVIDER environment variable and ensuring your chosen model name exists in the MODEL_PROVIDER_MAPPING dictionary located in prompt.py. The system automatically instantiates OllamaProvider for local models or GeminiProvider for Google's API based on this configuration, with Ollama serving as the fallback default.
The interviewstreet/hiring-agent repository implements a provider-agnostic architecture that routes LLM requests through a centralized initialization function. Understanding how the configuration files interact allows you to seamlessly switch between local Ollama instances and Google Gemini's managed API without modifying core evaluation logic.
Understanding the Provider Selection Logic
Hiring Agent determines which LLM backend to use through a lookup mechanism defined in prompt.py and executed in llm_utils.py.
The MODEL_PROVIDER_MAPPING dictionary (lines 48–64 of prompt.py) maps specific model strings to provider enums:
MODEL_PROVIDER_MAPPING = {
"gemma3:4b": ModelProvider.OLLAMA,
"gemini-3.5-flash": ModelProvider.GEMINI,
"gemini-2.5-pro": ModelProvider.GEMINI,
# ... additional mappings
}
When you instantiate a ResumeEvaluator, it calls initialize_llm_provider(model_name) from llm_utils.py. This function checks the mapping table and your environment variables:
- If the model maps to
ModelProvider.GEMINIandGEMINI_API_KEYis present, it returns aGeminiProviderinstance - Otherwise, it defaults to
OllamaProvider
The initialization logic explicitly warns you if the Gemini API key is missing, automatically falling back to Ollama to prevent runtime errors.
Configuration Methods
You have two primary methods to control provider selection: environment-based configuration and runtime parameter override.
Method 1: Environment Variables
Set these variables in your .env file or export them directly in your shell:
LLM_PROVIDER– Accepted values areollamaorgemini. If omitted, the system defaults toollama.DEFAULT_MODEL– The model string to use (e.g.,gemma3:4borgemini-3.5-flash). Must exist inMODEL_PROVIDER_MAPPING.GEMINI_API_KEY– Required only when using Google Gemini. Loaded from environment (line 66 ofprompt.py).
Method 2: Runtime Model Override
Pass a specific model_name parameter when constructing ResumeEvaluator in evaluator.py (lines 24–40). The provider initialization logic ignores the LLM_PROVIDER environment variable if the requested model explicitly maps to a different provider in the lookup table.
Step-by-Step Configuration Examples
Setting Up Ollama (Local Deployment)
For local inference using Ollama, minimal configuration is required since Ollama is the default provider:
# .env configuration
LLM_PROVIDER=ollama
DEFAULT_MODEL=gemma3:4b
# Do not set GEMINI_API_KEY
from evaluator import ResumeEvaluator
evaluator = ResumeEvaluator()
# Internally calls initialize_llm_provider("gemma3:4b")
# Returns OllamaProvider based on MODEL_PROVIDER_MAPPING
result = evaluator.evaluate_resume(resume_text)
Configuring Google Gemini (Cloud API)
To use Google Gemini, you must provide a valid API key and select a Gemini-supported model:
# .env configuration
LLM_PROVIDER=gemini
DEFAULT_MODEL=gemini-3.5-flash
GEMINI_API_KEY=your_api_key_here
from evaluator import ResumeEvaluator
evaluator = ResumeEvaluator()
# Maps to GeminiProvider via MODEL_PROVIDER_MAPPING
result = evaluator.evaluate_resume(resume_text)
If GEMINI_API_KEY is missing, the system logs a warning ("⚠️ Gemini API key not found. Falling back to Ollama.") and automatically instantiates OllamaProvider instead.
Runtime Provider Override (Per-Request Switching)
You can force a specific provider for individual evaluations without changing environment variables by leveraging the model name mapping:
from evaluator import ResumeEvaluator
# Override to Gemini regardless of LLM_PROVIDER setting
evaluator = ResumeEvaluator(model_name="gemini-2.5-pro")
# initialize_llm_provider detects ModelProvider.GEMINI and instantiates GeminiProvider
result = evaluator.evaluate_resume(resume_text)
This approach is useful for A/B testing or gradually migrating from local to cloud-based models.
Key Source Files and Architecture
Understanding these files helps troubleshoot configuration issues:
prompt.py– ContainsMODEL_PROVIDER_MAPPING,ModelProviderenum definitions, and environment variable loading logicllm_utils.py– Implementsinitialize_llm_provider()function and the concreteOllamaProviderandGeminiProviderclassesevaluator.py– TheResumeEvaluatorclass (lines 24–40) that orchestrates provider initialization and resume evaluationmodels.py– Defines theModelProviderenum and provider protocol interfaces
Summary
- Configuration is model-driven: The
MODEL_PROVIDER_MAPPINGinprompt.pyultimately determines whetherinitialize_llm_providerselects Ollama or Gemini, not just theLLM_PROVIDERvariable alone. - Environment variables control defaults: Set
LLM_PROVIDERandGEMINI_API_KEYto establish system-wide defaults, with automatic fallback to Ollama if Gemini credentials are missing. - Runtime flexibility: Pass
model_namedirectly toResumeEvaluatorto override environment settings for specific evaluations. - Secure key management: Never hard-code
GEMINI_API_KEY; the source code expects it via environment variables (line 66 ofprompt.py).
Frequently Asked Questions
What happens if I don't set the LLM_PROVIDER environment variable?
If LLM_PROVIDER is missing or contains an invalid value, the system falls back to ModelProvider.OLLAMA as defined in the default configuration within prompt.py. Your model requests will route to the OllamaProvider unless the specific model name you request exists in MODEL_PROVIDER_MAPPING and maps to Gemini.
Can I switch between Ollama and Gemini without restarting my application?
Yes, but only by instantiating a new ResumeEvaluator with a different model_name parameter. The provider is determined during initialization in evaluator.py (lines 24–40) via the initialize_llm_provider call. Once instantiated, the evaluator maintains its provider instance. Create a new evaluator instance with a model name mapping to your desired provider to switch backends at runtime.
Where is the list of supported model names defined?
The authoritative list resides in the MODEL_PROVIDER_MAPPING dictionary in prompt.py (lines 48–64). This mapping associates string identifiers like "gemma3:4b" or "gemini-3.5-flash" with ModelProvider.OLLAMA or ModelProvider.GEMINI enum values. Adding support for new models requires updating this dictionary and ensuring the corresponding provider class in llm_utils.py supports the model string.
Is the GEMINI_API_KEY required if I'm only using Ollama?
No. The GEMINI_API_KEY is only checked when initialize_llm_provider determines that the requested model maps to ModelProvider.GEMINI. If you exclusively use models mapped to Ollama (or set LLM_PROVIDER=ollama), the Google API key can remain unset without causing errors or warnings during provider initialization.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →