Class: Net::Llm::Claude
- Inherits:
-
Object
- Object
- Net::Llm::Claude
- Defined in:
- lib/net/llm/claude.rb
Instance Attribute Summary collapse
-
#anthropic_version ⇒ Object
readonly
Returns the value of attribute anthropic_version.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#http ⇒ Object
readonly
Returns the value of attribute http.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #fetch(messages, tools = [], &block) ⇒ Object
-
#initialize(endpoint:, headers:, http:, model: nil, anthropic_version: nil) ⇒ Claude
constructor
A new instance of Claude.
- #messages(messages, system: nil, max_tokens: 64000, tools: nil, &block) ⇒ Object
Constructor Details
#initialize(endpoint:, headers:, http:, model: nil, anthropic_version: nil) ⇒ Claude
Returns a new instance of Claude.
8 9 10 11 12 13 14 |
# File 'lib/net/llm/claude.rb', line 8 def initialize(endpoint:, headers:, http:, model: nil, anthropic_version: nil) @endpoint = endpoint @headers_source = headers @model = model @http = http @anthropic_version = anthropic_version end |
Instance Attribute Details
#anthropic_version ⇒ Object (readonly)
Returns the value of attribute anthropic_version.
6 7 8 |
# File 'lib/net/llm/claude.rb', line 6 def anthropic_version @anthropic_version end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
6 7 8 |
# File 'lib/net/llm/claude.rb', line 6 def endpoint @endpoint end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
6 7 8 |
# File 'lib/net/llm/claude.rb', line 6 def headers @headers end |
#http ⇒ Object (readonly)
Returns the value of attribute http.
6 7 8 |
# File 'lib/net/llm/claude.rb', line 6 def http @http end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
6 7 8 |
# File 'lib/net/llm/claude.rb', line 6 def model @model end |
Instance Method Details
#fetch(messages, tools = [], &block) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/net/llm/claude.rb', line 30 def fetch(, tools = [], &block) , = () anthropic_tools = tools.empty? ? nil : tools.map { |t| normalize_tool_for_anthropic(t) } if block_given? fetch_streaming(, anthropic_tools, system: , &block) else fetch_non_streaming(, anthropic_tools, system: ) end end |
#messages(messages, system: nil, max_tokens: 64000, tools: nil, &block) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/net/llm/claude.rb', line 20 def (, system: nil, max_tokens: 64000, tools: nil, &block) payload = build_payload(, system, max_tokens, tools, block_given?) if block_given? stream_request(payload, &block) else post_request(payload) end end |