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) ⇒ 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; unused in this pass-through adapter

Returns:

  • (Array<Hash>)


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

def adapt_messages(messages, think: false)
  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)


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

def inject_think_flag?
  false
end