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

Method _generate_null_stream

api/openrouter_handler.py:271–283  ·  view source on GitHub ↗

Generate a minimal streaming response for the NULL model.

(self)

Source from the content-addressed store, hash-verified

269 yield f"data: {json.dumps({'error': f'Unexpected error: {exc}'})}\n\n"
270
271 async def _generate_null_stream(self):
272 """Generate a minimal streaming response for the NULL model."""
273 chunk_id = f"chatcmpl-null-{int(time.time())}"
274 created = int(time.time())
275
276 # Send initial chunk with a single space
277 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"
278
279 # Send final chunk marking completion
280 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"
281
282 # Send [DONE] marker
283 yield "data: [DONE]\n\n"

Callers 1

handle_requestMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected