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, SmarterAuthenticatedListAPIView

The user’s chat sessions: PromptHistoryApiSession models.

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: SmarterAuthenticatedAPIView

One of the user’s chat sessions, by its id: a PromptHistoryApiSession.

get(request, *args, **kwargs)[source]
class smarter.apps.prompt.api.v1.views.history.ChatToolCallHistoryListView(*args, **kwargs)[source]

Bases: ContractListMixin, SmarterAuthenticatedListAPIView

The tool calls of the user’s chat sessions: PromptHistoryApiToolCall models.

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: SmarterAuthenticatedAPIView

A tool call of the user’s chat sessions: a PromptHistoryApiToolCall.

get(request, *args, **kwargs)[source]
class smarter.apps.prompt.api.v1.views.history.PluginUsageHistoryListView(*args, **kwargs)[source]

Bases: ContractListMixin, SmarterAuthenticatedListAPIView

The plugin usage of the user’s chat sessions: PromptHistoryApiPluginUsage models.

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 canDelete is the requesting user’s.

serializer_class

alias of PromptPluginUsageSerializer

class smarter.apps.prompt.api.v1.views.history.PluginUsageHistoryView(*args, **kwargs)[source]

Bases: SmarterAuthenticatedAPIView

A plugin usage of the user’s chat sessions: a PromptHistoryApiPluginUsage.

get(request, *args, **kwargs)[source]
smarter.apps.prompt.api.v1.views.history.plugin_usage_for_user(user)[source]

The plugin usage of the chat sessions whose user user may manage, newest first.

Parameters:

user (django.contrib.auth.models.User) – The requesting user.

Returns:

The plugin usage, with their sessions and plugins.

Return type:

QuerySet

smarter.apps.prompt.api.v1.views.history.sessions_for_user(user)[source]

The chat sessions whose user user may manage, newest first.

Parameters:

user (django.contrib.auth.models.User) – The requesting user.

Returns:

The sessions.

Return type:

QuerySet

smarter.apps.prompt.api.v1.views.history.tool_calls_for_user(user)[source]

The tool calls of the chat sessions whose user user may manage, newest first.

Parameters:

user (django.contrib.auth.models.User) – The requesting user.

Returns:

The tool calls, with their sessions.

Return type:

QuerySet