Providers
A chat provider convenience class. This class is a collection of all the chat providers and their handlers. It also provides a default provider and handler.
There are a few objectives of this class: 1. To provide a single point of access to all the chat providers. 2. To hide complexity introduced into the provider classes due to Pydantic models. 3. To provide a default provider and handler.
- smarter.apps.provider.services.text_completion.providers.CACHE_TIMEOUT = 10
Cache timeout in seconds for chat providers. This is to allow for short-term caching of provider instances. For now, this only benefits inner-process calls that lead to multiple instantiatiaons of the same provider within a short time frame.
However, the objective to to increase the cache timeout as observed usage patterns emerge that are confirmed to be cache safe.
- class smarter.apps.provider.services.text_completion.providers.ClientTypeEnum(*values)[source]
Bases:
SmarterEnumAbstractClient type distinguishes between the kind of handler we want from the provider.
- PASSTHROUGH = 'OpenAIPassthroughClient'
- SMARTER = 'OpenAISmarterClient'
- class smarter.apps.provider.services.text_completion.providers.OpenAICompatibleClientFactory(client_type=ClientTypeEnum.SMARTER)[source]
Bases:
SmarterHelperMixinA newer version of the OpenAICompatiblePassthroughChatProviders class.
- property client_type: ClientTypeEnum
- default_handler(request, **kwargs)[source]
A convenience method to get the default handler.
- Return type:
Union[SmarterChatHandlerProtocol,OpenAICompatiblePassthroughProtocol]
- property default_handler_name: str[source]
Returns the name of the platform-wide default provider. If no default provider is found, it raises a SmarterValueError.
- get_passthrough_handler(request, provider_name=None, **kwargs)[source]
Instantiates a OpenAIPassthroughClient for the given provider name and returns its passthrough handler. The key thing is that whatever handler we use here must implement the OpenAICompatiblePassthroughProtocol.
- Return type:
OpenAICompatiblePassthroughProtocol