Class: SentimentAI::Core::AnthropicDriver
- Inherits:
-
Object
- Object
- SentimentAI::Core::AnthropicDriver
- Defined in:
- lib/sentiment_ai/core/anthropic_driver.rb
Instance Method Summary collapse
- #analyze_sentence(sentence) ⇒ Object
-
#initialize(api_key) ⇒ AnthropicDriver
constructor
A new instance of AnthropicDriver.
- #positive_check(sentence) ⇒ Object
Constructor Details
#initialize(api_key) ⇒ AnthropicDriver
Returns a new instance of AnthropicDriver.
8 9 10 |
# File 'lib/sentiment_ai/core/anthropic_driver.rb', line 8 def initialize(api_key) @sentiment_ai = Anthropic::Client.new(access_token: api_key) end |
Instance Method Details
#analyze_sentence(sentence) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/sentiment_ai/core/anthropic_driver.rb', line 12 def analyze_sentence(sentence) text_request = I18n.t('prompt.sentence', sentence: sentence) @sentiment_ai.( parameters: { model: 'claude-3-haiku-20240307', messages: [ { 'role': 'user', 'content': text_request } ], max_tokens: 1000 } ) end |
#positive_check(sentence) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/sentiment_ai/core/anthropic_driver.rb', line 26 def positive_check(sentence) text_request = I18n.t('prompt.positive_check', sentence: sentence) @sentiment_ai.( parameters: { model: 'claude-3-haiku-20240307', messages: [ { 'role': 'user', 'content': text_request } ], max_tokens: 1000 } ) end |