Class: Prescient::Base

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ Base

Returns a new instance of Base.



6
7
8
9
# File 'lib/prescient/base.rb', line 6

def initialize(**options)
  @options = options
  validate_configuration!
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/prescient/base.rb', line 4

def options
  @options
end

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)


24
25
26
27
28
# File 'lib/prescient/base.rb', line 24

def available?
  health_check[:status] == 'healthy'
rescue StandardError
  false
end

#generate_embedding(text) ⇒ Object

Abstract methods that must be implemented by subclasses

Raises:

  • (NotImplementedError)


12
13
14
# File 'lib/prescient/base.rb', line 12

def generate_embedding(text)
  raise NotImplementedError, "#{self.class} must implement #generate_embedding"
end

#generate_response(prompt, context_items = [], **options) ⇒ Object

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/prescient/base.rb', line 16

def generate_response(prompt, context_items = [], **options)
  raise NotImplementedError, "#{self.class} must implement #generate_response"
end

#health_checkObject

Raises:

  • (NotImplementedError)


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

def health_check
  raise NotImplementedError, "#{self.class} must implement #health_check"
end