Download packages/console/app/src/lib/request-country.ts from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 878 Bytes
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/console/app/src/lib/request-country.ts
- Command line
-
hf download hf://SaylorTwift/opencode/packages/console/app/src/lib/request-country.ts
-
curl -L -o request-country.ts https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/console/app/src/lib/request-country.ts
878 Bytes
| const MUSE_SPARK_BLOCKED_COUNTRIES = new Set([ | |
| "AF", | |
| "BY", | |
| "CN", | |
| "CU", | |
| "EH", | |
| "ER", | |
| "ET", | |
| "HK", | |
| "HT", | |
| "IQ", | |
| "IR", | |
| "KH", | |
| "KP", | |
| "LY", | |
| "MM", | |
| "MO", | |
| "NI", | |
| "PK", | |
| "RU", | |
| "SO", | |
| "SY", | |
| "VE", | |
| ]) | |
| export function countryFromRequest(request: Request | undefined) { | |
| if (!request) return undefined | |
| const cloudflareRequest = request as Request & { cf?: { country?: string } } | |
| return cloudflareRequest.cf?.country ?? request.headers.get("cf-ipcountry") ?? undefined | |
| } | |
| export function isModelCountryRestricted(model: string, country: string | undefined) { | |
| return ( | |
| [ | |
| "muse-spark-1.3-contributor", | |
| "muse-spark-1.3-contributor-free", | |
| "muse-spark-1.2-contributor", | |
| "muse-spark-1.2-contributor-free", | |
| ].includes(model) && | |
| country !== undefined && | |
| MUSE_SPARK_BLOCKED_COUNTRIES.has(country.toUpperCase()) | |
| ) | |
| } | |