datarobot_genai.core.chat.completions
completions
is_streaming
Return True when the request asks for streaming, False otherwise.
Accepts both pydantic types and plain dictionaries.
Source code in datarobot_genai/core/chat/completions.py
backfill_model
Replace NAT's "unknown-model" placeholder (or None) with fallback.
NAT defaults ChatResponse.model / ChatResponseChunk.model to the literal
"unknown-model" whenever the workflow output didn't carry one. Callers pass the
agent's configured model (:func:default_response_model) as fallback so the
response reports the model the agent actually ran. A real model the workflow
produced — or a deliberately-set one such as moderation's MODERATION_MODEL_NAME
— is preserved.
Source code in datarobot_genai/core/chat/completions.py
convert_chat_completion_params_to_run_agent_input
convert_chat_completion_params_to_run_agent_input(chat_completion_params: CompletionCreateParams | Mapping[str, Any]) -> RunAgentInput
Convert a chat completion parameters to a run agent input.
Source code in datarobot_genai/core/chat/completions.py
agent_chat_completion_wrapper
async
agent_chat_completion_wrapper(agent: BaseAgent, chat_completion_params: CompletionCreateParams | Mapping[str, Any], mcp_tools_factory: Callable[[], Any]) -> InvokeReturn | tuple[str, MultiTurnSample | None, UsageMetrics]
Wrap the agent's invoke method in a chat completion wrapper.
MCP tools from mcp_tools_factory are combined with any tools already on
agent (MCP first, then existing agent.tools).
Returns
InvokeReturn When streaming is requested - the raw async event generator tuple[str, MultiTurnSample | None, UsageMetrics] When non-streaming - the reassembled final text, pipeline interactions, and accumulated usage metrics.