Module: OllamaChat::StateSelectors

Included in:
Chat
Defined in:
lib/ollama_chat/state_selectors.rb

Overview

A module that provides state selection functionality for OllamaChat.

The StateSelectors module encapsulates the StateSelector class, which manages configurable states with selection and display capabilities. It is used to handle various settings in the chat application such as document policies and think modes, allowing users to dynamically configure different aspects of the chat session behavior.

Defined Under Namespace

Modules: Common Classes: DatabaseStateSelector, StateSelector

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#document_policyOllamaChat::StateSelector (readonly)

The document_policy reader returns the document policy selector for the chat session.

Returns:

  • (OllamaChat::StateSelector)

    the document policy selector object that manages the policy for handling document references in user text



226
227
228
# File 'lib/ollama_chat/state_selectors.rb', line 226

def document_policy
  @document_policy
end

#think_modeOllamaChat::StateSelector (readonly)

The think_mode reader returns the think mode selector for the chat session.

Returns:

  • (OllamaChat::StateSelector)

    the think mode selector object that manages the thinking mode setting for the Ollama model interactions



232
233
234
# File 'lib/ollama_chat/state_selectors.rb', line 232

def think_mode
  @think_mode
end

#voicesOllamaChat::StateSelector (readonly)

The voices reader returns the voice selector for the chat session.

Returns:

  • (OllamaChat::StateSelector)

    the voice selector object that manages the currently selected voice for the chat session



238
239
240
# File 'lib/ollama_chat/state_selectors.rb', line 238

def voices
  @voices
end

Instance Method Details

#setup_state_selectors(config) ⇒ Object

Sets up state selectors for document policy and think mode based on the provided configuration.

Parameters:

  • config (ComplexConfig::Settings)

    the configuration object containing settings for document policy and think mode



245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# File 'lib/ollama_chat/state_selectors.rb', line 245

def setup_state_selectors(config)
  @document_policy = DatabaseStateSelector.new(
    chat:      self,
    attribute: :document_policy,
    name:      'Document policy',
    states:    OllamaChat::Parsing::DOCUMENT_POLICY_STATES,
    off:       OllamaChat::Parsing::DOCUMENT_POLICY_STATES[0, 1],
  )
  @think_mode = DatabaseStateSelector.new(
    chat:      self,
    attribute: :think_mode,
    name:      'Think mode',
    states:    OllamaChat::ThinkControl::THINK_MODE_STATES,
    off:       OllamaChat::ThinkControl::THINK_MODE_STATES[0, 1],
  )
  @voices = DatabaseStateSelector.new(
    chat:        self,
    attribute:   :current_voice,
    name:        'Voice',
    states:      config.voice.list,
    allow_empty: true
  )
end