|
7 | 7 | import PlusIcon from '~icons/lucide/plus'; |
8 | 8 | import TrashIcon from '~icons/lucide/trash-2'; |
9 | 9 | import CopyIcon from '~icons/lucide/copy'; |
| 10 | + import ExternalLinkIcon from '~icons/lucide/external-link'; |
10 | 11 | import { invalidateAll } from '$app/navigation'; |
11 | 12 |
|
12 | 13 | let { data } = $props(); |
13 | 14 |
|
| 15 | + const API_DOCS_URL = 'https://github.com/nanogpt-community/nanochat/blob/main/api-docs.md'; |
| 16 | +
|
14 | 17 | let newKeyName = $state(''); |
15 | 18 | let newlyCreatedKey = $state<string | null>(null); |
16 | 19 | let creating = $state(false); |
|
81 | 84 | Personal Access Tokens for API authentication. Use these keys with the |
82 | 85 | <code class="bg-muted rounded px-1">Authorization: Bearer <KEY></code> header. |
83 | 86 | </p> |
| 87 | + <a |
| 88 | + href={API_DOCS_URL} |
| 89 | + target="_blank" |
| 90 | + rel="noopener noreferrer" |
| 91 | + class="text-primary hover:text-primary/80 mt-2 inline-flex items-center gap-1 text-sm font-medium underline-offset-4 hover:underline" |
| 92 | + > |
| 93 | + View API Documentation |
| 94 | + <ExternalLinkIcon class="size-4" /> |
| 95 | + </a> |
84 | 96 | </div> |
85 | 97 |
|
86 | 98 | <Card.Root class="mt-8"> |
|
94 | 106 | <Card.Content> |
95 | 107 | <!-- Create new key form --> |
96 | 108 | <div class="mb-6 flex gap-2"> |
97 | | - <Input |
98 | | - bind:value={newKeyName} |
99 | | - placeholder="Key name (e.g., CLI Script)" |
100 | | - class="flex-1" |
101 | | - /> |
| 109 | + <Input bind:value={newKeyName} placeholder="Key name (e.g., CLI Script)" class="flex-1" /> |
102 | 110 | <Button onclick={createKey} disabled={creating || !newKeyName.trim()}> |
103 | 111 | <PlusIcon class="mr-1 size-4" /> |
104 | 112 | Generate Key |
|
117 | 125 | <CopyIcon class="size-4" /> |
118 | 126 | </Button> |
119 | 127 | </div> |
120 | | - <Button |
121 | | - variant="ghost" |
122 | | - size="sm" |
123 | | - class="mt-2" |
124 | | - onclick={() => (newlyCreatedKey = null)} |
125 | | - > |
| 128 | + <Button variant="ghost" size="sm" class="mt-2" onclick={() => (newlyCreatedKey = null)}> |
126 | 129 | Dismiss |
127 | 130 | </Button> |
128 | 131 | </div> |
|
157 | 160 | <Card.Title>Usage Example</Card.Title> |
158 | 161 | </Card.Header> |
159 | 162 | <Card.Content> |
160 | | - <pre class="bg-muted overflow-x-auto rounded-lg p-4 text-sm"><code>curl -X POST https://your-domain.com/api/generate-message \ |
| 163 | + <pre class="bg-muted overflow-x-auto rounded-lg p-4 text-sm"><code |
| 164 | + >curl -X POST https://your-domain.com/api/generate-message \ |
161 | 165 | -H "Authorization: Bearer nc_your_api_key_here" \ |
162 | 166 | -H "Content-Type: application/json" \ |
163 | 167 | -d '{'{'} |
164 | 168 | "message": "Hello!", |
165 | 169 | "model_id": "gpt-4o" |
166 | | - {'}'}'</code></pre> |
| 170 | + {'}'}'</code |
| 171 | + ></pre> |
167 | 172 | </Card.Content> |
168 | 173 | </Card.Root> |
0 commit comments