Commit 5c6be70
committed
fix: prevent streaming response duplication with custom OpenAI endpoints
When streaming, _process_chunk emits both an add_message event (to
initialise the chat bubble) and a token event for each chunk. Consumers
that process both event types — such as the OpenAI Responses API
endpoint — end up yielding the same content twice: once from the
add_message text and once from the token data.
Root-cause fix: set the first-chunk add_message text to an empty string
so streamed content is delivered exclusively through token events.
Defensive fix: track whether token events have been received in the
OpenAI Responses streaming handler and skip add_message text content
when tokens are active, preventing duplication even if the root cause
fix is bypassed.
Fixes #107191 parent 6ed0091 commit 5c6be70
3 files changed
Lines changed: 30 additions & 9 deletions
File tree
- src
- backend/base/langflow/api/v1
- lfx/src/lfx
- base/models
- custom/custom_component
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| 135 | + | |
135 | 136 | | |
136 | 137 | | |
137 | 138 | | |
| |||
161 | 162 | | |
162 | 163 | | |
163 | 164 | | |
| 165 | + | |
164 | 166 | | |
165 | 167 | | |
166 | 168 | | |
| |||
195 | 197 | | |
196 | 198 | | |
197 | 199 | | |
198 | | - | |
199 | | - | |
200 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
201 | 207 | | |
202 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
203 | 212 | | |
204 | 213 | | |
205 | 214 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
274 | 283 | | |
275 | | - | |
276 | | - | |
| 284 | + | |
| 285 | + | |
277 | 286 | | |
278 | 287 | | |
279 | 288 | | |
280 | 289 | | |
281 | 290 | | |
282 | 291 | | |
283 | | - | |
284 | 292 | | |
285 | 293 | | |
286 | 294 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1824 | 1824 | | |
1825 | 1825 | | |
1826 | 1826 | | |
1827 | | - | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
1828 | 1832 | | |
1829 | | - | |
| 1833 | + | |
1830 | 1834 | | |
1831 | 1835 | | |
1832 | 1836 | | |
| |||
0 commit comments