"""Build the SDK LLM object that points at a Cortex.0 inference server.""" from __future__ import annotations from openhands.sdk.llm import LLM from cortex0.settings import Cortex0Settings def build_llm(settings: Cortex0Settings) -> LLM: """Create an LLM bound to the Cortex.0 OpenAI-compatible endpoint. Cortex.0 is a GGUF MoE model served by llama.cpp or SGLang. Both expose the OpenAI chat-completions protocol, so the SDK talks to it through ``base_url`` with no adapter in between: the model sits directly in the agent loop. """ return LLM( model=settings.model, base_url=settings.base_url, api_key=settings.api_key, max_output_tokens=settings.max_output_tokens, temperature=settings.temperature, top_p=settings.top_p, top_k=settings.top_k, num_retries=settings.num_retries, timeout=settings.timeout, native_tool_calling=settings.native_tool_calling, # Cortex.0 is served by local runtimes that reject unknown provider # parameters; dropping them keeps every request acceptable. drop_params=True, )