Spaces:
Runtime error
Runtime error
Implemented chat completion streaming functionality in the Playground component.
Browse files62 unmodified lines6364656667686970717273747576777879808162 unmodified linestry {const hf = new HfInference(hfToken);const stream = await hf.textGenerationStream({model: currentModel,inputs: messages.map(m => m.content).join('\n'),parameters: {max_new_tokens: maxTokens,temperature: temperature,return_full_text: false}});for await (const response of stream) {if (streamingMessage) {streamingMessage.content += response.token.text;messages = [...messages];}}62 unmodified lines636465666768697071727374757662 unmodified linestry {const hf = new HfInference(hfToken);for await (const chunk of hf.chatCompletionStream({model: currentModel,messages: messages.map(({ role, content }) => ({ role, content })),temperature: temperature,max_tokens: maxTokens})) {if (streamingMessage && chunk.choices[0]?.delta?.content) {streamingMessage.content += chunk.choices[0].delta.content;messages = [...messages];}}
src/lib/components/Playground/Playground.svelte+7-12