-
-
Notifications
You must be signed in to change notification settings - Fork 367
Description
Basic checks
- I searched existing issues - this hasn't been reported
- I can reproduce this consistently
- This is a RubyLLM bug, not my application code
What's broken?
It’s not possible to query Amazon models. It always ends with an error.
How to reproduce
chat = RubyLLM.chat(model: 'amazon.nova-2-lite-v1:0')
response = chat.ask "What's the best way to learn Ruby?"
Error:
response = chat.ask "What's the best way to learn Ruby?"
request: POST https://bedrock-runtime.eu-central-1.amazonaws.com/model/amazon.nova-2-lite-v1:0/invoke
request: {anthropic_version: "bedrock-2023-05-31",
messages:
[{role: "user",
content: [{type: "text", text: "What's the best way to learn Ruby?"}]}],
max_tokens: 4096}
error: /usr/local/bundle/gems/ruby_llm-1.11.0/lib/ruby_llm/error.rb:52:in 'RubyLLM::ErrorMiddleware.parse_error': Malformed input request: #/messages/0/content/0: extraneous key [type] is not permitted, reformat your input and try again. (RubyLLM::BadRequestError)
from /usr/local/bundle/gems/ruby_llm-1.11.0/lib/ruby_llm/error.rb:40:in 'block in RubyLLM::ErrorMiddleware#call'
from /usr/local/bundle/gems/faraday-2.14.0/lib/faraday/response.rb:46:in 'Faraday::Response#on_complete'
from /usr/local/bundle/gems/ruby_llm-1.11.0/lib/ruby_llm/error.rb:39:in 'RubyLLM::ErrorMiddleware#call'
from /usr/local/bundle/gems/faraday-2.14.0/lib/faraday/middleware.rb:56:in 'Faraday::Middleware#call'
from /usr/local/bundle/gems/faraday-2.14.0/lib/faraday/middleware.rb:56:in 'Faraday::Middleware#call'
from /usr/local/bundle/gems/faraday-multipart-1.2.0/lib/faraday/multipart/middleware.rb:27:in 'Faraday::Multipart::Middleware#call'
from /usr/local/bundle/gems/faraday-retry-2.4.0/lib/faraday/retry/middleware.rb:171:in 'block in Faraday::Retry::Middleware#call'
from /usr/local/bundle/gems/faraday-retry-2.4.0/lib/faraday/retry/retryable.rb:7:in 'Faraday::Retryable#with_retries'
from /usr/local/bundle/gems/faraday-retry-2.4.0/lib/faraday/retry/middleware.rb:167:in 'Faraday::Retry::Middleware#call'
from /usr/local/bundle/gems/faraday-2.14.0/lib/faraday/middleware.rb:56:in 'Faraday::Middleware#call'
from /usr/local/bundle/gems/faraday-2.14.0/lib/faraday/response/logger.rb:25:in 'Faraday::Response::Logger#call'
from /usr/local/bundle/gems/faraday-2.14.0/lib/faraday/rack_builder.rb:153:in 'Faraday::RackBuilder#build_response'
from /usr/local/bundle/gems/faraday-2.14.0/lib/faraday/connection.rb:452:in 'Faraday::Connection#run_request'
from /usr/local/bundle/gems/faraday-2.14.0/lib/faraday/connection.rb:280:in 'Faraday::Connection#post'
from /usr/local/bundle/gems/ruby_llm-1.11.0/lib/ruby_llm/connection.rb:37:in 'RubyLLM::Connection#post'
from /usr/local/bundle/gems/ruby_llm-1.11.0/lib/ruby_llm/providers/bedrock/chat.rb:12:in 'RubyLLM::Providers::Bedrock::Chat#sync_response'
from /usr/local/bundle/gems/ruby_llm-1.11.0/lib/ruby_llm/provider.rb:59:in 'RubyLLM::Provider#complete'
from /usr/local/bundle/gems/ruby_llm-1.11.0/lib/ruby_llm/chat.rb:133:in 'RubyLLM::Chat#complete'
from /usr/local/bundle/gems/ruby_llm-1.11.0/lib/ruby_llm/chat.rb:36:in 'RubyLLM::Chat#ask'
from (app):10:in '
from /usr/local/bundle/gems/irb-1.14.1/lib/irb/workspace.rb:121:in 'Kernel#eval'
from /usr/local/bundle/gems/irb-1.14.1/lib/irb/workspace.rb:121:in 'IRB::WorkSpace#evaluate'
from /usr/local/bundle/gems/irb-1.14.1/lib/irb/context.rb:622:in 'IRB::Context#evaluate_expression'
from /usr/local/bundle/gems/irb-1.14.1/lib/irb/context.rb:590:in 'IRB::Context#evaluate'
from /usr/local/bundle/gems/irb-1.14.1/lib/irb.rb:1051:in 'block (2 levels) in IRB::Irb#eval_input'
from /usr/local/bundle/gems/irb-1.14.1/lib/irb.rb:1363:in 'IRB::Irb#signal_status'
from /usr/local/bundle/gems/irb-1.14.1/lib/irb.rb:1043:in 'block in IRB::Irb#eval_input'
from /usr/local/bundle/gems/irb-1.14.1/lib/irb.rb:1122:in 'block in IRB::Irb#each_top_level_statement'
from internal:kernel:168:in 'Kernel#loop'
from /usr/local/bundle/gems/irb-1.14.1/lib/irb.rb:1119:in 'IRB::Irb#each_top_level_statement'
from /usr/local/bundle/gems/irb-1.14.1/lib/irb.rb:1042:in 'IRB::Irb#eval_input'
from /usr/local/bundle/gems/irb-1.14.1/lib/irb.rb:1023:in 'block in IRB::Irb#run'
from /usr/local/bundle/gems/irb-1.14.1/lib/irb.rb:1022:in 'Kernel#catch'
from /usr/local/bundle/gems/irb-1.14.1/lib/irb.rb:1022:in 'IRB::Irb#run'
from /usr/local/bundle/gems/railties-8.1.1/lib/rails/commands/console/irb_console.rb:113:in 'Rails::Console::IRBConsole#start'
from /usr/local/bundle/gems/railties-8.1.1/lib/rails/commands/console/console_command.rb:59:in 'Rails::Console#start'
from /usr/local/bundle/gems/railties-8.1.1/lib/rails/commands/console/console_command.rb:8:in 'Rails::Console.start'
from /usr/local/bundle/gems/railties-8.1.1/lib/rails/commands/console/console_command.rb:87:in 'Rails::Command::ConsoleCommand#perform'
from /usr/local/bundle/gems/thor-1.3.2/lib/thor/command.rb:28:in 'Thor::Command#run'
from /usr/local/bundle/gems/thor-1.3.2/lib/thor/invocation.rb:127:in 'Thor::Invocation#invoke_command'
from /usr/local/bundle/gems/railties-8.1.1/lib/rails/command/base.rb:176:in 'Rails::Command::Base#invoke_command'
from /usr/local/bundle/gems/thor-1.3.2/lib/thor.rb:538:in 'Thor.dispatch'
from /usr/local/bundle/gems/railties-8.1.1/lib/rails/command/base.rb:71:in 'Rails::Command::Base.perform'
from /usr/local/bundle/gems/railties-8.1.1/lib/rails/command.rb:65:in 'block in Rails::Command.invoke'
from /usr/local/bundle/gems/railties-8.1.1/lib/rails/command.rb:143:in 'Rails::Command.with_argv'
from /usr/local/bundle/gems/railties-8.1.1/lib/rails/command.rb:63:in 'Rails::Command.invoke'
from /usr/local/bundle/gems/railties-8.1.1/lib/rails/commands.rb:18:in ''
from internal:/usr/local/lib/ruby/3.4.0/rubygems/core_ext/kernel_require.rb:37:in 'Kernel#require'
from internal:/usr/local/lib/ruby/3.4.0/rubygems/core_ext/kernel_require.rb:37:in 'Kernel#require'
from /usr/local/bundle/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in 'Kernel#require'
from bin/rails:4:in ''
(app):10:in '
': Malformed input request: #/messages/0/content/0: extraneous key [type] is not permitted, reformat your input and try again. (RubyLLM::BadRequestError)Expected behavior
However, when I query OpenAI directly (not via Bedrock), it works without any issues.
What actually happened
error: /usr/local/bundle/gems/ruby_llm-1.11.0/lib/ruby_llm/error.rb:52:in 'RubyLLM::ErrorMiddleware.parse_error': Malformed input request: #/messages/0/content/0: extraneous key [type] is not permitted, reformat your input and try again. (RubyLLM::BadRequestError)
from /usr/local/bundle/gems/ruby_llm-1.11.0/lib/ruby_llm/error.rb:40:in 'block in RubyLLM::ErrorMiddleware#call'
from /usr/local/bundle/gems/faraday-2.14.0/lib/faraday/response.rb:46:in 'Faraday::Response#on_complete'
from /usr/local/bundle/gems/ruby_llm-1.11.0/lib/ruby_llm/error.rb:39:in 'RubyLLM::ErrorMiddleware#call'
from /usr/local/bundle/gems/faraday-2.14.0/lib/faraday/middleware.rb:56:in 'Faraday::Middleware#call'
from /usr/local/bundle/gems/faraday-2.14.0/lib/faraday/middleware.rb:56:in 'Faraday::Middleware#call'
from /usr/local/bundle/gems/faraday-multipart-1.2.0/lib/faraday/multipart/middleware.rb:27:in 'Faraday::Multipart::Middleware#call'
from /usr/local/bundle/gems/faraday-retry-2.4.0/lib/faraday/retry/middleware.rb:171:in 'block in Faraday::Retry::Middleware#call'
from /usr/local/bundle/gems/faraday-retry-2.4.0/lib/faraday/retry/retryable.rb:7:in 'Faraday::Retryable#with_retries'
from /usr/local/bundle/gems/faraday-retry-2.4.0/lib/faraday/retry/middleware.rb:167:in 'Faraday::Retry::Middleware#call'
from /usr/local/bundle/gems/faraday-2.14.0/lib/faraday/middleware.rb:56:in 'Faraday::Middleware#call'
from /usr/local/bundle/gems/faraday-2.14.0/lib/faraday/response/logger.rb:25:in 'Faraday::Response::Logger#call'
from /usr/local/bundle/gems/faraday-2.14.0/lib/faraday/rack_builder.rb:153:in 'Faraday::RackBuilder#build_response'
from /usr/local/bundle/gems/faraday-2.14.0/lib/faraday/connection.rb:452:in 'Faraday::Connection#run_request'
from /usr/local/bundle/gems/faraday-2.14.0/lib/faraday/connection.rb:280:in 'Faraday::Connection#post'
from /usr/local/bundle/gems/ruby_llm-1.11.0/lib/ruby_llm/connection.rb:37:in 'RubyLLM::Connection#post'
from /usr/local/bundle/gems/ruby_llm-1.11.0/lib/ruby_llm/providers/bedrock/chat.rb:12:in 'RubyLLM::Providers::Bedrock::Chat#sync_response'
from /usr/local/bundle/gems/ruby_llm-1.11.0/lib/ruby_llm/provider.rb:59:in 'RubyLLM::Provider#complete'
from /usr/local/bundle/gems/ruby_llm-1.11.0/lib/ruby_llm/chat.rb:133:in 'RubyLLM::Chat#complete'
from /usr/local/bundle/gems/ruby_llm-1.11.0/lib/ruby_llm/chat.rb:36:in 'RubyLLM::Chat#ask'
from (app):10:in '
from /usr/local/bundle/gems/irb-1.14.1/lib/irb/workspace.rb:121:in 'Kernel#eval'
from /usr/local/bundle/gems/irb-1.14.1/lib/irb/workspace.rb:121:in 'IRB::WorkSpace#evaluate'
from /usr/local/bundle/gems/irb-1.14.1/lib/irb/context.rb:622:in 'IRB::Context#evaluate_expression'
from /usr/local/bundle/gems/irb-1.14.1/lib/irb/context.rb:590:in 'IRB::Context#evaluate'
from /usr/local/bundle/gems/irb-1.14.1/lib/irb.rb:1051:in 'block (2 levels) in IRB::Irb#eval_input'
from /usr/local/bundle/gems/irb-1.14.1/lib/irb.rb:1363:in 'IRB::Irb#signal_status'
from /usr/local/bundle/gems/irb-1.14.1/lib/irb.rb:1043:in 'block in IRB::Irb#eval_input'
from /usr/local/bundle/gems/irb-1.14.1/lib/irb.rb:1122:in 'block in IRB::Irb#each_top_level_statement'
from internal:kernel:168:in 'Kernel#loop'
from /usr/local/bundle/gems/irb-1.14.1/lib/irb.rb:1119:in 'IRB::Irb#each_top_level_statement'
from /usr/local/bundle/gems/irb-1.14.1/lib/irb.rb:1042:in 'IRB::Irb#eval_input'
from /usr/local/bundle/gems/irb-1.14.1/lib/irb.rb:1023:in 'block in IRB::Irb#run'
from /usr/local/bundle/gems/irb-1.14.1/lib/irb.rb:1022:in 'Kernel#catch'
from /usr/local/bundle/gems/irb-1.14.1/lib/irb.rb:1022:in 'IRB::Irb#run'
from /usr/local/bundle/gems/railties-8.1.1/lib/rails/commands/console/irb_console.rb:113:in 'Rails::Console::IRBConsole#start'
from /usr/local/bundle/gems/railties-8.1.1/lib/rails/commands/console/console_command.rb:59:in 'Rails::Console#start'
from /usr/local/bundle/gems/railties-8.1.1/lib/rails/commands/console/console_command.rb:8:in 'Rails::Console.start'
from /usr/local/bundle/gems/railties-8.1.1/lib/rails/commands/console/console_command.rb:87:in 'Rails::Command::ConsoleCommand#perform'
from /usr/local/bundle/gems/thor-1.3.2/lib/thor/command.rb:28:in 'Thor::Command#run'
from /usr/local/bundle/gems/thor-1.3.2/lib/thor/invocation.rb:127:in 'Thor::Invocation#invoke_command'
from /usr/local/bundle/gems/railties-8.1.1/lib/rails/command/base.rb:176:in 'Rails::Command::Base#invoke_command'
from /usr/local/bundle/gems/thor-1.3.2/lib/thor.rb:538:in 'Thor.dispatch'
from /usr/local/bundle/gems/railties-8.1.1/lib/rails/command/base.rb:71:in 'Rails::Command::Base.perform'
from /usr/local/bundle/gems/railties-8.1.1/lib/rails/command.rb:65:in 'block in Rails::Command.invoke'
from /usr/local/bundle/gems/railties-8.1.1/lib/rails/command.rb:143:in 'Rails::Command.with_argv'
from /usr/local/bundle/gems/railties-8.1.1/lib/rails/command.rb:63:in 'Rails::Command.invoke'
from /usr/local/bundle/gems/railties-8.1.1/lib/rails/commands.rb:18:in ''
from internal:/usr/local/lib/ruby/3.4.0/rubygems/core_ext/kernel_require.rb:37:in 'Kernel#require'
from internal:/usr/local/lib/ruby/3.4.0/rubygems/core_ext/kernel_require.rb:37:in 'Kernel#require'
from /usr/local/bundle/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in 'Kernel#require'
from bin/rails:4:in ''
(app):10:in '
': Malformed input request: #/messages/0/content/0: extraneous key [type] is not permitted, reformat your input and try again. (RubyLLM::BadRequestError)Environment
Ruby: 3.4.8
Rails: 8.1.1
RubyLLM: 1.11.0
Provider: AWS Bedrock
OS: Linux, Docker
RubyLLM.configure do |config|
config.bedrock_api_key = ENV['AWS_ACCESS_KEY_ID']
config.bedrock_secret_key = ENV['AWS_SECRET_ACCESS_KEY']
config.bedrock_region = ENV['AWS_REGION']
config.log_level = :debug
config.logger = Rails.logger
end
AWS_REGION=eu-central-1