Module: LLM
- Defined in:
- lib/llm.rb,
lib/llm/bot.rb,
lib/llm/error.rb,
lib/llm/buffer.rb,
lib/llm/message.rb,
lib/llm/version.rb,
lib/llm/response.rb,
lib/llm/eventhandler.rb,
lib/llm/providers/gemini.rb,
lib/llm/providers/ollama.rb,
lib/llm/providers/openai.rb,
lib/llm/providers/deepseek.rb,
lib/llm/providers/llamacpp.rb,
lib/llm/providers/anthropic.rb
Defined Under Namespace
Classes: Anthropic, Bot, Buffer, DeepSeek, Error, File, Function, Gemini, LlamaCpp, Message, Object, Ollama, OpenAI, Provider, Response, ResponseError
Constant Summary collapse
Class.new(ResponseError)
- RateLimitError =
HTTPTooManyRequests
Class.new(ResponseError)
- FormatError =
When an given an input object that is not understood
Class.new(Error)
- PromptError =
When given a prompt object that is not understood
Class.new(FormatError)
- VERSION =
"0.11.0"
Class Method Summary collapse
-
.File(obj) ⇒ LLM::File
-
.gemini ⇒ Gemini
A new instance of Gemini.
-
.ollama(key: nil) ⇒ Ollama
A new instance of Ollama.
-
.llamacpp(key: nil) ⇒ LLM::LlamaCpp
-
.deepseek ⇒ LLM::DeepSeek
-
.openai ⇒ OpenAI
A new instance of OpenAI.
-
.function(name, &b) ⇒ LLM::Function
Define a function.
-
.functions ⇒ Hash<String,LLM::Function>
Returns all known functions.
-
.anthropic ⇒ Anthropic
A new instance of Anthropic.
Class Method Details
.File(obj) ⇒ LLM::File
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/llm/file.rb', line 82 def LLM.File(obj) case obj when File obj.close unless obj.closed? LLM.File(obj.path) when LLM::File, LLM::Response then obj when String then LLM::File.new(obj) else raise TypeError, "don't know how to handle #{obj.class} objects" end end |
.gemini ⇒ Gemini
Returns a new instance of Gemini.
35 36 37 38 |
# File 'lib/llm.rb', line 35 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.
43 44 45 46 |
# File 'lib/llm.rb', line 43 def ollama(key: nil, **) require_relative "llm/providers/ollama" unless defined?(LLM::Ollama) LLM::Ollama.new(key:, **) end |
.llamacpp(key: nil) ⇒ LLM::LlamaCpp
51 52 53 54 |
# File 'lib/llm.rb', line 51 def llamacpp(key: nil, **) require_relative "llm/providers/llamacpp" unless defined?(LLM::LlamaCpp) LLM::LlamaCpp.new(key:, **) end |
.deepseek ⇒ LLM::DeepSeek
59 60 61 62 |
# File 'lib/llm.rb', line 59 def deepseek(**) require_relative "llm/providers/deepseek" unless defined?(LLM::DeepSeek) LLM::DeepSeek.new(**) end |
.openai ⇒ OpenAI
Returns a new instance of OpenAI.
67 68 69 70 |
# File 'lib/llm.rb', line 67 def openai(**) require_relative "llm/providers/openai" unless defined?(LLM::OpenAI) LLM::OpenAI.new(**) end |
.function(name, &b) ⇒ LLM::Function
Define a function
87 88 89 |
# File 'lib/llm.rb', line 87 def function(name, &b) functions[name.to_s] = LLM::Function.new(name, &b) end |
.functions ⇒ Hash<String,LLM::Function>
Returns all known functions
94 95 96 |
# File 'lib/llm.rb', line 94 def functions @functions ||= {} end |