Class: LittleGhost::Providers::LMStudio

Inherits:
OpenAICompatible show all
Defined in:
lib/little_ghost/providers/lm_studio.rb,
lib/little_ghost/providers/lm_studio/catalog_source.rb

Overview

LMStudio connects LittleGhost to an LM Studio server through its OpenAI-compatible API. Generation, embeddings, retries, cancellation, and deadlines use the shared compatible transport.

provider = LittleGhost::Providers::LMStudio.new(
model: "google/gemma-3-4b",
allow_insecure_http: true
)

The default endpoint is LM Studio's local server. Pass api_key when the server requires authentication. Plain HTTP remains an explicit opt-in.

Defined Under Namespace

Classes: CatalogSource

Constant Summary collapse

DEFAULT_BASE_URL =

Default endpoint for LM Studio's OpenAI-compatible API.

"http://localhost:1234/v1/"
DEFAULT_API_KEY =

:nodoc:

"lm-studio"

Constants inherited from OpenAICompatible

OpenAICompatible::CONTEXT_OVERFLOW_MARKERS, OpenAICompatible::DEFAULT_MAX_EMBEDDING_RESPONSE_BYTES, OpenAICompatible::INITIAL_RETRY_DELAY, OpenAICompatible::MAX_RETRY_DELAY, OpenAICompatible::TRANSIENT_STREAM_ERROR_TYPES

Instance Attribute Summary

Attributes inherited from OpenAICompatible

#api, #model

Instance Method Summary collapse

Methods inherited from OpenAICompatible

#embed, request_options, #stream

Methods inherited from Base

#embed, #prepare_request, request_options, #stream

Constructor Details

#initialize(api_key: DEFAULT_API_KEY, base_url: DEFAULT_BASE_URL, **arguments) ⇒ LMStudio

Configures an LM Studio client. All OpenAICompatible options apply. The placeholder API key is suitable only when LM Studio authentication is disabled.



27
28
29
# File 'lib/little_ghost/providers/lm_studio.rb', line 27

def initialize(api_key: DEFAULT_API_KEY, base_url: DEFAULT_BASE_URL, **arguments)
  super
end

Instance Method Details

#capabilities(metadata: {}) ⇒ Object

Uses refreshed LM Studio model metadata when available. Before a catalog refresh, the compatible endpoint retains its permissive capability contract.



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/little_ghost/providers/lm_studio.rb', line 34

def capabilities(metadata: {})
  parameters = [:supported_parameters] || ["supported_parameters"]
  return super unless parameters.is_a?(Array)

  values = parameters.map(&:to_s)
  ModelCapabilities.new(
    native_structured_output: values.include?("structured_outputs"),
    tools: values.include?("tools"),
    tool_choice: values.include?("tool_choice"),
    supported_parameters: values
  )
end