sim_platform.models.providers.local

OpenAI-compatible Chat Completions adapter for model servers on premises.

vLLM, Ollama, llama.cpp and LM Studio serve POST {base_url}/chat/completions. The Agent loop speaks the Responses format, so this adapter translates each request into chat messages and each reply back into Responses output items. It runs in the Agent process, imports only the standard library and never retries: Runtime decides attempts.

The profile’s base_url must name this machine or a private network (checked by ModelProfile), so prompts, market data and replies never leave the premises.

sim_platform.models.providers.local.chat_messages(payload)[source]

Translate a Responses request’s instructions and input items into chat messages.

Consecutive function calls become one assistant message with tool_calls; function outputs become tool messages; reasoning items are dropped because chat servers cannot read them back.

Parameters:

payload (Dict[str, Any])

Return type:

List[Dict[str, Any]]

sim_platform.models.providers.local.chat_tools(payload)[source]

Translate Responses function tools into chat tools entries.

Parameters:

payload (Dict[str, Any])

Return type:

List[Dict[str, Any]]

class sim_platform.models.providers.local.OpenAICompatibleChat[source]

Bases: object

Stateless apart from call identities; one instance per experiment.

Local servers sometimes omit or repeat tool call IDs. The Agent loop needs every call ID to be unique within a run, so a missing or repeated ID is replaced with a generated one; the replacement is what the conversation records and sends back.

body(profile, value)[source]

The Chat Completions request for a Responses payload and profile.

Parameters:
Return type:

Dict[str, Any]

reply(data)[source]

Translate a Chat Completions body into Responses output items and usage.

Parameters:

data (Dict[str, Any])

Return type:

Dict[str, Any]

async request(profile, value, secret)[source]
Parameters:
  • profile (ModelProfile)

  • value (Dict[str, Any])

  • secret (str)

Return type:

Dict[str, Any]

async request_received(profile, value, secret, received)[source]

Send one Chat Completions request to the profile’s local server.

Parameters:
  • profile (ModelProfile)

  • value (Dict[str, Any])

  • secret (str)

  • received (Callable[[], None] | None)

Return type:

Dict[str, Any]

sim_platform.models.providers.local.default_provider(profile)[source]

The built-in adapter for a profile’s provider name.

Parameters:

profile (ModelProfile)

Return type:

Any