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.prompt.providers.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.prompt.providers.providers.ChatProviders(*args, **kwargs)[source]
Bases:
SmarterHelperMixinCollection of all the chat providers.
- property all_handlers: Dict[str, HandlerProtocol]
A dictionary of all the handler callables. handlers must conform to HandlerProtocol.
- property default: OpenAIChatProvider
- default_handler(user, chat, data, plugins=None, functions=None)[source]
Expose the handler method of the default provider
- get_handler(provider=None)[source]
A convenience method to get a handler by provider name.
- Return type:
- property googleai: GoogleAIChatProvider
- googleai_handler(user, chat, data, plugins=None, functions=None)[source]
Expose the handler method of the googleai provider
- property metaai: MetaAIChatProvider
- metaai_handler(user, chat, data, plugins=None, functions=None)[source]
Expose the handler method of the metaai provider
- property openai: OpenAIChatProvider