No, I don’t think it’s a specificity of Microsoft Azure, I’ve tested the requests in pure JavaScript and it works without any problems, without any notion of “tools”. Here, I have the impression that it’s a problem with the plugin (I specify that I’m not a Ruby developer) but it seems that the abstraction layer used makes things more complicated. In doubt, we forked that plugin and put debuggers everywhere, the URL, the headers that go to Azure are 100% compliant.
DiscourseAi::Completions::Endpoints::OpenAi: status: 400 - body: { “error”: { “message”: “Unrecognized request argument supplied: tools”, “type”: “invalid_request_error”, “param”: null, “code”: null } }
It seems that the only place where we call a “tools” in ./lib/completions/endpoints/open_ai.rb (DiscourseAi::Completions::Endpoints::OpenAi) is:
def prepare_payload(prompt, model_params, dialect)
Rails.logger.warn("Preparing payload with prompt: #{prompt}, model_params: #{model_params}, dialect: #{dialect}")
default_options
.merge(model_params)
.merge(messages: prompt)
.tap do |payload|
payload[:stream] = true if @streaming_mode
payload[:tools] = dialect.tools if dialect.tools.present?
end
end
which seems to lead us to ./lib/completions/dialects/chat_gpt.rb (payload[:tools] = dialect.tools if dialect.tools.present?)
In the message from PEYRUSSE Christian, we realize that the “dialect” is “dialect: #DiscourseAi::Completions::Dialects::ChatGpt:0x00007f230513e6e0”
If that can help…
Thank you.