Class: HermesAgent::Client
- Inherits:
-
Object
- Object
- HermesAgent::Client
- Defined in:
- lib/hermes_agent/client.rb,
lib/hermes_agent/client/util.rb,
lib/hermes_agent/client/entity.rb,
lib/hermes_agent/client/errors.rb,
lib/hermes_agent/client/stream.rb,
lib/hermes_agent/client/version.rb,
lib/hermes_agent/client/transport.rb,
lib/hermes_agent/client/conversation.rb,
lib/hermes_agent/client/entities/job.rb,
lib/hermes_agent/client/entities/run.rb,
lib/hermes_agent/client/configuration.rb,
lib/hermes_agent/client/entities/model.rb,
lib/hermes_agent/client/resources/chat.rb,
lib/hermes_agent/client/resources/jobs.rb,
lib/hermes_agent/client/resources/runs.rb,
lib/hermes_agent/client/entities/health.rb,
lib/hermes_agent/client/resources/health.rb,
lib/hermes_agent/client/resources/models.rb,
lib/hermes_agent/client/entities/response.rb,
lib/hermes_agent/client/resources/responses.rb,
lib/hermes_agent/client/entities/capabilities.rb,
lib/hermes_agent/client/resources/capabilities.rb,
lib/hermes_agent/client/entities/chat_completion.rb,
lib/hermes_agent/client/entities/session_headers.rb
Overview
A client for the Hermes API server.
Construct a client with the server location and credentials, then reach endpoints through resource accessors such as #health.
client = HermesAgent::Client.new(base_url: "http://127.0.0.1:8642")
client.health.check.status # => "ok"
Note this class is not thread-safe. When using in a multithreaded application, you should create a separate client object per thread.
Defined Under Namespace
Modules: Entities, Resources Classes: APIError, AuthenticationError, BadRequestError, Configuration, ConnectionError, Conversation, Entity, Error, MalformedResponseError, NotFoundError, PermissionError, RateLimitError, ServerError, Stream, TimeoutError
Constant Summary collapse
- VERSION =
Version of the hermes-client gem
"0.1.0"
Instance Attribute Summary collapse
-
#config ⇒ Configuration
readonly
The configuration this client was built with.
Instance Method Summary collapse
-
#capabilities ⇒ Resources::Capabilities
The capabilities resource (the server's advertised endpoints and feature matrix).
-
#chat ⇒ Resources::Chat
The chat resource (OpenAI-compatible chat completions).
-
#health ⇒ Resources::Health
The health resource (server health checks).
-
#initialize(base_url: Configuration::DEFAULT_BASE_URL, api_key: UNSET, read_timeout: nil, open_timeout: nil, write_timeout: nil, keep_alive_timeout: Configuration::DEFAULT_KEEP_ALIVE_TIMEOUT) {|config| ... } ⇒ Client
constructor
Create a client.
-
#jobs ⇒ Resources::Jobs
The jobs resource (the Jobs API, for scheduled background work).
-
#models ⇒ Resources::Models
The models resource (discovery of advertised models).
-
#responses ⇒ Resources::Responses
The responses resource (the Responses API, with server-side conversation state).
-
#runs ⇒ Resources::Runs
The runs resource (the Runs API, for long-running server-side agent runs).
Constructor Details
#initialize(base_url: Configuration::DEFAULT_BASE_URL, api_key: UNSET, read_timeout: nil, open_timeout: nil, write_timeout: nil, keep_alive_timeout: Configuration::DEFAULT_KEEP_ALIVE_TIMEOUT) {|config| ... } ⇒ Client
Create a client.
Settings may be supplied as keyword arguments, by yielding the Configuration to a block, or both (the block runs after the keyword arguments are applied).
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/hermes_agent/client.rb', line 58 def initialize(base_url: Configuration::DEFAULT_BASE_URL, api_key: UNSET, read_timeout: nil, open_timeout: nil, write_timeout: nil, keep_alive_timeout: Configuration::DEFAULT_KEEP_ALIVE_TIMEOUT) @config = Configuration.new(base_url: base_url, read_timeout: read_timeout, open_timeout: open_timeout, write_timeout: write_timeout, keep_alive_timeout: keep_alive_timeout) @config.api_key = api_key unless api_key.equal?(UNSET) yield @config if block_given? @transport = Transport.new(@config) end |
Instance Attribute Details
#config ⇒ Configuration (readonly)
The configuration this client was built with.
76 77 78 |
# File 'lib/hermes_agent/client.rb', line 76 def config @config end |
Instance Method Details
#capabilities ⇒ Resources::Capabilities
The capabilities resource (the server's advertised endpoints and feature matrix).
83 84 85 |
# File 'lib/hermes_agent/client.rb', line 83 def capabilities @capabilities ||= Resources::Capabilities.new(@transport) end |
#chat ⇒ Resources::Chat
The chat resource (OpenAI-compatible chat completions).
91 92 93 |
# File 'lib/hermes_agent/client.rb', line 91 def chat @chat ||= Resources::Chat.new(@transport) end |
#health ⇒ Resources::Health
The health resource (server health checks).
99 100 101 |
# File 'lib/hermes_agent/client.rb', line 99 def health @health ||= Resources::Health.new(@transport) end |
#jobs ⇒ Resources::Jobs
The jobs resource (the Jobs API, for scheduled background work).
107 108 109 |
# File 'lib/hermes_agent/client.rb', line 107 def jobs @jobs ||= Resources::Jobs.new(@transport) end |
#models ⇒ Resources::Models
The models resource (discovery of advertised models).
115 116 117 |
# File 'lib/hermes_agent/client.rb', line 115 def models @models ||= Resources::Models.new(@transport) end |
#responses ⇒ Resources::Responses
The responses resource (the Responses API, with server-side conversation state).
124 125 126 |
# File 'lib/hermes_agent/client.rb', line 124 def responses @responses ||= Resources::Responses.new(@transport) end |
#runs ⇒ Resources::Runs
The runs resource (the Runs API, for long-running server-side agent runs).
133 134 135 |
# File 'lib/hermes_agent/client.rb', line 133 def runs @runs ||= Resources::Runs.new(@transport) end |