Class: AnthropicRequestDetails

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

Overview

GlimRequest delegates to this

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(req) ⇒ AnthropicRequestDetails

only for requests that involve a message array, like OpenAI



14
15
16
# File 'lib/anthropic_request_details.rb', line 14

def initialize(req)
  @req = req
end

Instance Attribute Details

#reqObject

Returns the value of attribute req.



18
19
20
# File 'lib/anthropic_request_details.rb', line 18

def req
  @req
end

Instance Method Details

#llm_class_changedObject



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

def llm_class_changed
  update_request_hash
end

#response_classObject



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

def response_class
  AnthropicResponse
end

#update_request_hashObject



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

def update_request_hash
  req.request_hash[:max_tokens_to_sample] = req.max_tokens || 2000
  req.request_hash[:prompt] = req.prompt    
  req.request_hash[:temperature] = req.temperature 
  req.request_hash[:model] = req.llm_name 
  # deeply remove keys for any values that are nil
  req.request_hash.delete_if { |k, v| v.nil? }
end