perf: memo GridCard, fuse save fns, fix slash tab active color
This commit is contained in:
39
memento-note/app/api/user/ai-status/route.ts
Normal file
39
memento-note/app/api/user/ai-status/route.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { auth } from '@/auth';
|
||||
import { getSystemConfig } from '@/lib/config';
|
||||
import { getAnyActiveByokForUser } from '@/lib/byok';
|
||||
import { resolveAiRoute } from '@/lib/ai/router';
|
||||
|
||||
/**
|
||||
* GET /api/user/ai-status
|
||||
* Returns the effective AI provider and model for the current user.
|
||||
* Used by the UI to show which model is active (BYOK vs admin).
|
||||
*/
|
||||
export async function GET() {
|
||||
const session = await auth();
|
||||
if (!session?.user?.id) {
|
||||
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
||||
}
|
||||
|
||||
const config = await getSystemConfig();
|
||||
const adminRoute = resolveAiRoute('chat', config);
|
||||
|
||||
const byok = await getAnyActiveByokForUser(session.user.id, adminRoute.providerType);
|
||||
|
||||
if (byok) {
|
||||
const model = (byok.model && byok.model.trim()) ? byok.model : adminRoute.modelName;
|
||||
return NextResponse.json({
|
||||
usedByok: true,
|
||||
provider: byok.provider,
|
||||
model,
|
||||
source: 'byok',
|
||||
});
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
usedByok: false,
|
||||
provider: adminRoute.providerType,
|
||||
model: adminRoute.modelName,
|
||||
source: 'admin',
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user