Module: LlmGateway::Adapters::OpenAI::Responses::OptionMapper
Constant Summary
collapse
- VALID_REASONING_LEVELS =
%w[low medium high xhigh].freeze
Class Method Summary
collapse
included, #map_cache_key!, #map_prompt_cache_retention!
Class Method Details
.map(options) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/llm_gateway/adapters/openai/responses/option_mapper.rb', line 14
def map(options)
mapped_options = options.dup
max_completion_tokens = mapped_options.delete(:max_completion_tokens)
mapped_options[:max_output_tokens] = max_completion_tokens || mapped_options[:max_output_tokens] || 20_480
map_cache_key!(mapped_options)
map_prompt_cache_retention!(mapped_options)
return mapped_options unless mapped_options.key?(:reasoning)
reasoning = mapped_options.delete(:reasoning)
return mapped_options if reasoning.nil? || reasoning.to_s == "none"
mapped_options.merge(reasoning: normalize_reasoning(reasoning))
end
|
.normalize_reasoning(reasoning) ⇒ Object
31
32
33
34
35
36
|
# File 'lib/llm_gateway/adapters/openai/responses/option_mapper.rb', line 31
def normalize_reasoning(reasoning)
effort = reasoning.to_s
return { effort: effort, summary: "detailed" } if VALID_REASONING_LEVELS.include?(effort)
raise ArgumentError, "Invalid reasoning '#{reasoning}'. Use 'none', 'low', 'medium', 'high', or 'xhigh'."
end
|