Skip to content

Commit 81dfac6

Browse files
authored
Add MiniMax now longer free notification and use materialized views (#1400)
2 parents 90de222 + 5f3e037 commit 81dfac6

1 file changed

Lines changed: 44 additions & 28 deletions

File tree

src/lib/notifications.ts

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { hasReceivedPromotion } from '@/lib/promotionalCredits';
1313
import { getKiloPassStateForUser } from '@/lib/kilo-pass/state';
1414
import { db } from '@/lib/drizzle';
1515
import { fromMicrodollars } from '@/lib/utils';
16+
import { KILO_AUTO_FREE_MODEL } from '@/lib/kilo-auto-model';
1617

1718
/** Pre-fetched data shared across notification generators to avoid duplicate DB queries. */
1819
type NotificationContext = {
@@ -40,14 +41,6 @@ export type KiloNotification = {
4041
const normalUnconditionalNotifications: KiloNotification[] = [
4142
//If you need to check or personalize the notification, see examples at the bottom of this file
4243
//if you just want a simple straightforward global message, add it here.
43-
// Disabled: GLM-5 free period has long ended; no need to keep notifying users.
44-
// {
45-
// id: 'feb-25-glm5-free-ended',
46-
// title: 'GLM-5 Free Period Ended',
47-
// message:
48-
// 'The free period for GLM-5 has ended. Try another free model like MiniMax M2.5 or Trinity Large Preview!',
49-
// showIn: ['extension', 'cli'],
50-
// },
5144
{
5245
id: 'kilo-cli-jan-5',
5346
title: 'Kilo CLI',
@@ -119,6 +112,7 @@ export async function generateUserNotifications(user: User): Promise<KiloNotific
119112
generateAutoTopUpNotification,
120113
generateAutoTopUpOrgsNotification,
121114
generateByokProvidersNotification,
115+
generateMiniMaxNoLongerFreeNotification,
122116
generateFirstDayWelcomeNotification,
123117
generateKiloPassNotification,
124118
];
@@ -237,6 +231,46 @@ async function generateTeamsTrialNotification(
237231
];
238232
}
239233

234+
async function generateMiniMaxNoLongerFreeNotification(
235+
user: User,
236+
_ctx: NotificationContext
237+
): Promise<KiloNotification[]> {
238+
try {
239+
const users = await cachedPosthogQuery(
240+
z.array(z.tuple([z.string()]).transform(([userId]) => userId))
241+
)(
242+
'minimax-no-longer-free-users',
243+
'select id from notification_mar_23_minimax_no_longer_free limit 5e5'
244+
);
245+
246+
if (!users.includes(user.id)) {
247+
console.debug(
248+
'[generateMiniMaxNoLongerFreeNotification] user has not used MiniMax M2.5 free'
249+
);
250+
return [];
251+
}
252+
253+
console.debug('[generateMiniMaxNoLongerFreeNotification] user has used MiniMax M2.5 free');
254+
return [
255+
{
256+
id: 'minimax-no-longer-free-mar-23',
257+
title: 'MiniMax M2.5 Free ending soon',
258+
message:
259+
'The MiniMax M2.5 free promotion ends soon. Please switch to Kilo Auto Free or another free model.',
260+
action: {
261+
actionText: 'Learn more',
262+
actionURL: 'https://kilo.ai/docs/contributing/architecture/auto-model-tiers',
263+
},
264+
suggestModelId: KILO_AUTO_FREE_MODEL.id,
265+
showIn: ['cli', 'extension'],
266+
},
267+
];
268+
} catch (e) {
269+
console.error('[generateMiniMaxNoLongerFreeNotification]', e);
270+
return [];
271+
}
272+
}
273+
240274
async function generateByokProvidersNotification(
241275
user: User,
242276
_ctx: NotificationContext
@@ -248,26 +282,7 @@ async function generateByokProvidersNotification(
248282
)
249283
)(
250284
'byok-provider-usage-users',
251-
`
252-
select u.id, ev.properties.apiProvider
253-
from events ev
254-
join postgres.kilocode_users u on u.google_user_email = ev.distinct_id
255-
where ev.event = 'LLM Completion'
256-
and ev.properties.apiProvider in (
257-
'anthropic'
258-
, 'gemini'
259-
, 'openai-native'
260-
, 'minimax'
261-
, 'mistral'
262-
, 'xai'
263-
, 'zai'
264-
)
265-
and ev.timestamp >= now() - interval 14 day
266-
group by u.id, ev.properties.apiProvider
267-
having count(ev.distinct_id) >= 10
268-
order by max(ev.timestamp) desc
269-
limit 1e5
270-
`
285+
'select id, apiProvider from notification_byok_providers_jan_19 limit 5e5'
271286
);
272287

273288
const provider = byokProviderUsers.find(p => p.userId === user.id)?.provider;
@@ -278,6 +293,7 @@ async function generateByokProvidersNotification(
278293

279294
const names = {
280295
anthropic: 'Claude API Key',
296+
bedrock: 'Amazon Bedrock',
281297
gemini: 'Google AI API Key',
282298
'openai-native': 'OpenAI API Key',
283299
minimax: 'MiniMax Coding Plan',

0 commit comments

Comments
 (0)