-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: add CTAs to AI budget admin notifications #28138
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
coderd/database/migrations/000579_ai_budget_admin_notification_actions.down.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| UPDATE notification_templates | ||
| SET | ||
| body_template = $$User **{{.Labels.username}}** has used more than {{.Labels.threshold}}% of their {{.Labels.period}} AI budget ({{.Labels.limit}}). | ||
|
|
||
| Effective group: **{{.Labels.effective_group_name}}** | ||
| {{- if eq .Labels.limit_source "user_override"}} | ||
|
|
||
| This limit is a per-user override. | ||
| {{- end}} | ||
|
|
||
| AI budget period: {{.Labels.period_start}} - {{.Labels.period_end}}$$, | ||
| actions = '[]'::jsonb | ||
| WHERE | ||
| id = '2a7b0ac1-00e1-4625-9cd5-1e5933972c77'; | ||
|
|
||
| UPDATE notification_templates | ||
| SET | ||
| body_template = $$User **{{.Labels.username}}** has reached their {{.Labels.period}} AI budget limit ({{.Labels.limit}}). Subsequent requests will be blocked. | ||
|
|
||
| Effective group: **{{.Labels.effective_group_name}}** | ||
| {{- if eq .Labels.limit_source "user_override"}} | ||
|
|
||
| This limit is a per-user override. | ||
| {{- end}} | ||
|
|
||
| AI budget period: {{.Labels.period_start}} - {{.Labels.period_end}}$$, | ||
| actions = '[]'::jsonb | ||
| WHERE | ||
| id = '0bafe0ea-a78b-4217-ad05-1ef12e92e025'; |
43 changes: 43 additions & 0 deletions
43
coderd/database/migrations/000579_ai_budget_admin_notification_actions.up.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| UPDATE notification_templates | ||
| SET | ||
| body_template = $$User **{{.Labels.username}}** has used more than {{.Labels.threshold}}% of their {{.Labels.period}} AI budget ({{.Labels.limit}}). | ||
|
|
||
| Effective group: **{{.Labels.effective_group_name}}** | ||
| {{- if eq .Labels.limit_source "user_override"}} | ||
|
|
||
| This limit is a per-user override. | ||
| {{- end}} | ||
|
|
||
| AI budget period: {{.Labels.period_start}} - {{.Labels.period_end}} | ||
|
|
||
| [How to configure AI budgets](https://coder.com/docs/ai-coder/ai-gateway/cost-controls#budget)$$, | ||
| actions = '[ | ||
| { | ||
| "label": "Manage user AI budget", | ||
| "url": "{{base_url}}/organizations/{{.Labels.organization_name}}/groups/{{.Labels.effective_group_name}}?filter={{.Labels.username}}" | ||
| } | ||
| ]'::jsonb | ||
| WHERE | ||
| id = '2a7b0ac1-00e1-4625-9cd5-1e5933972c77'; | ||
|
|
||
| UPDATE notification_templates | ||
| SET | ||
| body_template = $$User **{{.Labels.username}}** has reached their {{.Labels.period}} AI budget limit ({{.Labels.limit}}). Subsequent requests will be blocked until {{.Labels.period_end}}. | ||
|
|
||
| Effective group: **{{.Labels.effective_group_name}}** | ||
| {{- if eq .Labels.limit_source "user_override"}} | ||
|
|
||
| This limit is a per-user override. | ||
| {{- end}} | ||
|
|
||
| AI budget period: {{.Labels.period_start}} - {{.Labels.period_end}} | ||
|
|
||
| Raise this user's limit to unblock them sooner. [How to configure AI budgets](https://coder.com/docs/ai-coder/ai-gateway/cost-controls#budget).$$, | ||
| actions = '[ | ||
| { | ||
| "label": "Manage user AI budget", | ||
| "url": "{{base_url}}/organizations/{{.Labels.organization_name}}/groups/{{.Labels.effective_group_name}}?filter={{.Labels.username}}" | ||
| } | ||
| ]'::jsonb | ||
| WHERE | ||
| id = '0bafe0ea-a78b-4217-ad05-1ef12e92e025'; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,11 +9,17 @@ | |
| "user_email": "[email protected]", | ||
| "user_name": "Bobby", | ||
| "user_username": "bobby", | ||
| "actions": [], | ||
| "actions": [ | ||
| { | ||
| "label": "Manage user AI budget", | ||
| "url": "http://test.com/organizations/coder/groups/Engineering?filter=alice" | ||
| } | ||
| ], | ||
| "labels": { | ||
| "effective_group_name": "Engineering", | ||
| "limit": "$1000.00", | ||
| "limit_source": "user_override", | ||
| "organization_name": "coder", | ||
| "period": "monthly", | ||
| "period_end": "August 1, 2026", | ||
| "period_start": "July 1, 2026", | ||
|
|
@@ -24,6 +30,6 @@ | |
| }, | ||
| "title": "alice has reached their monthly AI budget limit", | ||
| "title_markdown": "alice has reached their monthly AI budget limit", | ||
| "body": "User alice has reached their monthly AI budget limit ($1000.00). Subsequent requests will be blocked.\n\nEffective group: Engineering\n\nThis limit is a per-user override.\n\nAI budget period: July 1, 2026 - August 1, 2026", | ||
| "body_markdown": "User **alice** has reached their monthly AI budget limit ($1000.00). Subsequent requests will be blocked.\n\nEffective group: **Engineering**\n\nThis limit is a per-user override.\n\nAI budget period: July 1, 2026 - August 1, 2026" | ||
| "body": "User alice has reached their monthly AI budget limit ($1000.00). Subsequent requests will be blocked until August 1, 2026.\n\nEffective group: Engineering\n\nThis limit is a per-user override.\n\nAI budget period: July 1, 2026 - August 1, 2026\n\nRaise this user's limit to unblock them sooner. How to configure AI budgets (https://coder.com/docs/ai-coder/ai-gateway/cost-controls#budget).", | ||
| "body_markdown": "User **alice** has reached their monthly AI budget limit ($1000.00). Subsequent requests will be blocked until August 1, 2026.\n\nEffective group: **Engineering**\n\nThis limit is a per-user override.\n\nAI budget period: July 1, 2026 - August 1, 2026\n\nRaise this user's limit to unblock them sooner. [How to configure AI budgets](https://coder.com/docs/ai-coder/ai-gateway/cost-controls#budget)." | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.