Spaces:
Sleeping
Sleeping
Download backend/src/lib/modelAccess.ts from bardd/mike-backend: direct link, hf CLI and curl.
- Browser
- Download file 956 Bytes
-
https://huggingface.co/spaces/bardd/mike-backend/resolve/main/backend/src/lib/modelAccess.ts
- Command line
-
hf download hf://spaces/bardd/mike-backend/backend/src/lib/modelAccess.ts
-
curl -L -o modelAccess.ts https://huggingface.co/spaces/bardd/mike-backend/resolve/main/backend/src/lib/modelAccess.ts
956 Bytes
| import { getSelectableModelIds } from "./inference/config"; | |
| import { runSql } from "./supabase"; | |
| export const PILOT_FAST_MODEL_ID = "gemini-3.1-flash-lite-high"; | |
| export const PILOT_PRO_MODEL_ID = "gemini-3.1-pro-high"; | |
| const PILOT_MODEL_IDS = new Set([PILOT_FAST_MODEL_ID, PILOT_PRO_MODEL_ID]); | |
| export async function isOperatorUser(userId: string): Promise<boolean> { | |
| const result = await runSql( | |
| "select is_operator from auth.users where id = $1 limit 1", | |
| [userId], | |
| ); | |
| return result.rows[0]?.is_operator === true; | |
| } | |
| export function normalizeModelForAccess( | |
| modelId: string | null | undefined, | |
| isOperator: boolean, | |
| ): string { | |
| if (isOperator) { | |
| const selectable = new Set(getSelectableModelIds()); | |
| if (modelId && selectable.has(modelId)) return modelId; | |
| return PILOT_FAST_MODEL_ID; | |
| } | |
| if (modelId && PILOT_MODEL_IDS.has(modelId)) return modelId; | |
| return PILOT_FAST_MODEL_ID; | |
| } | |