Class: LlmClassifier::Adapters::RubyLlm

Inherits:
Base
  • Object
show all
Defined in:
lib/llm_classifier/adapters/ruby_llm.rb

Overview

Adapter for the ruby_llm gem

Instance Method Summary collapse

Instance Method Details

#chat(model:, system_prompt:, user_prompt:) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/llm_classifier/adapters/ruby_llm.rb', line 7

def chat(model:, system_prompt:, user_prompt:)
  ensure_ruby_llm_loaded!

  chat_instance = ::RubyLLM.chat(model: model)
  chat_instance.with_instructions(system_prompt)
  response = chat_instance.ask(user_prompt)

  {
    content: response.content,
    input_tokens: response.input_tokens,
    output_tokens: response.output_tokens
  }
end