|
1 | 1 | <script lang="ts"> |
2 | | - import { type ConversationClass } from "$lib/state/conversations.svelte"; |
3 | | - import { token } from "$lib/state/token.svelte.js"; |
4 | 2 | import { billing } from "$lib/state/billing.svelte"; |
| 3 | + import { type ConversationClass } from "$lib/state/conversations.svelte"; |
5 | 4 | import { isCustomModel } from "$lib/types.js"; |
6 | 5 | import { |
7 | 6 | getInferenceSnippet, |
|
17 | 16 | import IconExternal from "~icons/carbon/arrow-up-right"; |
18 | 17 | import IconCopy from "~icons/carbon/copy"; |
19 | 18 | import LocalToasts from "../local-toasts.svelte"; |
| 19 | + import IconLaunch from "~icons/carbon/launch"; |
20 | 20 |
|
21 | 21 | hljs.registerLanguage("javascript", javascript); |
22 | 22 | hljs.registerLanguage("python", python); |
|
37 | 37 | type Language = keyof typeof labelsByLanguage; |
38 | 38 |
|
39 | 39 | let lang: Language = $state("javascript"); |
40 | | - let showToken = $state(false); |
41 | | -
|
42 | 40 | type GetSnippetArgs = { |
43 | 41 | tokenStr?: string; |
44 | 42 | conversation: ConversationClass; |
|
98 | 96 | return hljs.highlight(code, { language: language === "sh" ? "http" : language }).value; |
99 | 97 | } |
100 | 98 |
|
101 | | - const tokenStr = $derived.by(() => { |
102 | | - if (isCustomModel(conversation.model)) { |
103 | | - const t = conversation.model.accessToken; |
104 | | -
|
105 | | - return t && showToken ? t : undefined; |
106 | | - } |
107 | | -
|
108 | | - return token.value && showToken ? token.value : undefined; |
109 | | - }); |
110 | | -
|
111 | 99 | const snippetsByLang = $derived({ |
112 | | - javascript: getSnippet({ lang: "js", tokenStr, conversation }), |
113 | | - python: getSnippet({ lang: "python", tokenStr, conversation }), |
114 | | - http: getSnippet({ lang: "sh", tokenStr, conversation }), |
| 100 | + javascript: getSnippet({ lang: "js", conversation }), |
| 101 | + python: getSnippet({ lang: "python", conversation }), |
| 102 | + http: getSnippet({ lang: "sh", conversation }), |
115 | 103 | } as Record<Language, GetInferenceSnippetReturn>); |
116 | 104 |
|
117 | 105 | // Auto-switch to available language if current one has no snippets |
|
245 | 233 | <h2 class="font-semibold">Non-Streaming API</h2> |
246 | 234 | {/if} |
247 | 235 | <div class="flex items-center gap-x-4"> |
248 | | - <label class="flex items-center gap-x-1.5 text-sm select-none"> |
249 | | - <input type="checkbox" bind:checked={showToken} /> |
250 | | - <p class="leading-none">With token</p> |
251 | | - </label> |
| 236 | + <a |
| 237 | + href="https://huggingface.co/settings/tokens/new?ownUserPermissions=inference.serverless.write&tokenType=fineGrained" |
| 238 | + target="_blank" |
| 239 | + class="flex items-center gap-x-1 text-xs text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300" |
| 240 | + > |
| 241 | + Create token |
| 242 | + <IconLaunch class="translate-y-[0.5px] text-xs" /> |
| 243 | + </a> |
252 | 244 | <LocalToasts> |
253 | 245 | {#snippet children({ addToast, trigger })} |
254 | 246 | <button |
|
0 commit comments