Spaces:
Runtime error
Runtime error
update
Browse filesFiles changed (2)
174 unmodified lines175176177178179180181174 unmodified lines<div class="!p-0 text-sm font-semibold">Add message</div></button>{:else}<PlaygroundCode model={$currentModel} />{/if}</div>174 unmodified lines175176177178179180181182183184185186174 unmodified lines<div class="!p-0 text-sm font-semibold">Add message</div></button>{:else}<PlaygroundCodemodel={$currentModel}streaming={$streaming}temperature={$temperature}maxTokens={$maxTokens}/>{/if}</div>
123456789101112131415161718192021222324252627282929 unmodified lines5960616263646566676869707172<script>export let model = '';const npmSnippet = `import { HfInference } from '@huggingface/inference'const hf = new HfInference('your access token')`;$: nonStreaming = `await hf.chatCompletion({model: "${model}",messages: [{ role: "user", content: "Complete the this sentence with words one plus one is equal " }],max_tokens: 500,temperature: 0.1,seed: 0,});`;$: streaming = `let out = "";for await (const chunk of hf.chatCompletionStream({model: "mistrali/Mistral-7B-Instruct-v0.2",messages: [{ role: "user", content: "Complete the equation 1+1= ,just the answer" },],max_tokens: 500,temperature: 0.1,seed: 0,})) {if (chunk.choices && chunk.choices.length > 0) {29 unmodified lines</div><preclass="overflow-x-auto border-y border-y-gray-100 bg-gray-50 px-4 py-6 text-sm">{npmSnippet}</pre><div class="px-4 pb-4 pt-6"><h2 class="font-semibold">Non-Streaming API</h2></div><preclass="overflow-x-auto border-y border-y-gray-100 bg-gray-50 px-4 py-6 text-sm">{nonStreaming}</pre><div class="px-4 pb-4 pt-6"><h2 class="font-semibold">Streaming API</h2></div><preclass="overflow-x-auto border-y border-gray-100 bg-gray-50 px-4 py-6 text-sm">{streaming}</pre></div>12345678910111213141516171819202122232425262728293031323329 unmodified lines63646566676869707172737475<script lang="ts">export let model: string;export let streaming: Boolean;export let temperature: number;export let maxTokens: number;export let messages: Array;const npmSnippet = `import { HfInference } from '@huggingface/inference'const hf = new HfInference('your access token')`;$: nonStreamingSnippet = `await hf.chatCompletion({model: "${model}",messages: [{ role: "user", content: "Complete the this sentence with words one plus one is equal " }],max_tokens: ${maxTokens},temperature: ${temperature},seed: 0,});`;$: streamingSnippet = `let out = "";for await (const chunk of hf.chatCompletionStream({model: "${model}",messages: [{ role: "user", content: "Complete the equation 1+1= ,just the answer" },],max_tokens: ${maxTokens},temperature: ${temperature},seed: 0,})) {if (chunk.choices && chunk.choices.length > 0) {29 unmodified lines</div><preclass="overflow-x-auto border-y border-y-gray-100 bg-gray-50 px-4 py-6 text-sm">{npmSnippet}</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 border-y border-gray-100 bg-gray-50 px-4 py-6 text-sm">{streaming? streamingSnippet: nonStreamingSnippet}</pre></div>
src/lib/components/Playground/Playground.svelte+6-1
src/lib/components/Playground/PlaygroundCode.svelte+20-17