Module: LlmGateway::Adapters::OpenAI::ChatCompletions::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
|
# File 'lib/llm_gateway/adapters/openai/chat_completions/option_mapper.rb', line 14
def map(options)
mapped_options = options.dup
mapped_options[:max_completion_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_effort: normalize_reasoning_effort(reasoning))
end
|
.normalize_reasoning_effort(reasoning) ⇒ Object
29
30
31
32
33
34
|
# File 'lib/llm_gateway/adapters/openai/chat_completions/option_mapper.rb', line 29
def normalize_reasoning_effort(reasoning)
effort = reasoning.to_s
return effort if VALID_REASONING_LEVELS.include?(effort)
raise ArgumentError, "Invalid reasoning '#{reasoning}'. Use 'none', 'low', 'medium', 'high', or 'xhigh'."
end
|