Spaces:
Runtime error
Runtime error
Use highlight.js (#15)
Browse filesFiles changed (5)
16 unmodified lines171819202016 unmodified lines - name: Push to hub env: HF_DEPLOYMENT_TOKEN: ${{ secrets.HF_DEPLOYMENT_TOKEN }} run: git push https://mishig:$HF_DEPLOYMENT_TOKEN@huggingface.co/spaces/huggingface-projects/inference-playground main run: git push https://mishig:$HF_DEPLOYMENT_TOKEN@huggingface.co/spaces/huggingface-projects/inference-playground main16 unmodified lines1718192021222316 unmodified lines "@sveltejs/kit": "^2.0.0", "@sveltejs/vite-plugin-svelte": "^3.0.0", "autoprefixer": "^10.4.19", "highlight.js": "^11.10.0", "postcss": "^8.4.38", "prettier": "^3.1.1", "prettier-plugin-svelte": "^3.1.2",33 unmodified lines3435363738394041421027 unmodified lines1070107110721073107410751076107710781079108033 unmodified lines autoprefixer: specifier: ^10.4.19 version: 10.4.19(postcss@8.4.38) highlight.js: specifier: ^11.10.0 version: 11.10.0 postcss: specifier: ^8.4.38 version: 8.4.381027 unmodified lines dependencies: function-bind: 1.1.2
/highlight.js@11.10.0: resolution: {integrity: sha512-SYVnVFswQER+zu1laSya563s+F8VDGt7o35d4utbamowvUNLLMovFqwCLSocpZTz3MgaSRA1IbqRWZv97dtErQ==} engines: {node: '>=12.0.0'} dev: true
/import-meta-resolve@4.1.0: resolution: {integrity: sha512-I6fiaX09Xivtk+THaMfAwnA3MVA5Big1WHF1Dfx9hFuvNIWpXnorlkzhcQf6ehrqQiiZECRt1poOAkPmer3ruw==} dev: true1234@import 'highlight.js/styles/atom-one-light';@tailwind base;@tailwind components;@tailwind utilities;1234567891 unmodified line1112131415161718192021222324252651 unmodified lines7879806781828384858687888990747576919293949596<script lang="ts"> import { type ChatCompletionInputMessage } from '@huggingface/tasks'; import hljs from 'highlight.js/lib/core'; import javascript from 'highlight.js/lib/languages/javascript'; import python from 'highlight.js/lib/languages/python'; import bash from 'highlight.js/lib/languages/bash';
export let model: string; export let streaming: Boolean;1 unmodified line export let maxTokens: number; export let messages: ChatCompletionInputMessage[];
type Langauge = 'javascript' | 'python' | 'bash';
hljs.registerLanguage('javascript', javascript); hljs.registerLanguage('python', python); hljs.registerLanguage('bash', bash);
function highlight(code: string, language: Langauge) { return hljs.highlight(code, { language }).value; }
const npmSnippet = `import { HfInference } from '@huggingface/inference'
const hf = new HfInference('your access token')`;51 unmodified lines <h2 class="font-semibold">Install and instantiate</h2> </div> <pre class="overflow-x-auto rounded-lg border border-gray-200/80 bg-white px-4 py-6 text-sm shadow-sm dark:border-gray-800 dark:bg-gray-800/50">{npmSnippet}</pre> class="overflow-x-auto rounded-lg border border-gray-200/80 bg-white px-4 py-6 text-sm shadow-sm dark:border-gray-800 dark:bg-gray-800/50">{@html highlight( npmSnippet, 'javascript' )}</pre>
<div class="px-4 pb-4 pt-6"> <h2 class="font-semibold">{streaming ? 'Streaming API' : 'Non-Streaming API'}</h2> </div>
<pre class="overflow-x-auto rounded-lg border border-gray-200/80 bg-white px-4 py-6 text-sm shadow-sm dark:border-gray-800 dark:bg-gray-800/50">{streaming ? streamingSnippet : nonStreamingSnippet} class="overflow-x-auto rounded-lg border border-gray-200/80 bg-white px-4 py-6 text-sm shadow-sm dark:border-gray-800 dark:bg-gray-800/50">{@html highlight( streaming ? streamingSnippet : nonStreamingSnippet, 'javascript' )} </pre></div>.github/workflows/deploy-to-spaces.yml+1-1
package.json+1
pnpm-lock.yaml+8
src/app.css+1
src/lib/components/CodeSnippets.svelte+22-4