Adding a New LLM Provider
To add support for a new LLM provider, you need to implement several components:- Message Format Adapter: Implements
CanMapMessagesto convert Polyglot’s message format to the provider’s format - Body Format Adapter: Implements
CanMapRequestBodyto structure the request body according to the provider’s API - Request Adapter: Implements
ProviderRequestAdapterto build HTTP requests for the provider - Response Adapter: Implements
ProviderResponseAdapterto parse responses from the provider - Usage Format Adapter: Implements
CanMapUsageto extract token usage information
InferenceDriverFactory to create the appropriate driver for your provider:
make method’s match statement.
Adding a New Embeddings Provider
Similarly, to add a new embeddings provider, implement theCanVectorize interface:
Embeddings class to create your driver: