Module: Raif::Concerns::Llms::OpenAiCompletions::ToolFormatting
- Extended by:
- ActiveSupport::Concern
- Included in:
- Llms::OpenAiCompletions, Llms::OpenRouter
- Defined in:
- app/models/raif/concerns/llms/open_ai_completions/tool_formatting.rb
Instance Method Summary collapse
Instance Method Details
#build_forced_tool_choice(tool_name) ⇒ Object
27 28 29 |
# File 'app/models/raif/concerns/llms/open_ai_completions/tool_formatting.rb', line 27 def build_forced_tool_choice(tool_name) { "type" => "function", "function" => { "name" => tool_name } } end |
#build_tools_parameter(model_completion) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/models/raif/concerns/llms/open_ai_completions/tool_formatting.rb', line 6 def build_tools_parameter(model_completion) model_completion.available_model_tools_map.map do |_tool_name, tool| if tool.provider_managed? raise Raif::Errors::UnsupportedFeatureError, "Raif doesn't yet support provider-managed tools for the OpenAI Completions API. Consider using the OpenAI Responses API instead." else # It's a developer-managed tool validate_json_schema!(tool.tool_arguments_schema) { type: "function", function: { name: tool.tool_name, description: tool.tool_description, parameters: tool.tool_arguments_schema } } end end end |