Clarify OpenAI client timeout precedence
This commit is contained in:
@@ -20,12 +20,17 @@ fields:
|
||||
| `PromptDir` | Prompt-definition directory, required unless a prompt source option is supplied. |
|
||||
| `ProfileDir` | Optional custom profile directory over built-ins. |
|
||||
| `SchemaDir` | Schema directory; empty uses `.`. |
|
||||
| `Timeout` | Default timeout for the built-in OpenAI-compatible client. |
|
||||
| `HTTPClient` | Optional HTTP client for that built-in client. |
|
||||
| `Timeout` | Base timeout for the built-in OpenAI-compatible client when `HTTPClient` is absent or has a zero timeout. A non-positive value uses the internal default. |
|
||||
| `HTTPClient` | Optional HTTP client for that built-in client. It is cloned; a non-zero `Timeout` on it takes precedence over `Config.Timeout` as the base timeout. |
|
||||
|
||||
Nil options are ignored. Invalid construction, including
|
||||
`WithLLMClient(nil)`, returns an error matching `ErrInvalidConfig`.
|
||||
|
||||
An effective positive `timeout_seconds` replaces the base timeout. An explicit
|
||||
request override of zero disables the HTTP-client timeout. The timeout is
|
||||
otherwise inherited from the supplied client, `Config.Timeout`, or the internal
|
||||
default in that order.
|
||||
|
||||
Source options replace their matching directory source:
|
||||
|
||||
- prompts: `WithPromptFS(fsys, root)`, `WithPromptFile(path)`;
|
||||
|
||||
@@ -77,9 +77,12 @@ resolves the configured non-empty `api_key_env` at request time and sends the
|
||||
same header. If neither mechanism supplies a key, it sends no
|
||||
`Authorization` header.
|
||||
|
||||
The configured client timeout applies by default. A positive effective
|
||||
`timeout_seconds` replaces it. An explicit request override of zero disables
|
||||
the HTTP-client timeout; negative values are rejected before a request is sent.
|
||||
The client base timeout is chosen at construction: a non-zero timeout on a
|
||||
supplied `http.Client` takes precedence over `Config.Timeout`; otherwise a
|
||||
positive `Config.Timeout` is used, then the internal default. A positive
|
||||
effective `timeout_seconds` replaces that base. An explicit request override
|
||||
of zero disables the HTTP-client timeout; negative values are rejected before a
|
||||
request is sent.
|
||||
|
||||
## Response Subset And Failures
|
||||
|
||||
|
||||
@@ -10,13 +10,14 @@ format and protocol behavior.
|
||||
## Construction
|
||||
|
||||
`NewOpenAICompatibleClient` validates a non-empty configured base URL, records
|
||||
an optional default model, and establishes the default timeout. A non-positive
|
||||
configured timeout uses the internal default.
|
||||
an optional default model, and resolves one base timeout. A supplied client with
|
||||
a non-zero timeout supplies that base; otherwise a positive configured timeout
|
||||
is used, then the internal default.
|
||||
|
||||
When callers supply an `http.Client`, construction clones it rather than
|
||||
mutating the caller's instance. A supplied client with no timeout receives the
|
||||
resolved default in the clone; a supplied non-zero timeout is retained. The
|
||||
client stores the trimmed base URL, default model, timeout, and cloned client.
|
||||
resolved base timeout in the clone. The client stores the trimmed base URL,
|
||||
default model, and cloned client.
|
||||
|
||||
## Generate Flow
|
||||
|
||||
@@ -28,7 +29,7 @@ client stores the trimmed base URL, default model, timeout, and cloned client.
|
||||
request;
|
||||
4. prefer a direct API key, otherwise resolve the configured key environment
|
||||
variable;
|
||||
5. derive a request HTTP client when an explicit timeout changes the configured
|
||||
5. derive a request HTTP client only when an explicit timeout changes the base
|
||||
client;
|
||||
6. execute the request, reject non-success status responses without returning
|
||||
provider response bodies; and
|
||||
|
||||
Reference in New Issue
Block a user