File size: 1,142 Bytes
c429240
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""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,
    )