diff --git a/.env.example b/.env.example index 4d8f7de..687281a 100644 --- a/.env.example +++ b/.env.example @@ -17,6 +17,14 @@ MINI_APP_ALLOWED_ORIGINS=http://localhost:5173 # Parsing / AI OPENAI_API_KEY=your-openai-api-key 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_SHARED_SECRET=your-scheduler-shared-secret diff --git a/infra/terraform/README.md b/infra/terraform/README.md index d6de3bb..62df321 100644 --- a/infra/terraform/README.md +++ b/infra/terraform/README.md @@ -73,6 +73,15 @@ Recommended approach: - Keep `project_id` separate for dev/prod when possible - Keep non-secret bot config in `*.tfvars`: - 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` ## CI validation diff --git a/infra/terraform/main.tf b/infra/terraform/main.tf index ab28a37..52492e3 100644 --- a/infra/terraform/main.tf +++ b/infra/terraform/main.tf @@ -93,6 +93,30 @@ module "bot_api_service" { var.bot_parser_model == null ? {} : { 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 ? {} : { MINI_APP_ALLOWED_ORIGINS = join(",", var.bot_mini_app_allowed_origins) }, diff --git a/infra/terraform/terraform.tfvars.example b/infra/terraform/terraform.tfvars.example index 87d4768..645f7e4 100644 --- a/infra/terraform/terraform.tfvars.example +++ b/infra/terraform/terraform.tfvars.example @@ -11,7 +11,15 @@ mini_app_image = "europe-west1-docker.pkg.dev/my-gcp-project/household-bot/mini database_url_secret_id = "database-url" telegram_bot_token_secret_id = "telegram-bot-token" 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 = [ "https://household-dev-mini-app-abc123-ew.a.run.app" ] diff --git a/infra/terraform/variables.tf b/infra/terraform/variables.tf index 5cb74f6..24a5b63 100644 --- a/infra/terraform/variables.tf +++ b/infra/terraform/variables.tf @@ -76,6 +76,62 @@ variable "bot_parser_model" { 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" { description = "Optional allow-list of mini app origins for bot CORS handling" type = list(string)