chore(infra): align bot runtime env configuration

This commit is contained in:
2026-03-11 02:43:28 +04:00
parent 43285e590b
commit 3c0a53981a
5 changed files with 106 additions and 1 deletions

View File

@@ -17,6 +17,14 @@ MINI_APP_ALLOWED_ORIGINS=http://localhost:5173
# Parsing / AI # Parsing / AI
OPENAI_API_KEY=your-openai-api-key OPENAI_API_KEY=your-openai-api-key
PARSER_MODEL=gpt-4.1-mini PARSER_MODEL=gpt-4.1-mini
PURCHASE_PARSER_MODEL=gpt-5-mini
ASSISTANT_MODEL=gpt-5-mini
ASSISTANT_TIMEOUT_MS=15000
ASSISTANT_MEMORY_MAX_TURNS=12
ASSISTANT_RATE_LIMIT_BURST=5
ASSISTANT_RATE_LIMIT_BURST_WINDOW_MS=60000
ASSISTANT_RATE_LIMIT_ROLLING=50
ASSISTANT_RATE_LIMIT_ROLLING_WINDOW_MS=86400000
# Scheduler # Scheduler
SCHEDULER_SHARED_SECRET=your-scheduler-shared-secret SCHEDULER_SHARED_SECRET=your-scheduler-shared-secret

View File

@@ -73,6 +73,15 @@ Recommended approach:
- Keep `project_id` separate for dev/prod when possible - Keep `project_id` separate for dev/prod when possible
- Keep non-secret bot config in `*.tfvars`: - Keep non-secret bot config in `*.tfvars`:
- optional `bot_parser_model` - optional `bot_parser_model`
- optional `bot_purchase_parser_model`
- optional `bot_assistant_model`
- optional assistant runtime knobs:
`bot_assistant_timeout_ms`,
`bot_assistant_memory_max_turns`,
`bot_assistant_rate_limit_burst`,
`bot_assistant_rate_limit_burst_window_ms`,
`bot_assistant_rate_limit_rolling`,
`bot_assistant_rate_limit_rolling_window_ms`
- optional `bot_mini_app_allowed_origins` - optional `bot_mini_app_allowed_origins`
## CI validation ## CI validation

View File

@@ -93,6 +93,30 @@ module "bot_api_service" {
var.bot_parser_model == null ? {} : { var.bot_parser_model == null ? {} : {
PARSER_MODEL = var.bot_parser_model PARSER_MODEL = var.bot_parser_model
}, },
var.bot_purchase_parser_model == null ? {} : {
PURCHASE_PARSER_MODEL = var.bot_purchase_parser_model
},
var.bot_assistant_model == null ? {} : {
ASSISTANT_MODEL = var.bot_assistant_model
},
var.bot_assistant_timeout_ms == null ? {} : {
ASSISTANT_TIMEOUT_MS = tostring(var.bot_assistant_timeout_ms)
},
var.bot_assistant_memory_max_turns == null ? {} : {
ASSISTANT_MEMORY_MAX_TURNS = tostring(var.bot_assistant_memory_max_turns)
},
var.bot_assistant_rate_limit_burst == null ? {} : {
ASSISTANT_RATE_LIMIT_BURST = tostring(var.bot_assistant_rate_limit_burst)
},
var.bot_assistant_rate_limit_burst_window_ms == null ? {} : {
ASSISTANT_RATE_LIMIT_BURST_WINDOW_MS = tostring(var.bot_assistant_rate_limit_burst_window_ms)
},
var.bot_assistant_rate_limit_rolling == null ? {} : {
ASSISTANT_RATE_LIMIT_ROLLING = tostring(var.bot_assistant_rate_limit_rolling)
},
var.bot_assistant_rate_limit_rolling_window_ms == null ? {} : {
ASSISTANT_RATE_LIMIT_ROLLING_WINDOW_MS = tostring(var.bot_assistant_rate_limit_rolling_window_ms)
},
length(var.bot_mini_app_allowed_origins) == 0 ? {} : { length(var.bot_mini_app_allowed_origins) == 0 ? {} : {
MINI_APP_ALLOWED_ORIGINS = join(",", var.bot_mini_app_allowed_origins) MINI_APP_ALLOWED_ORIGINS = join(",", var.bot_mini_app_allowed_origins)
}, },

View File

@@ -12,6 +12,14 @@ database_url_secret_id = "database-url"
telegram_bot_token_secret_id = "telegram-bot-token" telegram_bot_token_secret_id = "telegram-bot-token"
openai_api_key_secret_id = "openai-api-key" openai_api_key_secret_id = "openai-api-key"
bot_parser_model = "gpt-4.1-mini" bot_parser_model = "gpt-4.1-mini"
bot_purchase_parser_model = "gpt-5-mini"
bot_assistant_model = "gpt-5-mini"
bot_assistant_timeout_ms = 15000
bot_assistant_memory_max_turns = 12
bot_assistant_rate_limit_burst = 5
bot_assistant_rate_limit_burst_window_ms = 60000
bot_assistant_rate_limit_rolling = 50
bot_assistant_rate_limit_rolling_window_ms = 86400000
bot_mini_app_allowed_origins = [ bot_mini_app_allowed_origins = [
"https://household-dev-mini-app-abc123-ew.a.run.app" "https://household-dev-mini-app-abc123-ew.a.run.app"
] ]

View File

@@ -76,6 +76,62 @@ variable "bot_parser_model" {
nullable = true nullable = true
} }
variable "bot_purchase_parser_model" {
description = "Optional PURCHASE_PARSER_MODEL override for bot runtime"
type = string
default = null
nullable = true
}
variable "bot_assistant_model" {
description = "Optional ASSISTANT_MODEL override for bot runtime"
type = string
default = null
nullable = true
}
variable "bot_assistant_timeout_ms" {
description = "Optional ASSISTANT_TIMEOUT_MS override for bot runtime"
type = number
default = null
nullable = true
}
variable "bot_assistant_memory_max_turns" {
description = "Optional ASSISTANT_MEMORY_MAX_TURNS override for bot runtime"
type = number
default = null
nullable = true
}
variable "bot_assistant_rate_limit_burst" {
description = "Optional ASSISTANT_RATE_LIMIT_BURST override for bot runtime"
type = number
default = null
nullable = true
}
variable "bot_assistant_rate_limit_burst_window_ms" {
description = "Optional ASSISTANT_RATE_LIMIT_BURST_WINDOW_MS override for bot runtime"
type = number
default = null
nullable = true
}
variable "bot_assistant_rate_limit_rolling" {
description = "Optional ASSISTANT_RATE_LIMIT_ROLLING override for bot runtime"
type = number
default = null
nullable = true
}
variable "bot_assistant_rate_limit_rolling_window_ms" {
description = "Optional ASSISTANT_RATE_LIMIT_ROLLING_WINDOW_MS override for bot runtime"
type = number
default = null
nullable = true
}
variable "bot_mini_app_allowed_origins" { variable "bot_mini_app_allowed_origins" {
description = "Optional allow-list of mini app origins for bot CORS handling" description = "Optional allow-list of mini app origins for bot CORS handling"
type = list(string) type = list(string)