Module: OllamaChat::ModelHandling

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

Overview

A module that provides functionality for managing Ollama models, including checking model availability, pulling models from remote servers, and handling model presence verification.

This module encapsulates the logic for interacting with Ollama models, ensuring that required models are available locally before attempting to use them in chat sessions. It handles both local model verification and remote model retrieval when necessary.

Examples:

Checking if a model is present

chat.model_present?('llama3.1')

Pulling a model from a remote server

chat.pull_model_from_remote('mistral')

Ensuring a model is available locally

chat.pull_model_unless_present('phi3', {})

Defined Under Namespace

Classes: ModelMetadata

Instance Method Summary collapse

Instance Method Details

#get_stored_model_options(model_name) ⇒ Hash

Retrieves the stored model options from the database for a given model name.

Parameters:

  • model_name (String)

    the name of the model to look up

Returns:

  • (Hash)

    the model options as a hash with symbolized keys



40
41
42
43
# File 'lib/ollama_chat/model_handling.rb', line 40

def get_stored_model_options(model_name)
  models::ModelOptions.where(model_name:).first&.options.
    to_h.symbolize_keys_recursive
end