Class: Net::Llm::Anthropic
- Inherits:
-
Object
- Object
- Net::Llm::Anthropic
- Defined in:
- lib/net/llm/anthropic.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(api_key: ENV.fetch("ANTHROPIC_API_KEY"), model: "claude-sonnet-4-20250514", http: Net::Llm.http) ⇒ Anthropic
constructor
A new instance of Anthropic.
- #messages ⇒ Object
Constructor Details
#initialize(api_key: ENV.fetch("ANTHROPIC_API_KEY"), model: "claude-sonnet-4-20250514", http: Net::Llm.http) ⇒ Anthropic
Returns a new instance of Anthropic.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/net/llm/anthropic.rb', line 8 def initialize(api_key: ENV.fetch("ANTHROPIC_API_KEY"), model: "claude-sonnet-4-20250514", http: Net::Llm.http) @api_key = api_key @model = model @claude = Claude.new( endpoint: "https://api.anthropic.com/v1/messages", headers: { "x-api-key" => api_key, "anthropic-version" => "2023-06-01" }, model: model, http: http ) end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
6 7 8 |
# File 'lib/net/llm/anthropic.rb', line 6 def api_key @api_key end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
6 7 8 |
# File 'lib/net/llm/anthropic.rb', line 6 def model @model end |
Instance Method Details
#fetch ⇒ Object
20 |
# File 'lib/net/llm/anthropic.rb', line 20 def fetch(...) = @claude.fetch(...) |
#messages ⇒ Object
19 |
# File 'lib/net/llm/anthropic.rb', line 19 def (...) = @claude.(...) |