Spaces:
Runtime error
Runtime error
No need for double-try
Browse files19 unmodified lines202122232425262728293031323334352324252627282930313233343637383940414235363719 unmodified lines ...conversation.messages ]; let out = ''; try { for await (const chunk of hf.chatCompletionStream( { model: conversation.model.id, messages, temperature: conversation.config.temperature, max_tokens: conversation.config.maxTokens }, { signal: abortController.signal } )) { if (chunk.choices && chunk.choices.length > 0 && chunk.choices[0]?.delta?.content) { out += chunk.choices[0].delta.content; onChunk(out); for await (const chunk of hf.chatCompletionStream( { model: conversation.model.id, messages, temperature: conversation.config.temperature, max_tokens: conversation.config.maxTokens }, { signal: abortController.signal } )) { if (chunk.choices && chunk.choices.length > 0 && chunk.choices[0]?.delta?.content) { out += chunk.choices[0].delta.content; onChunk(out); } } } catch (error) { if (error.name === 'AbortError') { console.log('Stream aborted'); } else { throw error; } }}src/lib/components/InferencePlayground/inferencePlaygroundUtils.ts+12-20