Module: LlmClient
- Extended by:
- Forwardable
- Defined in:
- lib/llm_client.rb,
lib/llm_client/util.rb,
lib/llm_client/errors.rb,
lib/llm_client/version.rb,
lib/llm_client/http_client.rb,
lib/llm_client/configuration.rb
Overview
A module representing an LLM client.
This module provides methods to interact with the LLM Server using an HTTP client. It can be configured with a host, a Ruby logger, a log level, and provides methods to forward heartbeat and completion requests to the HTTP client.
Examples
LlmClient.host = "http://localhost:9292"
LlmClient.logger = Logger.new(STDOUT)
LlmClient.log_level = LlmClient::LEVEL_DEBUG
If logger is present and log level not set, it is LlmClientL::LEVEL_INFO by default.
After LlmClient module configuration you can interact wiht the LLM Server.
Examples
result = LlmClient.heartbeat
if result.success?
puts "Server is running"
response = result.success
puts "Status: #{response.status}"
puts "Body: #{response.body}"
puts "Headers: #{response.headers}"
else
puts "Server is not responding"
error = result.failure
puts "Error: #{error}"
end
response = LlmClient.completion("Who is the creator of Ruby language?")
if result.success?
puts "Completions generated successfully"
response = result.success
puts "Status: #{response.status}"
puts "Body: #{response.body}"
puts "Headers: #{response.headers}"
calculated_response = response.body[:response]
puts "Calculated Response: #{calculated_response}"
else
puts "Failed to generate completions"
error = result.failure
puts "Error: #{error}"
end
Defined Under Namespace
Modules: Util Classes: Configuration, ConnectionError, HttpClient, Response
Constant Summary collapse
- LEVEL_DEBUG =
map to the same values as the standard library’s logger
Logger::DEBUG
- LEVEL_ERROR =
Logger::ERROR
- LEVEL_INFO =
Logger::INFO
- VERSION =
"0.1.2"
Class Attribute Summary collapse
-
.config ⇒ Object
readonly
Returns the value of attribute config.
-
.http_client ⇒ Object
readonly
Returns the value of attribute http_client.
Class Attribute Details
.config ⇒ Object (readonly)
Returns the value of attribute config.
76 77 78 |
# File 'lib/llm_client.rb', line 76 def config @config end |
.http_client ⇒ Object (readonly)
Returns the value of attribute http_client.
76 77 78 |
# File 'lib/llm_client.rb', line 76 def http_client @http_client end |