datarobot_genai.dragent.inline
inline
In-process dragent execution for use as a DRUM alternative in run_agent.py.
Mirrors the entry shape of datarobot_drum's execute_drum_inline so the
host script can route between DRUM and dragent with a single env-var-gated
branch. The function always returns a single aggregated OpenAI
ChatCompletion; the request's stream flag is ignored because the
agentic playground only renders the final assistant message.
execute_dragent_inline_async
async
execute_dragent_inline_async(chat_completion: CompletionCreateParamsBase, custom_model_dir: Path, *, config_file: Path | None = None, default_headers: dict[str, str] | None = None) -> ChatCompletion
Execute a dragent workflow in-process and return the final OpenAI ChatCompletion.
The function delegates aggregation to NAT: runner.result(to_type=ChatResponse)
is the same call the dragent FastAPI route uses for non-streaming
/v1/chat/completions requests. NAT workflows already declare how to
produce a single response — per_user_tool_calling_agent registers
single_output_type=ChatResponse natively, and dragent-native agents
(base, langgraph, crewai, llamaindex) declare
Streaming(convert=aggregate_dragent_event_responses) so NAT collapses
their stream and then chains the registered global converter
DRAgentEventResponse → ChatResponseChunk through to ChatResponse.
The OpenAI ChatCompletion is then a structural re-validation of NAT's
OpenAI-compatible ChatResponse.
Parameters
chat_completion
OpenAI Chat Completions create-params dict (stream is ignored).
custom_model_dir
Directory containing the agent code. workflow.yaml is loaded from
here when config_file is not supplied.
config_file
Optional explicit override of the workflow YAML path.
default_headers
Optional HTTP headers to inject into the workflow's auth/LLM components
(forwarded to load_workflow).
Source code in datarobot_genai/dragent/inline.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
execute_dragent_inline
execute_dragent_inline(chat_completion: CompletionCreateParamsBase, custom_model_dir: Path, *, config_file: Path | None = None, default_headers: dict[str, str] | None = None) -> ChatCompletion
Run :func:execute_dragent_inline_async synchronously for run_agent.py.
Sync entry point used by datarobot-user-models's run_agent.py when the
dragent inline path is enabled. The host process may already have an asyncio
loop running on the current thread (for example when run_agent_procedure
is invoked from an ipykernel driven agentic notebook) without exposing
that loop to this call site; in that case asyncio.run cannot be used here
and the coroutine is executed in a worker thread with its own event loop.