INNER CODE UNIT · Python
elapsed
hyperonym/basaran · basaran/__main__.py:197
elapsed = (now - times[index]) // 1_000_000
if elapsed > COMPLETION_MAX_INTERVAL:
data = template.copy()
data["choices"] = [reduce_choice(buffers[index])]
yield serialize(data)
buffers[index].clear()
times[index] = now
# Yield remaining data in the buffers.
for _, buffer in buffers.items():
if buffer:
data = template.copy()
data["choices"] = [reduce_choice(buffer)]
yield serialize(data)
yield "data: [DONE]\n\n"
return Response(stream(), mimetype="text/event-stream")