Request Lifecycle Signals
The request lifecycle signals of a plugin’s tool call.
A tool call to a SqlPlugin, ApiPlugin, ImageSearchPlugin or SkillPlugin sends one family of
smarter.apps.llmtool.signals, in this order:
<family>_request_started, when the tool call begins.<family>_authenticatedor<family>_authentication_failed, when the plugin’s remote service accepts or rejects its credentials. Families without credentials have neither, and a response served from the cache sends neither, since nothing was authenticated.<family>_responded, with the response, or<family>_failed, with the error.<family>_request_completed, always, with whether the request succeeded and how long it took.
PluginRequest sends them, so that each plugin sends them the same way.
Example:
with PluginRequest(SQL_PLUGIN_REQUEST_SIGNALS, sender=self.__class__, plugin=self, function_args=function_args) as request:
...
request.authenticated(connection=sql_connection.name)
...
request.responded(response=retval, cached=False)
- smarter.apps.llmtool.plugin.request.API_PLUGIN_REQUEST_SIGNALS = PluginRequestSignals(started=<django.dispatch.dispatcher.Signal object>, responded=<django.dispatch.dispatcher.Signal object>, failed=<django.dispatch.dispatcher.Signal object>, completed=<django.dispatch.dispatcher.Signal object>, authenticated=<django.dispatch.dispatcher.Signal object>, authentication_failed=<django.dispatch.dispatcher.Signal object>)
The ApiPlugin request lifecycle signals.
- smarter.apps.llmtool.plugin.request.IMAGE_SEARCH_PLUGIN_REQUEST_SIGNALS = PluginRequestSignals(started=<django.dispatch.dispatcher.Signal object>, responded=<django.dispatch.dispatcher.Signal object>, failed=<django.dispatch.dispatcher.Signal object>, completed=<django.dispatch.dispatcher.Signal object>, authenticated=<django.dispatch.dispatcher.Signal object>, authentication_failed=<django.dispatch.dispatcher.Signal object>)
The ImageSearchPlugin request lifecycle signals.
- class smarter.apps.llmtool.plugin.request.PluginRequest(signals, sender, plugin, function_args=None)[source]
Bases:
objectSend a plugin family’s request lifecycle signals for one tool call.
Entering the context sends
started. Leaving it sendsfailedif an exception escapes andfailed()was not already called, and thencompleted. Exceptions are never suppressed.- Parameters:
signals (
PluginRequestSignals) – The plugin family’s signals.sender (
type) – The signals’ sender, usually the plugin’s class.plugin (
PluginBase) – The plugin, which every signal sends.function_args (
dict[str,Any] |list|str|None) – The tool call’s arguments, whichstartedsends.
- authenticated(**kwargs)[source]
Send
authenticated, with the plugin andkwargs, if the family has credentials.- Return type:
- authentication_failed(error, **kwargs)[source]
Send
authentication_failed, with the plugin, the error andkwargs, if the family has credentials.
- cached
Set by the plugin, when its response was served from the cache.
- class smarter.apps.llmtool.plugin.request.PluginRequestSignals(started, responded, failed, completed, authenticated=None, authentication_failed=None)[source]
Bases:
objectOne plugin family’s request lifecycle signals.
- Variables:
started – Sent when a tool call begins.
responded – Sent with the response.
failed – Sent with the error, if the tool call fails.
completed – Sent when the tool call ends, successfully or not.
authenticated – Sent when the remote service accepts the plugin’s credentials. None if the family has no credentials.
authentication_failed – Sent when the remote service rejects them. None if the family has no credentials.
- __init__(started, responded, failed, completed, authenticated=None, authentication_failed=None)
- completed: Signal
- failed: Signal
- responded: Signal
- started: Signal
- smarter.apps.llmtool.plugin.request.SKILL_PLUGIN_REQUEST_SIGNALS = PluginRequestSignals(started=<django.dispatch.dispatcher.Signal object>, responded=<django.dispatch.dispatcher.Signal object>, failed=<django.dispatch.dispatcher.Signal object>, completed=<django.dispatch.dispatcher.Signal object>, authenticated=None, authentication_failed=None)
The SkillPlugin request lifecycle signals.
A SkillPlugin’s tool call reads its stored skill, so it has no credentials.
- smarter.apps.llmtool.plugin.request.SQL_PLUGIN_REQUEST_SIGNALS = PluginRequestSignals(started=<django.dispatch.dispatcher.Signal object>, responded=<django.dispatch.dispatcher.Signal object>, failed=<django.dispatch.dispatcher.Signal object>, completed=<django.dispatch.dispatcher.Signal object>, authenticated=<django.dispatch.dispatcher.Signal object>, authentication_failed=<django.dispatch.dispatcher.Signal object>)
The SqlPlugin request lifecycle signals.