-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(webapp): reload LLM pricing registry on Redis pub/sub #3534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
e768e53
1699582
1381c9d
0985da3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| area: webapp | ||
| type: improvement | ||
| --- | ||
|
|
||
| The LLM pricing registry now reloads from the database whenever a publish lands on `LLM_PRICING_RELOAD_CHANNEL` on the worker Redis, instead of waiting for the next 5-minute interval. LLM model and pricing changes reflect in cost enrichment within seconds. |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1424,6 +1424,14 @@ const EnvironmentSchema = z | |||||
| // LLM cost tracking | ||||||
| LLM_COST_TRACKING_ENABLED: BoolEnv.default(true), | ||||||
| LLM_PRICING_RELOAD_INTERVAL_MS: z.coerce.number().int().default(5 * 60 * 1000), // 5 minutes | ||||||
| LLM_PRICING_RELOAD_CHANNEL: z.string().default("llm-registry:reload"), | ||||||
| LLM_PRICING_RELOAD_DEBOUNCE_MS: z.coerce.number().int().default(1000), | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cat -n apps/webapp/app/env.server.ts | sed -n '1420,1440p'Repository: triggerdotdev/trigger.dev Length of output: 1638 🏁 Script executed: # Search for usages of LLM_PRICING_RELOAD_DEBOUNCE_MS
rg "LLM_PRICING_RELOAD_DEBOUNCE_MS" --type ts --type tsxRepository: triggerdotdev/trigger.dev Length of output: 97 🏁 Script executed: # Check other debounce or timeout env variables in the same file to see if they have bounds
rg "DEBOUNCE|TIMEOUT|INTERVAL" apps/webapp/app/env.server.ts -A 1 -B 1Repository: triggerdotdev/trigger.dev Length of output: 15620 🏁 Script executed: # Search for usages of LLM_PRICING_RELOAD_DEBOUNCE_MS
rg "LLM_PRICING_RELOAD_DEBOUNCE_MS" -A 3 -B 3Repository: triggerdotdev/trigger.dev Length of output: 1880 🏁 Script executed: # Check the context where this debounce variable is used - look for debounce function calls
rg "debounce" --type ts -B 2 -A 2 | head -100Repository: triggerdotdev/trigger.dev Length of output: 7594 🏁 Script executed: # Look at how debounceMs is used in the llmPricingRegistry.server.ts file
cat -n apps/webapp/app/v3/llmPricingRegistry.server.ts | head -150Repository: triggerdotdev/trigger.dev Length of output: 5508 🏁 Script executed: # Get the full context of the scheduleReload function and how debounceMs is used
rg "scheduleReload|debounceMs|pendingReloadTimer" apps/webapp/app/v3/llmPricingRegistry.server.ts -B 2 -A 5Repository: triggerdotdev/trigger.dev Length of output: 1367 Add a lower bound to debounce milliseconds to prevent misconfiguration. At line 1428, Suggested patch- LLM_PRICING_RELOAD_DEBOUNCE_MS: z.coerce.number().int().default(1000),
+ LLM_PRICING_RELOAD_DEBOUNCE_MS: z.coerce.number().int().min(0).default(1000),📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| // Whether to subscribe this process to the LLM_PRICING_RELOAD_CHANNEL. | ||||||
| // Default off — only OTel-ingesting services need real-time pricing | ||||||
| // freshness; dashboard/worker processes are fine on the existing | ||||||
| // 5-minute periodic reload. In multi-service deployments, set this to | ||||||
| // true on the span-ingesting services. | ||||||
| LLM_PRICING_RELOAD_PUBSUB_ENABLED: BoolEnv.default(false), | ||||||
| LLM_PRICING_SEED_ON_STARTUP: BoolEnv.default(false), | ||||||
| LLM_PRICING_READY_TIMEOUT_MS: z.coerce.number().int().default(500), | ||||||
| LLM_METRICS_BATCH_SIZE: z.coerce.number().int().default(5000), | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.