discourse-ai/lib/completions/endpoints
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
..
anthropic.rb FEATURE: allow specifying tool use none in completion prompt 2025-03-25 08:06:43 +11:00
aws_bedrock.rb FEATURE: allow specifying tool use none in completion prompt 2025-03-25 08:06:43 +11:00
base.rb FEATURE: implement thinking token support (#1155) 2025-03-04 12:22:30 +11:00
canned_response.rb FEATURE: implement thinking token support (#1155) 2025-03-04 12:22:30 +11:00
cohere.rb FEATURE: improve tool support (#904) 2024-11-12 08:14:30 +11:00
fake.rb FEATURE: implement thinking token support (#1155) 2025-03-04 12:22:30 +11:00
gemini.rb FEATURE: allow specifying tool use none in completion prompt 2025-03-25 08:06:43 +11:00
hugging_face.rb FEATURE: improve tool support (#904) 2024-11-12 08:14:30 +11:00
mistral.rb FEATURE: Add support for Mistral models (#919) 2024-11-19 17:28:09 +11:00
ollama.rb FEATURE: improve tool support (#904) 2024-11-12 08:14:30 +11:00
open_ai.rb FEATURE: allow specifying tool use none in completion prompt 2025-03-25 08:06:43 +11:00
open_router.rb FEATURE: allow disabling of top_p and temp for thinking models (#1184) 2025-03-11 16:54:02 +11:00
samba_nova.rb FEATURE: improve tool support (#904) 2024-11-12 08:14:30 +11:00
vllm.rb FEATURE: improve tool support (#904) 2024-11-12 08:14:30 +11:00