Class: Spacy::LLMClientBase
- Inherits:
-
Object
- Object
- Spacy::LLMClientBase
- Defined in:
- lib/ruby-spacy/llm_client_base.rb
Overview
Shared HTTP layer for LLM API clients (OpenAIClient, AnthropicClient). Implements JSON POST requests with retry on rate limits (429/529) and transient network errors, using only net/http (no external dependencies).
Direct Known Subclasses
Defined Under Namespace
Classes: APIError
Constant Summary collapse
- DEFAULT_TIMEOUT =
Default request timeout in seconds
120- MAX_RETRIES =
Maximum number of retries for rate-limited requests and network errors
3- BASE_RETRY_DELAY =
Base delay in seconds for exponential backoff between retries
1
Instance Method Summary collapse
-
#initialize(base_url:, timeout: DEFAULT_TIMEOUT) ⇒ LLMClientBase
constructor
A new instance of LLMClientBase.
Constructor Details
#initialize(base_url:, timeout: DEFAULT_TIMEOUT) ⇒ LLMClientBase
Returns a new instance of LLMClientBase.
32 33 34 35 |
# File 'lib/ruby-spacy/llm_client_base.rb', line 32 def initialize(base_url:, timeout: DEFAULT_TIMEOUT) @base_url = base_url.sub(%r{/\z}, "") @timeout = timeout end |