Class: RCrewAI::LLMClients::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/rcrewai/llm_clients/base.rb

Direct Known Subclasses

Anthropic, Google, Ollama, OpenAI

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = RCrewAI.configuration) ⇒ Base

Returns a new instance of Base.



12
13
14
15
16
17
# File 'lib/rcrewai/llm_clients/base.rb', line 12

def initialize(config = RCrewAI.configuration)
  @config = config
  @logger = Logger.new($stdout)
  @logger.level = Logger::INFO
  validate_config!
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



10
11
12
# File 'lib/rcrewai/llm_clients/base.rb', line 10

def config
  @config
end

#loggerObject (readonly)

Returns the value of attribute logger.



10
11
12
# File 'lib/rcrewai/llm_clients/base.rb', line 10

def logger
  @logger
end

Instance Method Details

#chat(messages:, tools: nil, tool_choice: :auto, stream: nil, **options) ⇒ Object

Raises:

  • (NotImplementedError)


19
20
21
# File 'lib/rcrewai/llm_clients/base.rb', line 19

def chat(messages:, tools: nil, tool_choice: :auto, stream: nil, **options)
  raise NotImplementedError, 'Subclasses must implement #chat method'
end

#complete(prompt:, **options) ⇒ Object



27
28
29
# File 'lib/rcrewai/llm_clients/base.rb', line 27

def complete(prompt:, **options)
  chat(messages: [{ role: 'user', content: prompt }], **options)
end

#supports_native_tools?(model: config.model) ⇒ Boolean

rubocop:disable Lint/UnusedMethodArgument

Returns:

  • (Boolean)


23
24
25
# File 'lib/rcrewai/llm_clients/base.rb', line 23

def supports_native_tools?(model: config.model) # rubocop:disable Lint/UnusedMethodArgument
  true
end