Class: AiAgent::Claude
- Inherits:
-
Base
- Object
- Base
- AiAgent::Claude
show all
- Defined in:
- lib/ai_agent/ai_agent/claude.rb
Instance Attribute Summary
Attributes inherited from Base
#agent, #api_key, #endpoint, #timeout
Instance Method Summary
collapse
Methods inherited from Base
#analyze_sentiment, #recognize_entities, #summarize_text
Constructor Details
#initialize(api_key: nil, endpoint: nil, timeout: 60) ⇒ Claude
12
13
14
15
16
17
|
# File 'lib/ai_agent/ai_agent/claude.rb', line 12
def initialize(api_key: nil, endpoint: nil, timeout: 60)
self.agent = CLAUDE
self.api_key = api_key || ENV['ANTHROPIC_API_KEY']
self.endpoint = endpoint
self.timeout = timeout
end
|
Instance Method Details
#client ⇒ Object
19
20
21
|
# File 'lib/ai_agent/ai_agent/claude.rb', line 19
def client
claude if agent == CLAUDE
end
|
27
28
29
|
# File 'lib/ai_agent/ai_agent/claude.rb', line 27
def format_response(response)
client.parse_response(response) rescue "ERROR: Couldn't extract text from Claude response"
end
|
#send_messages(messages, options) ⇒ Object
23
24
25
|
# File 'lib/ai_agent/ai_agent/claude.rb', line 23
def send_messages(messages, options)
client.messages(messages, options)
end
|