FIX: tools broke on Claude with no params (#574)
Some tools may have no params, allow that
This commit is contained in:
parent
3b0cfdbe5c
commit
a77658e2b1
|
@ -158,7 +158,7 @@ module DiscourseAi
|
|||
return "" if prompt.tools.blank?
|
||||
|
||||
has_arrays =
|
||||
prompt.tools.any? { |tool| tool[:parameters].any? { |p| p[:type] == "array" } }
|
||||
prompt.tools.any? { |tool| tool[:parameters]&.any? { |p| p[:type] == "array" } }
|
||||
|
||||
(<<~TEXT).strip
|
||||
#{self.class.tool_preamble(include_array_tip: has_arrays)}
|
||||
|
|
|
@ -47,6 +47,15 @@ RSpec.describe DiscourseAi::Completions::Dialects::Dialect do
|
|||
|
||||
expect(dialect.build_tools_prompt).to include("array")
|
||||
end
|
||||
|
||||
it "does not break if there are no params" do
|
||||
prompt = DiscourseAi::Completions::Prompt.new("12345")
|
||||
prompt.tools = [{ name: "categories", description: "lookup all categories" }]
|
||||
|
||||
dialect = TestDialect.new(prompt, "test")
|
||||
|
||||
expect(dialect.build_tools_prompt).not_to include("array")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#trim_messages" do
|
||||
|
|
Loading…
Reference in New Issue