Class: Boxcars::Cerebras

Inherits:
Openai show all
Defined in:
lib/boxcars/engine/cerebras.rb

Overview

Engine that uses Cerebras’s OpenAI-compatible API.

Constant Summary collapse

DEFAULT_PARAMS =

The default parameters to use when asking the engine

{
  model: "llama-3.3-70b",
  temperature: 0.1,
  max_tokens: 4096
}.freeze
URI_BASE =
"https://api.cerebras.ai/v1"
DEFAULT_NAME =
"Cerebras engine"
DEFAULT_DESCRIPTION =
"useful for when you need to use Cerebras to process complex content. " \
"Supports text, images, and other content types"

Constants inherited from Openai

Openai::CHAT_MODEL_REGEX, Openai::GPT5_MODEL_REGEX, Openai::O_SERIES_REGEX

Instance Attribute Summary

Attributes inherited from Openai

#open_ai_params

Attributes inherited from Engine

#batch_size, #user_id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Openai

#capabilities, #default_params, #validate_response!

Methods inherited from Engine

#add_usage_detail!, #aggregate_generate_usage!, #aggregate_token_usage_details!, #append_generate_choices!, #capabilities, #extract_answer, #generate, #generate_one, #generation_info, #get_num_tokens, #normalize_generate_response, #process_generate_prompt!, #process_generate_response!, #run, #supports?, #usage_nested_token_value, #usage_token_value, #validate_response!

Constructor Details

#initialize(name: DEFAULT_NAME, description: DEFAULT_DESCRIPTION, batch_size: 20, **kwargs) ⇒ Cerebras

Returns a new instance of Cerebras.



19
20
21
# File 'lib/boxcars/engine/cerebras.rb', line 19

def initialize(name: DEFAULT_NAME, description: DEFAULT_DESCRIPTION, batch_size: 20, **kwargs)
  super(name:, description:, batch_size:, **DEFAULT_PARAMS.merge(kwargs))
end

Class Method Details

.provider_client(openai_access_token: nil) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/boxcars/engine/cerebras.rb', line 27

def self.provider_client(openai_access_token: nil)
  access_token = Boxcars.configuration.cerebras_api_key(cerebras_api_key: openai_access_token)
  Boxcars::OpenAIClient.build(
    access_token:,
    uri_base: URI_BASE
  )
end

Instance Method Details

#client(prompt:, inputs: {}, cerebras_api_key: nil) ⇒ Object



23
24
25
# File 'lib/boxcars/engine/cerebras.rb', line 23

def client(prompt:, inputs: {}, cerebras_api_key: nil, **)
  super(prompt:, inputs:, openai_access_token: cerebras_api_key, **)
end