MCPcopy Create free account
hub / github.com/agent0ai/agent-zero / _stream

Method _stream

models.py:471–497  ·  view source on GitHub ↗
(
        self,
        messages: List[BaseMessage],
        stop: Optional[List[str]] = None,
        run_manager: Optional[CallbackManagerForLLMRun] = None,
        **kwargs: Any,
    )

Source from the content-addressed store, hash-verified

469 return output["response_delta"]
470
471 def _stream(
472 self,
473 messages: List[BaseMessage],
474 stop: Optional[List[str]] = None,
475 run_manager: Optional[CallbackManagerForLLMRun] = None,
476 **kwargs: Any,
477 ) -> Iterator[ChatGenerationChunk]:
478 configure_litellm()
479 msgs = self._convert_messages(messages)
480
481 # Apply rate limiting if configured
482 apply_rate_limiter_sync(self.a0_model_conf, str(msgs))
483
484 result = ChatGenerationResult()
485 call_kwargs = _merge_litellm_call_kwargs(self.kwargs, kwargs)
486 transport = LiteLLMTransport(
487 model=self.model_name,
488 messages=msgs,
489 kwargs=call_kwargs,
490 stop=stop,
491 )
492 for parsed in transport.stream():
493 output = result.add_chunk(parsed)
494 if output["response_delta"]:
495 yield ChatGenerationChunk(
496 message=AIMessageChunk(content=output["response_delta"])
497 )
498
499 async def _astream(
500 self,

Callers

nothing calls this directly

Calls 8

_convert_messagesMethod · 0.95
streamMethod · 0.95
add_chunkMethod · 0.95
LiteLLMTransportClass · 0.90
configure_litellmFunction · 0.85
apply_rate_limiter_syncFunction · 0.85

Tested by

no test coverage detected