Skip to content

Streaming responses are "duplicated" whenever a code block is used #106

@squid4539

Description

@squid4539

Hello, I am persistently facing this issue with duplicate streaming chunks whenever a response includes code blocks. I tried to reproduce it with other prompts but it only occurred when a response contained code blocks, and it duplicated the chunk right before the code block is written.

I am not sure if this is a problem with upstream web api or this library, but I thought of asking here first.

Version: latest ghcr image sha256:710b929a648fa9c32312a09b830f683f5eda13b3b263f860918e88b5cfe4a36a
Requests made with OpenWebUI v0.7.2

Using gemini-3.0-flash from this api

Quicksort is one of the most efficient sorting algorithms, using a **divide-and-conquer** strategy. It picks an element as a "pivot" and partitions the array around it, ensuring elements smaller than the pivot go to the left and larger ones go to the right.

### The Algorithm Logic

1.  **Pick a Pivot:** Usually the last element, the first element, or a random one.
2.  **Partition:** Reorder the array so that all elements with values less than the pivot come before it, and all elements with values greater than the pivot come after it.
3.  **Recursion:** Recursively apply the above steps to the sub-arrays of elements with smaller and larger values.

[Image of quicksort algorithm steps showing partitioning and recursion]

---

### CQuicksort is one of the most efficient sorting algorithms, using a **divide-and-conquer** strategy. It picks an element as a "pivot" and partitions the array around it, ensuring elements smaller than the pivot go to the left and larger ones go to the right.

### The Algorithm Logic

1.  **Pick a Pivot:** Usually the last element, the first element, or a random one.
2.  **Partition:** Reorder the array so that all elements with values less than the pivot come before it, and all elements with values greater than the pivot come after it.
3.  **Recursion:** Recursively apply the above steps to the sub-arrays of elements with smaller and larger values.

[Image of quicksort algorithm steps showing partitioning and recursion]

-----

### C++ Implementation

Here is a clean, standard implementation using the **Lomuto partition scheme** (picking the last element as the pivot):

```cpp
#
```Quicksort is one of the most efficient sorting algorithms, using a **divide-and-conquer** strategy. It picks an element as a "pivot" and partitions the array around it, ensuring elements smaller than the pivot go to the left and larger ones go to the right.

### The Algorithm Logic

Using gemini cli, model also 3 flash

Quicksort is a highly efficient, **divide-and-conquer** sorting algorithm. It works by selecting a 'pivot' element from the array and partitioning the other elements into two sub-arrays, according to whether they are less than or greater than the pivot.

Here is the implementation in C++ using the last element as the pivot.

### C++ Implementation

```cpp
#include <iostream>
#include <vector>

using namespace std;

// Helper function to swap two elements
void swap(int& a, int& b) {
    int temp = a;
    a = b;
    b = temp;
}

You can see how it's repeated 3 times in the first response, but the normal model does not have this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions