Module: LLM
- Defined in:
- lib/llm.rb,
lib/llm/chat.rb,
lib/llm/error.rb,
lib/llm/buffer.rb,
lib/llm/message.rb,
lib/llm/version.rb,
lib/llm/response.rb,
lib/llm/response/file.rb,
lib/llm/response/audio.rb,
lib/llm/response/image.rb,
lib/llm/providers/gemini.rb,
lib/llm/providers/ollama.rb,
lib/llm/providers/openai.rb,
lib/llm/response/respond.rb,
lib/llm/response/filelist.rb,
lib/llm/providers/voyageai.rb,
lib/llm/response/embedding.rb,
lib/llm/response/modellist.rb,
lib/llm/providers/anthropic.rb,
lib/llm/response/completion.rb,
lib/llm/response/download_file.rb,
lib/llm/response/audio_translation.rb,
lib/llm/response/audio_transcription.rb
Defined Under Namespace
Modules: Utils Classes: Anthropic, Buffer, Chat, Error, File, Function, Gemini, Message, Mime, Model, Multipart, Ollama, OpenAI, Provider, Response, VoyageAI
Constant Summary collapse
- VERSION =
"0.6.1"
Class Method Summary collapse
-
.anthropic ⇒ Anthropic
A new instance of Anthropic.
- .File(path) ⇒ LLM::File
-
.function(name, &b) ⇒ LLM::Function
Define a function LLM.function(:system) do |fn| fn.description “Run system command” fn.params do |schema| schema.object(command: schema.string.required) end fn.define do |params| system(params.command) end end.
-
.functions ⇒ Hash<String,LLM::Function>
Returns all known functions.
-
.gemini ⇒ Gemini
A new instance of Gemini.
-
.ollama(key: nil) ⇒ Ollama
A new instance of Ollama.
-
.openai ⇒ OpenAI
A new instance of OpenAI.
-
.voyageai ⇒ VoyageAI
A new instance of VoyageAI.
Class Method Details
.anthropic ⇒ Anthropic
Returns a new instance of Anthropic.
26 27 28 29 30 |
# File 'lib/llm.rb', line 26 def anthropic(**) require_relative "llm/providers/anthropic" unless defined?(LLM::Anthropic) require_relative "llm/providers/voyageai" unless defined?(LLM::VoyageAI) LLM::Anthropic.new(**) end |
.File(path) ⇒ LLM::File
74 75 76 77 78 79 80 81 |
# File 'lib/llm/file.rb', line 74 def LLM.File(path) case path when LLM::File, LLM::Response::File path else LLM::File.new(path) end end |
.function(name, &b) ⇒ LLM::Function
Define a function LLM.function(:system) do |fn|
fn.description "Run system command"
fn.params do |schema|
schema.object(command: schema.string.required)
end
fn.define do |params|
system(params.command)
end
end
79 80 81 |
# File 'lib/llm.rb', line 79 def function(name, &b) functions[name.to_s] = LLM::Function.new(name, &b) end |
.functions ⇒ Hash<String,LLM::Function>
Returns all known functions
86 87 88 |
# File 'lib/llm.rb', line 86 def functions @functions ||= {} end |
.gemini ⇒ Gemini
Returns a new instance of Gemini.
43 44 45 46 |
# File 'lib/llm.rb', line 43 def gemini(**) require_relative "llm/providers/gemini" unless defined?(LLM::Gemini) LLM::Gemini.new(**) end |
.ollama(key: nil) ⇒ Ollama
Returns a new instance of Ollama.
51 52 53 54 |
# File 'lib/llm.rb', line 51 def ollama(key: nil, **) require_relative "llm/providers/ollama" unless defined?(LLM::Ollama) LLM::Ollama.new(key:, **) end |