discourse-ai/lib/completions/dialects
Sam 1dde82eb58
FEATURE: allow specifying tool use none in completion prompt
This PR adds support for disabling further tool calls by setting tool_choice to :none across all supported LLM providers:

- OpenAI: Uses "none" tool_choice parameter
- Anthropic: Uses {type: "none"} and adds a prefill message to prevent confusion
- Gemini: Sets function_calling_config mode to "NONE"
- AWS Bedrock: Doesn't natively support tool disabling, so adds a prefill message

We previously used to disable tool calls by simply removing tool definitions, but this would cause errors with some providers. This implementation uses the supported method appropriate for each provider while providing a fallback for Bedrock.

Co-authored-by: Natalie Tay <natalie.tay@gmail.com>

* remove stray puts

* cleaner chain breaker for last tool call (works in thinking)

remove unused code

* improve test

---------

Co-authored-by: Natalie Tay <natalie.tay@gmail.com>
2025-03-25 08:06:43 +11:00
..
chat_gpt.rb FIX: legacy reasoning models not working, missing provider params (#1149) 2025-02-24 16:38:23 +11:00
claude.rb FEATURE: implement thinking token support (#1155) 2025-03-04 12:22:30 +11:00
claude_tools.rb FEATURE: implement thinking token support (#1155) 2025-03-04 12:22:30 +11:00
cohere_tools.rb FEATURE: Add native Cohere tool support (#655) 2024-06-04 08:59:15 +10:00
command.rb FEATURE: Amazon Nova support via bedrock (#997) 2024-12-06 07:45:58 +11:00
dialect.rb FEATURE: allow specifying tool use none in completion prompt 2025-03-25 08:06:43 +11:00
fake.rb FEATURE: Amazon Nova support via bedrock (#997) 2024-12-06 07:45:58 +11:00
gemini.rb FEATURE: Amazon Nova support via bedrock (#997) 2024-12-06 07:45:58 +11:00
mistral.rb FEATURE: Amazon Nova support via bedrock (#997) 2024-12-06 07:45:58 +11:00
nova.rb FEATURE: Amazon Nova support via bedrock (#997) 2024-12-06 07:45:58 +11:00
nova_tools.rb FEATURE: Amazon Nova support via bedrock (#997) 2024-12-06 07:45:58 +11:00
ollama.rb FEATURE: Amazon Nova support via bedrock (#997) 2024-12-06 07:45:58 +11:00
ollama_tools.rb FEATURE: Tools for models from Ollama provider (#819) 2024-10-11 07:25:53 +11:00
open_ai_compatible.rb FEATURE: Amazon Nova support via bedrock (#997) 2024-12-06 07:45:58 +11:00
open_ai_tools.rb FIX: Make sure custom tool enums follow json-schema. (#718) 2024-07-16 14:23:17 -03:00
xml_tools.rb FEATURE: allow specifying tool use none in completion prompt 2025-03-25 08:06:43 +11:00