Class HttpProviderBase
- Namespace
- IntentSharp.Providers
- Assembly
- IntentSharp.dll
Shared plumbing for HTTP-based providers: request posting, status-code mapping, bounded retries with exponential backoff, and cancellation. Subclasses only translate to and from their wire format.
public abstract class HttpProviderBase : IAIProvider, IDisposable
- Inheritance
-
objectHttpProviderBase
- Implements
-
IDisposable
- Derived
- Inherited Members
-
object.Equals(object)object.Equals(object, object)object.GetHashCode()object.GetType()object.MemberwiseClone()object.ReferenceEquals(object, object)object.ToString()
- Extension Methods
Constructors
- HttpProviderBase(HttpProviderSettings, HttpClient?, Uri, ILogger?)
Validates the settings and prepares the HTTP client.
Fields
- JsonOptions
The options request bodies are written with. Read-only, so a subclass cannot change them for every provider.
- Logger
The logger given to the constructor, or a logger that discards everything.
- Settings
The settings this provider was created with.
Properties
- DefaultModel
The model from the settings, used when a request names none.
- Name
Stable provider name used in results, rate limiting and logs (for example "OpenAI").
- SupportsEmbeddings
True when EmbedAsync(string, CancellationToken) is implemented.
Methods
- Authenticate(HttpRequestMessage)
Adds provider authentication headers to an outgoing request.
- CompleteAsync(AIRequest, CancellationToken)
Sends a chat-style request and returns the model's reply.
- Dispose()
Disposes the HTTP client when the provider created it. A client passed to the constructor is left open.
- EmbedAsync(string, CancellationToken)
Returns an embedding vector for the text. Throws NotSupportedException when SupportsEmbeddings is false.
- IsMalformedReply(Exception)
True for the exceptions JsonElement throws when a reply lacks the expected shape: a missing property (KeyNotFoundException), a value of the wrong kind (InvalidOperationException), an empty array (IndexOutOfRangeException) or a number out of range (FormatException).
- MalformedReply(Exception)
A transient AIProviderException for a success reply that lacks the expected shape, with the parse failure as the inner exception, so the client records a provider issue or falls back instead of letting it escape.
- PostJsonAsync(string, object, CancellationToken)
Posts JSON and returns the parsed response document. Maps non-success status codes to typed exceptions and retries transient ones. A success status whose body is not JSON (a proxy's HTML page, for example) throws a transient AIProviderException carrying that status and the parse error as the inner exception; it is not retried.
- Truncate(string, int)
Returns
sunchanged when it has at mostmaxcharacters, otherwise its firstmaxcharacters followed by "...".