discourse-ai/lib/completions
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
..
dialects FEATURE: allow specifying tool use none in completion prompt 2025-03-25 08:06:43 +11:00
endpoints FEATURE: allow specifying tool use none in completion prompt 2025-03-25 08:06:43 +11:00
anthropic_message_processor.rb FEATURE: implement thinking token support (#1155) 2025-03-04 12:22:30 +11:00
json_stream_decoder.rb FEATURE: improve tool support (#904) 2024-11-12 08:14:30 +11:00
json_streaming_parser.rb FEATURE: partial tool call support for OpenAI and Anthropic (#908) 2024-11-14 06:58:24 +11:00
llm.rb DEV: Support for extra model params in LLM completions (#1208) 2025-03-21 13:49:23 -03:00
nova_message_processor.rb FEATURE: Amazon Nova support via bedrock (#997) 2024-12-06 07:45:58 +11:00
open_ai_message_processor.rb FEATURE: AI Usage page (#964) 2024-11-29 06:26:48 +11:00
prompt.rb FEATURE: silent triage using ai persona (#1193) 2025-03-17 15:14:09 +11:00
prompt_messages_builder.rb FEATURE: automation triage using personas (#1126) 2025-03-06 09:41:09 +11:00
report.rb UX: Improve rough edges of AI usage page (#1014) 2024-12-12 08:55:24 +11:00
thinking.rb FEATURE: implement thinking token support (#1155) 2025-03-04 12:22:30 +11:00
tool_call.rb FEATURE: AI artifacts (#898) 2024-11-19 09:22:39 +11:00
tool_call_progress_tracker.rb FEATURE: AI artifacts (#898) 2024-11-19 09:22:39 +11:00
upload_encoder.rb FEATURE: Add vision support to AI personas (Claude 3) (#546) 2024-03-27 14:30:11 +11:00
xml_tag_stripper.rb FIX: display search correctly, bug when stripping XML (#668) 2024-06-14 15:28:40 +10:00
xml_tool_processor.rb FEATURE: AI artifacts (#898) 2024-11-19 09:22:39 +11:00