Class: Ollama::PromptAdapters::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ollama/prompt_adapters/base.rb

Overview

Base prompt adapter — pass-through with no transformation. Subclasses override adapt_messages to apply model-family-specific prompt shaping (e.g. injecting think tags, reordering parts).

Direct Known Subclasses

DeepSeek, Gemma4, Generic, Qwen

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(profile) ⇒ Base

Returns a new instance of Base.



11
12
13
# File 'lib/ollama/prompt_adapters/base.rb', line 11

def initialize(profile)
  @profile = profile
end

Instance Attribute Details

#profileObject (readonly)

Returns the value of attribute profile.



9
10
11
# File 'lib/ollama/prompt_adapters/base.rb', line 9

def profile
  @profile
end

Instance Method Details

#adapt_messages(messages, think: false, tools: nil) ⇒ Array<Hash>

Transform messages for this model family. rubocop:disable Lint/UnusedMethodArgument -- keyword kept for subclass / duck-typed API

Parameters:

  • messages (Array<Hash>)
  • think (Boolean, String, nil) (defaults to: false)

    forwarded from chat

  • tools (Array<Hash>, nil) (defaults to: nil)

    forwarded from chat

Returns:

  • (Array<Hash>)


21
22
23
# File 'lib/ollama/prompt_adapters/base.rb', line 21

def adapt_messages(messages, think: false, tools: nil)
  messages
end

#inject_think_flag?Boolean

Whether this adapter injects think: true into the API body. Gemma 4 uses a system-prompt tag instead, so returns false there.

Returns:

  • (Boolean)


28
29
30
# File 'lib/ollama/prompt_adapters/base.rb', line 28

def inject_think_flag?
  false
end