Config & Settings¶
Configuration is split into two files: settings.py for all tunable
parameters, and prompts.py for all LLM prompt strings.
This separation means you can tune retrieval behaviour (changing RRF_K,
RETRIEVAL_N) or swap LLM providers (changing GCP_GEMINI_MODEL) purely
through environment variables — no code changes needed.
Settings¶
All parameters are read from environment variables at startup (via python-dotenv).
Defaults are shown below. Override any value in your .env file.
GCP_PROJECT_ID=top-arc-65ca
GCP_LOCATION_ID=australia-southeast1
GCP_EMBED_MODEL=text-embedding-005
GCP_GEMINI_MODEL=gemini-2.5-flash
GCLOUD_PATH=/path/to/gcloud
HTTPS_PROXY=cloudproxy.auiag.corp:8080 # omit if not behind a proxy
DB_DSN=dbname=anzsic_db
RRF_K=60
RETRIEVAL_N=20
TOP_K=5
EMBED_DIM=768
settings ¶
config/settings.py ────────────────────────────────────────────────────────────────────────────── Single source of truth for all tuneable parameters.
All values can be overridden via environment variables or a .env file placed at the project root. The frozen dataclass ensures settings are never mutated at runtime.
To swap providers, change the relevant env var — no code edits required: GCP_EMBED_MODEL → swap embedding model GCP_GEMINI_MODEL → swap LLM model DB_DSN → swap database
Settings
dataclass
¶
Immutable application settings loaded from environment variables.
Source code in prod/config/settings.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
get_settings
cached
¶
Returns a cached singleton Settings instance.
Use this everywhere instead of instantiating Settings() directly — it guarantees a single object is shared across the entire process.
Source code in prod/config/settings.py
Prompts¶
All LLM prompt strings live in one place. To tune how Gemini re-ranks
candidates, edit RERANK_SYSTEM_BASE. To change the output schema, edit
RERANK_USER_TEMPLATE and update the corresponding Pydantic models.
prompts ¶
config/prompts.py ────────────────────────────────────────────────────────────────────────────── All LLM prompt strings in one place.
Why centralise prompts? • Easy to diff and review prompt changes in version control • Swap or tune a prompt without touching service logic • Single source for prompt versioning / A-B testing
To change the re-ranking prompt: edit RERANK_SYSTEM_BASE below. To support a different output schema: change RERANK_OUTPUT_SCHEMA.
build_system_prompt ¶
Assembles the Gemini system prompt, optionally appending the full CSV.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_reference
|
bool
|
When True, appends all 5,236 ANZSIC codes as a fallback lookup table for low-confidence queries. |
required |
csv_reference
|
str
|
Pre-loaded CSV reference string (code: desc lines). |
required |
Returns:
| Type | Description |
|---|---|
str
|
Complete system prompt string ready to send to the LLM. |
Source code in prod/config/prompts.py
build_candidate_block ¶
Renders the numbered candidate list for the LLM user message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candidates
|
list[dict]
|
List of candidate dicts (from Candidate.model_dump()). |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted multi-line string. |
Source code in prod/config/prompts.py
build_user_message ¶
Assembles the user-turn message for the LLM.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Raw input description from the user. |
required |
candidates
|
list[dict]
|
List of candidate dicts. |
required |
top_k
|
int
|
Number of results to request from the LLM. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted user message string. |