Class: LLM::Provider
Overview
The Provider class represents an abstract class for LLM (Language Model) providers
Instance Method Summary collapse
-
#chat(prompt, role = :user, **params) ⇒ LLM::LazyConversation
Starts a new lazy conversation.
-
#chat!(prompt, role = :user, **params) ⇒ LLM::Conversation
Starts a new conversation.
-
#complete(prompt, role = :user, **params) ⇒ LLM::Response::Completion
Completes a given prompt using the LLM.
- #embed(input, **params) ⇒ LLM::Response::Embedding
-
#initialize(secret, host:, port: 443, ssl: true) ⇒ Provider
constructor
A new instance of Provider.
-
#inspect ⇒ String
Returns an inspection of the provider object.
Methods included from HTTPClient
Constructor Details
#initialize(secret, host:, port: 443, ssl: true) ⇒ Provider
Returns a new instance of Provider.
17 18 19 20 21 22 |
# File 'lib/llm/provider.rb', line 17 def initialize(secret, host:, port: 443, ssl: true) @secret = secret @http = Net::HTTP.new(host, port).tap do |http| http.use_ssl = ssl end end |
Instance Method Details
#chat(prompt, role = :user, **params) ⇒ LLM::LazyConversation
Starts a new lazy conversation
61 62 63 |
# File 'lib/llm/provider.rb', line 61 def chat(prompt, role = :user, **params) LazyConversation.new(self).chat(prompt, role, **params) end |
#chat!(prompt, role = :user, **params) ⇒ LLM::Conversation
Starts a new conversation
71 72 73 |
# File 'lib/llm/provider.rb', line 71 def chat!(prompt, role = :user, **params) Conversation.new(self).chat(prompt, role, **params) end |
#complete(prompt, role = :user, **params) ⇒ LLM::Response::Completion
Completes a given prompt using the LLM
51 52 53 |
# File 'lib/llm/provider.rb', line 51 def complete(prompt, role = :user, **params) raise NotImplementedError end |
#embed(input, **params) ⇒ LLM::Response::Embedding
38 39 40 |
# File 'lib/llm/provider.rb', line 38 def (input, **params) raise NotImplementedError end |
#inspect ⇒ String
Note:
The secret key is redacted in inspect for security reasons
Returns an inspection of the provider object
28 29 30 |
# File 'lib/llm/provider.rb', line 28 def inspect "#<#{self.class.name}:0x#{object_id.to_s(16)} @secret=[REDACTED] @http=#{@http.inspect}>" end |