MCPcopy Create free account
hub / github.com/Roy3838/Observer / _generate_null_stream

Method _generate_null_stream

api/openrouter_handler.py:281–293  ·  view source on GitHub ↗

Generate a minimal streaming response for the NULL model.

(self)

Source from the content-addressed store, hash-verified

279 yield f"data: {json.dumps({'error': f'Unexpected error: {exc}'})}\n\n"
280
281 async def _generate_null_stream(self):
282 """Generate a minimal streaming response for the NULL model."""
283 chunk_id = f"chatcmpl-null-{int(time.time())}"
284 created = int(time.time())
285
286 # Send initial chunk with a single space
287 yield f"data: {json.dumps({'id': chunk_id, 'object': 'chat.completion.chunk', 'created': created, 'model': 'NULL', 'choices': [{'index': 0, 'delta': {'role': 'assistant', 'content': ' '}, 'finish_reason': None}]})}\n\n"
288
289 # Send final chunk marking completion
290 yield f"data: {json.dumps({'id': chunk_id, 'object': 'chat.completion.chunk', 'created': created, 'model': 'NULL', 'choices': [{'index': 0, 'delta': {}, 'finish_reason': 'stop'}]})}\n\n"
291
292 # Send [DONE] marker
293 yield "data: [DONE]\n\n"

Callers 1

handle_requestMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected