Class: Langchain::LLM::Base Abstract

Inherits:
Object
  • Object
show all
Includes:
DependencyHelper
Defined in:
lib/langchain/llm/base.rb

Overview

This class is abstract.

A LLM is a language model consisting of a neural network with many parameters (typically billions of weights or more), trained on large quantities of unlabeled text using self-supervised learning or semi-supervised learning.

Langchain.rb provides a common interface to interact with all supported LLMs:

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DependencyHelper

#depends_on

Instance Attribute Details

#clientObject (readonly)

A client for communicating with the LLM



25
26
27
# File 'lib/langchain/llm/base.rb', line 25

def client
  @client
end

Instance Method Details

#chatObject

Generate a chat completion for a given prompt. Parameters will depend on the LLM

Raises:

  • NotImplementedError if not supported by the LLM



35
36
37
# File 'lib/langchain/llm/base.rb', line 35

def chat(...)
  raise NotImplementedError, "#{self.class.name} does not support chat"
end

#completeObject

Generate a completion for a given prompt. Parameters will depend on the LLM.

Raises:

  • NotImplementedError if not supported by the LLM



43
44
45
# File 'lib/langchain/llm/base.rb', line 43

def complete(...)
  raise NotImplementedError, "#{self.class.name} does not support completion"
end

#default_dimensionsObject



27
28
29
# File 'lib/langchain/llm/base.rb', line 27

def default_dimensions
  self.class.const_get(:DEFAULTS).dig(:dimensions)
end

#embedObject

Generate an embedding for a given text. Parameters depends on the LLM.

Raises:

  • NotImplementedError if not supported by the LLM



52
53
54
# File 'lib/langchain/llm/base.rb', line 52

def embed(...)
  raise NotImplementedError, "#{self.class.name} does not support generating embeddings"
end

#summarizeObject

Generate a summary for a given text. Parameters depends on the LLM.

Raises:

  • NotImplementedError if not supported by the LLM



61
62
63
# File 'lib/langchain/llm/base.rb', line 61

def summarize(...)
  raise NotImplementedError, "#{self.class.name} does not support summarization"
end