Class: EmbeddingUtil::ServerModel

Inherits:
Data
  • Object
show all
Defined in:
lib/embedding_util/server_model.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#capabilityObject (readonly)

Returns the value of attribute capability

Returns:

  • (Object)

    the current value of capability



10
11
12
# File 'lib/embedding_util/server_model.rb', line 10

def capability
  @capability
end

#profileObject (readonly)

Returns the value of attribute profile

Returns:

  • (Object)

    the current value of profile



10
11
12
# File 'lib/embedding_util/server_model.rb', line 10

def profile
  @profile
end

Class Method Details

.for(capability, profile) ⇒ Object



20
21
22
# File 'lib/embedding_util/server_model.rb', line 20

def self.for(capability, profile)
  new(capability: capability.to_sym, profile: profile)
end

.parse(value) ⇒ Object

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
18
# File 'lib/embedding_util/server_model.rb', line 11

def self.parse(value)
  text = value.to_s
  prefix, profile_name = text.split("-", 2)
  capability = SERVER_MODEL_PREFIXES[prefix]
  raise ArgumentError, "unknown server model #{value.inspect}; expected embedding-PROFILE or reranker-PROFILE" unless capability && profile_name

  new(capability: capability, profile: Profiles.fetch(profile_name))
end

Instance Method Details

#default_port(config) ⇒ Object



36
37
38
# File 'lib/embedding_util/server_model.rb', line 36

def default_port(config)
  capability == :embedding ? config.embedding_port : config.reranker_port
end

#nameObject



24
25
26
# File 'lib/embedding_util/server_model.rb', line 24

def name
  "#{capability_name}-#{profile.name}"
end

#settingsObject



28
29
30
31
32
33
34
# File 'lib/embedding_util/server_model.rb', line 28

def settings
  case capability
  when :embedding then profile.embedding
  when :reranker then profile.reranker
  else raise ArgumentError, "unknown server capability: #{capability.inspect}"
  end
end