Spaces:
Sleeping
Sleeping
Download client/src/components/api-usage.tsx from rohanchand21/freellmapi: direct link, hf CLI and curl.
- Browser
- Download file 1.16 kB
-
https://huggingface.co/spaces/rohanchand21/freellmapi/resolve/main/client/src/components/api-usage.tsx
- Command line
-
hf download hf://spaces/rohanchand21/freellmapi/client/src/components/api-usage.tsx
-
curl -L -o api-usage.tsx https://huggingface.co/spaces/rohanchand21/freellmapi/resolve/main/client/src/components/api-usage.tsx
1.16 kB
| import { CopyButton } from '@/components/copy-button' | |
| import { useI18n } from '@/i18n' | |
| // The /v1 base URL for ready-to-run snippets, derived the same way as the chat | |
| // model page + Keys page: the dev server port in DEV, the page origin in a | |
| // packaged/hosted build. | |
| export function apiBaseUrl(): string { | |
| return import.meta.env.DEV | |
| ? `http://${window.location.hostname}:${__SERVER_PORT__}/v1` | |
| : `${window.location.origin}/v1` | |
| } | |
| // A copy-able "ways to use the API" code block, matching the chat detail page's | |
| // snippet card so every modality's detail page looks the same. | |
| export function ApiUsageBlock({ snippet }: { snippet: string }) { | |
| const { t } = useI18n() | |
| return ( | |
| <div className="overflow-hidden rounded-2xl border bg-card"> | |
| <div className="flex items-center gap-2 border-b px-3 py-2"> | |
| <CopyButton text={snippet} className="size-7 shrink-0" label={t('common.copy')} /> | |
| <span className="text-xs font-medium">{t('models.codeSnippetHeading')}</span> | |
| </div> | |
| <pre className="overflow-x-auto px-4 py-3 text-[11px] leading-relaxed"><code className="font-mono">{snippet}</code></pre> | |
| </div> | |
| ) | |
| } | |