Module: RubyLLM::Providers::Bedrock::Chat
- Included in:
- RubyLLM::Providers::Bedrock
- Defined in:
- lib/ruby_llm/providers/bedrock/chat.rb
Overview
Chat methods for the AWS Bedrock API implementation
Class Method Summary collapse
- .format_basic_message(msg) ⇒ Object
- .format_message(msg) ⇒ Object
- .sync_response(connection, payload, additional_headers = {}) ⇒ Object
Class Method Details
.format_basic_message(msg) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/ruby_llm/providers/bedrock/chat.rb', line 29 def (msg) { role: Anthropic::Chat.convert_role(msg.role), content: Media.format_content(msg.content) } end |
.format_message(msg) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/ruby_llm/providers/bedrock/chat.rb', line 19 def (msg) if msg.tool_call? Anthropic::Tools.format_tool_call(msg) elsif msg.tool_result? Anthropic::Tools.format_tool_result(msg) else (msg) end end |
.sync_response(connection, payload, additional_headers = {}) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/ruby_llm/providers/bedrock/chat.rb', line 10 def sync_response(connection, payload, additional_headers = {}) signature = sign_request("#{connection.connection.url_prefix}#{completion_url}", payload:) response = connection.post completion_url, payload do |req| req.headers.merge! build_headers(signature.headers, streaming: block_given?) req.headers = additional_headers.merge(req.headers) unless additional_headers.empty? end Anthropic::Chat.parse_completion_response response end |