Improved handling of streaming response from OpenAI API in Playground component.
Browse files
src/lib/components/Playground/Playground.svelte
CHANGED
@@ -75,9 +75,11 @@
|
|
75 |
max_tokens: 500,
|
76 |
seed: 0,
|
77 |
})) {
|
78 |
-
if (
|
79 |
-
streamingMessage
|
80 |
-
|
|
|
|
|
81 |
}
|
82 |
}
|
83 |
} catch (error) {
|
|
|
75 |
max_tokens: 500,
|
76 |
seed: 0,
|
77 |
})) {
|
78 |
+
if (chunk.choices && chunk.choices.length > 0) {
|
79 |
+
if (streamingMessage && chunk.choices[0]?.delta?.content) {
|
80 |
+
streamingMessage.content += chunk.choices[0].delta.content;
|
81 |
+
messages = [...messages];
|
82 |
+
}
|
83 |
}
|
84 |
}
|
85 |
} catch (error) {
|