Module: LLM

Defined in:
lib/llm.rb,
lib/llm/error.rb,
lib/llm/message.rb,
lib/llm/version.rb,
lib/llm/response.rb,
lib/llm/http_client.rb,
lib/llm/conversation.rb,
lib/llm/message_queue.rb,
lib/llm/providers/gemini.rb,
lib/llm/providers/ollama.rb,
lib/llm/providers/openai.rb,
lib/llm/providers/voyageai.rb,
lib/llm/response/embedding.rb,
lib/llm/providers/anthropic.rb,
lib/llm/response/completion.rb

Defined Under Namespace

Modules: HTTPClient Classes: Anthropic, Conversation, Error, File, Gemini, Message, MessageQueue, Model, Ollama, OpenAI, Provider, Response, VoyageAI

Constant Summary collapse

VERSION =
"0.2.1"

Class Method Summary collapse

Class Method Details

.anthropic(secret, options = {}) ⇒ Anthropic

Returns a new instance of Anthropic.

Parameters:

  • secret (String)

    The secret key for authentication

Returns:

  • (Anthropic)

    a new instance of Anthropic



20
21
22
23
24
# File 'lib/llm.rb', line 20

def anthropic(secret, options = {})
  require_relative "llm/providers/anthropic" unless defined?(LLM::Anthropic)
  require_relative "llm/providers/voyageai" unless defined?(LLM::VoyageAI)
  LLM::Anthropic.new(secret, **options)
end

.voyageai(secret, options = {}) ⇒ VoyageAI

Returns a new instance of VoyageAI.

Parameters:

  • secret (String)

    The secret key for authentication

Returns:

  • (VoyageAI)

    a new instance of VoyageAI



29
30
31
32
# File 'lib/llm.rb', line 29

def voyageai(secret, options = {})
  require_relative "llm/providers/voyageai" unless defined?(LLM::VoyageAI)
  LLM::VoyageAI.new(secret, **options)
end

.gemini(secret, options = {}) ⇒ Gemini

Returns a new instance of Gemini.

Parameters:

  • secret (String)

    The secret key for authentication

Returns:

  • (Gemini)

    a new instance of Gemini



37
38
39
40
# File 'lib/llm.rb', line 37

def gemini(secret, options = {})
  require_relative "llm/providers/gemini" unless defined?(LLM::Gemini)
  LLM::Gemini.new(secret, **options)
end

.ollama(secret, options = {}) ⇒ Ollama

Returns a new instance of Ollama.

Returns:

  • (Ollama)

    a new instance of Ollama



45
46
47
48
# File 'lib/llm.rb', line 45

def ollama(secret, options = {})
  require_relative "llm/providers/ollama" unless defined?(LLM::Ollama)
  LLM::Ollama.new(secret, **options)
end

.openai(secret, options = {}) ⇒ OpenAI

Returns a new instance of OpenAI.

Parameters:

  • secret (String)

    The secret key for authentication

Returns:

  • (OpenAI)

    a new instance of OpenAI



53
54
55
56
# File 'lib/llm.rb', line 53

def openai(secret, options = {})
  require_relative "llm/providers/openai" unless defined?(LLM::OpenAI)
  LLM::OpenAI.new(secret, **options)
end

.File(path) ⇒ LLM::File

Parameters:

  • path (String)

    The path to a file

Returns:



64
65
66
# File 'lib/llm/file.rb', line 64

def LLM.File(path)
  LLM::File.new(path)
end