Class: LLM::Clients::OpenAI::Response
- Inherits:
-
Object
- Object
- LLM::Clients::OpenAI::Response
- Defined in:
- lib/llm/clients/open_ai/response.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(raw_response) ⇒ Response
constructor
A new instance of Response.
- #to_normalized_response ⇒ Object
Constructor Details
#initialize(raw_response) ⇒ Response
Returns a new instance of Response.
4 5 6 |
# File 'lib/llm/clients/open_ai/response.rb', line 4 def initialize(raw_response) @raw_response = raw_response end |
Class Method Details
.normalize_stop_reason(stop_reason) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/llm/clients/open_ai/response.rb', line 16 def self.normalize_stop_reason(stop_reason) case stop_reason when "stop" LLM::StopReason::STOP when "safety" LLM::StopReason::SAFETY when "max_tokens" LLM::StopReason::MAX_TOKENS_REACHED else LLM::StopReason::OTHER end end |
Instance Method Details
#to_normalized_response ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/llm/clients/open_ai/response.rb', line 8 def to_normalized_response LLM::Response.new( content: content, raw_response: parsed_response, stop_reason: normalize_stop_reason ) end |