Method AddChatProviderAdapter
- Namespace
- MailFathom.AI
- Assembly
- MailFathom.AI.dll
AddChatProviderAdapter(IServiceCollection)
Registers the adapter that produces answers by calling a chat provider, and the transport it sends over.
public static IServiceCollection AddChatProviderAdapter(this IServiceCollection services)
Parameters
servicesIServiceCollectionThe service collection to add to.
Returns
- IServiceCollection
The same service collection, so registration reads as one expression.
Remarks
The caller registers the IChatGenerationPlanSource, the scoped ChatGenerationPlan it publishes, and the IProviderEndpointCredentialSource itself, because binding configuration and resolving a secret reference both belong to the composition root. Nothing here reads configuration or knows what a secret reference is.
The client is scoped rather than a singleton because the plan it runs against is: the declaration behind it reloads, and a client built once would go on calling the model the process started with. One scope is one operation, so the plan a call uses is the one its operation began with.
Independent of AddEmbeddingProviderAdapter(IServiceCollection) in both directions, and that is the point rather than an accident of ordering. An instance may declare a chat provider and no embedding provider, or the reverse, and each of those is a working deployment with a different set of capabilities — so neither method assumes the other ran, and the client factory they share is registered by whichever one runs first.
Exceptions
- ArgumentNullException
Thrown when
servicesis null.