Skip to content

Commit eb27e68

Browse files
imtyMImtiaz Mukadamcrmne
authored
Fix: remove tool_choice: auto param for open ai (#336)
## What this does Removes the `tool_choice: 'auto'` from Openai's `render_payload` which allows it to be overwritten with `with_params`. Open [defaults to auto](https://platform.openai.com/docs/api-reference/chat/create#chat_create-tool_choice) when tools are present. <!-- Clear description of what this PR does and why --> ## Type of change - [x] Bug fix - [ ] New feature - [ ] Breaking change - [ ] Documentation - [ ] Performance improvement ## Scope check - [x] I read the [Contributing Guide](https://github.com/crmne/ruby_llm/blob/main/CONTRIBUTING.md) - [x] This aligns with RubyLLM's focus on **LLM communication** - [x] This isn't application-specific logic that belongs in user code - [x] This benefits most users, not just my specific use case ## Quality check - [ ] I ran `overcommit --install` and all hooks pass - [x] I tested my changes thoroughly - [x] I updated documentation if needed - [ ] I didn't modify auto-generated files manually (`models.json`, `aliases.json`) ## API changes - [ ] Breaking change - [ ] New public methods/classes - [ ] Changed method signatures - [ ] No API changes ## Related issues <!-- Link issues: "Fixes #123" or "Related to #123" --> Fixes #317 --------- Co-authored-by: Imtiaz Mukadam <[email protected]> Co-authored-by: Carmine Paolino <[email protected]>
1 parent 837fa7a commit eb27e68

File tree

1 file changed

+1
-4
lines changed
  • lib/ruby_llm/providers/openai

1 file changed

+1
-4
lines changed

lib/ruby_llm/providers/openai/chat.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ def render_payload(messages, tools:, temperature:, model:, stream: false, schema
2121
# Only include temperature if it's not nil (some models don't accept it)
2222
payload[:temperature] = temperature unless temperature.nil?
2323

24-
if tools.any?
25-
payload[:tools] = tools.map { |_, tool| tool_for(tool) }
26-
payload[:tool_choice] = 'auto'
27-
end
24+
payload[:tools] = tools.map { |_, tool| tool_for(tool) } if tools.any?
2825

2926
if schema
3027
# Use strict mode from schema if specified, default to true

0 commit comments

Comments
 (0)