Spot the bug in the stream collector

from Local large language models
Ollama 0.33.3 · llama.cpp 0.3.0 · Python 3.14 intermediate 4 min 1 issue to find

Find the completion bug in this generated Ollama stream collector.

Python
import json

def collect(response):
    parts = []
    for line in response:
        event = json.loads(line)
        parts.append(event.get("response", ""))
    return "".join(parts)
Open in playground
Report an error