Pass caller LLM runtime options
All checks were successful
build / build (push) Successful in 27s

This commit is contained in:
robert
2026-05-21 13:58:18 -03:00
parent 7317b41755
commit c009b2f081
3 changed files with 20 additions and 7 deletions

View File

@@ -30,6 +30,9 @@ class BuilderContext:
llm_base_url: str | None = None
llm_api_key: str | None = None
llm_model: str | None = None
llm_temperature_mode: str | None = None
llm_temperature: float | None = None
llm_extra_body: dict[str, Any] | None = None
SYSTEM_PROMPT = """\
@@ -219,12 +222,19 @@ def build_agent_builder(ctx: BuilderContext) -> Any:
tools = build_tools(ToolContext(
bucket=ctx.bucket, settings=settings, cp_jwt=ctx.cp_jwt,
))
model = ChatOpenAI(
model=ctx.llm_model or settings.litellm_model,
base_url=ctx.llm_base_url or (settings.litellm_url + "/v1"),
api_key=ctx.llm_api_key or settings.litellm_key,
temperature=0.0,
)
model_kwargs: dict[str, Any] = {
"model": ctx.llm_model or settings.litellm_model,
"base_url": ctx.llm_base_url or (settings.litellm_url + "/v1"),
"api_key": ctx.llm_api_key or settings.litellm_key,
"stream_usage": True,
}
if ctx.llm_temperature_mode != "omit":
model_kwargs["temperature"] = (
ctx.llm_temperature if ctx.llm_temperature is not None else 0.0
)
if ctx.llm_extra_body:
model_kwargs["extra_body"] = dict(ctx.llm_extra_body)
model = ChatOpenAI(**model_kwargs)
kwargs: dict[str, Any] = {
"model": model,
"tools": tools,