mishig HF staff commited on
Commit
5f94ff7
1 Parent(s): 3b5cc6c

No need for double-try

Browse files
src/lib/components/InferencePlayground/inferencePlaygroundUtils.ts CHANGED
@@ -20,26 +20,18 @@ export async function handleStreamingResponse(
20
  ...conversation.messages
21
  ];
22
  let out = '';
23
- try {
24
- for await (const chunk of hf.chatCompletionStream(
25
- {
26
- model: conversation.model.id,
27
- messages,
28
- temperature: conversation.config.temperature,
29
- max_tokens: conversation.config.maxTokens
30
- },
31
- { signal: abortController.signal }
32
- )) {
33
- if (chunk.choices && chunk.choices.length > 0 && chunk.choices[0]?.delta?.content) {
34
- out += chunk.choices[0].delta.content;
35
- onChunk(out);
36
- }
37
- }
38
- } catch (error) {
39
- if (error.name === 'AbortError') {
40
- console.log('Stream aborted');
41
- } else {
42
- throw error;
43
  }
44
  }
45
  }
 
20
  ...conversation.messages
21
  ];
22
  let out = '';
23
+ for await (const chunk of hf.chatCompletionStream(
24
+ {
25
+ model: conversation.model.id,
26
+ messages,
27
+ temperature: conversation.config.temperature,
28
+ max_tokens: conversation.config.maxTokens
29
+ },
30
+ { signal: abortController.signal }
31
+ )) {
32
+ if (chunk.choices && chunk.choices.length > 0 && chunk.choices[0]?.delta?.content) {
33
+ out += chunk.choices[0].delta.content;
34
+ onChunk(out);
 
 
 
 
 
 
 
 
35
  }
36
  }
37
  }