Class: Foobara::Ai::AnthropicApi::CreateMessage
- Inherits:
-
BaseCommand
- Object
- Command
- BaseCommand
- Foobara::Ai::AnthropicApi::CreateMessage
- Defined in:
- foobara-anthropic-api-1.1.0/src/create_message.rb
Constant Summary
Constants included from TruncatedInspect
Instance Method Summary collapse
Methods inherited from BaseCommand
#anthropic_version, #api_token, #api_token_from_env, #build_request_headers, #issue_http_request
Methods inherited from Command
Methods included from CommandPatternImplementation
install_state_machine_callback_methods
Methods included from TruncatedInspect
Methods included from Concern
foobara_class_methods_module_for, foobara_concern?, included
Instance Method Details
#build_request_body ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'src/create_message.rb', line 26 def build_request_body body = { model:, max_tokens:, messages: } sys = inputs[:system] if sys body[:system] = sys end self.request_body = body end |
#build_result ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'src/create_message.rb', line 43 def build_result = Types::MessageResult.new( response_body, # Set this to false to discover new attributes ignore_unexpected_attributes: true ) if fail_if_hitting_token_limit && .hit_max_tokens? add_runtime_error(:hit_token_limit, model:, max_tokens:) end end |
#max_tokens ⇒ Object
37 38 39 40 41 |
# File 'src/create_message.rb', line 37 def max_tokens @max_tokens ||= inputs[:max_tokens] || run_subcommand!(GetModel, model:).max_tokens || 64_000 end |