History
Prompt history views for smarter api.
They are mounted at /api/v1/prompts/history/, and return the chat sessions, tool calls and
plugin usage of the sessions whose user the requesting user may manage, as the models of
smarter.apps.prompt.contract.history: their own sessions, the sessions of their account’s
users for an account admin, and every session for a superuser. A session holds a user’s
conversation, so a user never reads another account’s, nor the platform’s.
- class smarter.apps.prompt.api.v1.views.history.ChatHistoryListView(*args, **kwargs)[source]
Bases:
ContractListMixin,SmarterAuthenticatedListAPIViewThe user’s chat sessions:
PromptHistoryApiSessionmodels.- contract_model
alias of
PromptHistoryApiSession
- get_queryset()[source]
Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.
This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.
You may want to override this if you need to provide different querysets depending on the incoming request.
(Eg. return a list of items that is specific to the user)
- serializer_class
alias of
PromptSerializer
- class smarter.apps.prompt.api.v1.views.history.ChatHistoryView(*args, **kwargs)[source]
Bases:
SmarterAuthenticatedAPIViewOne of the user’s chat sessions, by its id: a
PromptHistoryApiSession.
- class smarter.apps.prompt.api.v1.views.history.ChatToolCallHistoryListView(*args, **kwargs)[source]
Bases:
ContractListMixin,SmarterAuthenticatedListAPIViewThe tool calls of the user’s chat sessions:
PromptHistoryApiToolCallmodels.- contract_model
alias of
PromptHistoryApiToolCall
- get_queryset()[source]
Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.
This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.
You may want to override this if you need to provide different querysets depending on the incoming request.
(Eg. return a list of items that is specific to the user)
- serializer_class
alias of
PromptToolCallSerializer
- class smarter.apps.prompt.api.v1.views.history.ChatToolCallHistoryView(*args, **kwargs)[source]
Bases:
SmarterAuthenticatedAPIViewA tool call of the user’s chat sessions: a
PromptHistoryApiToolCall.
- class smarter.apps.prompt.api.v1.views.history.PluginUsageHistoryListView(*args, **kwargs)[source]
Bases:
ContractListMixin,SmarterAuthenticatedListAPIViewThe plugin usage of the user’s chat sessions:
PromptHistoryApiPluginUsagemodels.- contract_model
alias of
PromptHistoryApiPluginUsage
- get_queryset()[source]
Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.
This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.
You may want to override this if you need to provide different querysets depending on the incoming request.
(Eg. return a list of items that is specific to the user)
- item(row)[source]
A plugin usage of the response, whose plugin’s
canDeleteis the requesting user’s.
- serializer_class
alias of
PromptPluginUsageSerializer
- class smarter.apps.prompt.api.v1.views.history.PluginUsageHistoryView(*args, **kwargs)[source]
Bases:
SmarterAuthenticatedAPIViewA plugin usage of the user’s chat sessions: a
PromptHistoryApiPluginUsage.
- smarter.apps.prompt.api.v1.views.history.plugin_usage_for_user(user)[source]
The plugin usage of the chat sessions whose user
usermay manage, newest first.- Parameters:
user (django.contrib.auth.models.User) – The requesting user.
- Returns:
The plugin usage, with their sessions and plugins.
- Return type:
- smarter.apps.prompt.api.v1.views.history.sessions_for_user(user)[source]
The chat sessions whose user
usermay manage, newest first.- Parameters:
user (django.contrib.auth.models.User) – The requesting user.
- Returns:
The sessions.
- Return type:
- smarter.apps.prompt.api.v1.views.history.tool_calls_for_user(user)[source]
The tool calls of the chat sessions whose user
usermay manage, newest first.- Parameters:
user (django.contrib.auth.models.User) – The requesting user.
- Returns:
The tool calls, with their sessions.
- Return type: