Class: Boxcars::Together

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

Overview

Engine that uses Together AI’s OpenAI-compatible API.

Constant Summary collapse

DEFAULT_PARAMS =
{
  model: "deepseek-ai/DeepSeek-R1-Distill-Llama-70B",
  temperature: 0.1,
  max_tokens: 4096
}.freeze
URI_BASE =
"https://api.together.xyz/v1"
DEFAULT_NAME =
"DeepSeek R1 Distill Llama 70B AI engine"
DEFAULT_DESCRIPTION =
"useful for when you need to use DeepSeek AI 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) ⇒ Together

Returns a new instance of Together.



18
19
20
# File 'lib/boxcars/engine/together.rb', line 18

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



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

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

Instance Method Details

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



22
23
24
# File 'lib/boxcars/engine/together.rb', line 22

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