Workbench Page and Prompt Session

The Prompt Engineer’s Workbench’s page, PromptWorkbenchView, and the chat’s prompt session.

SmarterPromptSession is the chat session of a prompt, which the chat’s configuration api, PromptConfigView, creates or resumes.

class smarter.apps.prompt.views.detailviews.prompt_workbench_view.PromptWorkbenchView(**kwargs)[source]

Bases: ConsoleAppView

The Prompt Engineer’s Workbench of an LLMClient, /workbench/llm-clients/<hashed_id>/prompt/: the single-page.

console’s page (ADR-035).

The console renders @smarter/workbench, the chat with the LLMClient, Smarter Chat (the @smarter.sh/ui-chat npm package), and the developer Console beside it, configured from the hashed id and the console’s session: the chat reads its configuration from the public api, /api/v1/llm-clients/<hashed_id>/config/ (PromptConfigView), and the Console’s tabs call the web console’s api, /api/web/prompt/llm-clients/<hashed_id>/. The console first asks the resource api for the LLMClient, and shows Page not found to a user who may not read it. Django keeps this view at the path it served the page at, so that its url name, and LLMClient.workbench_url, still reverse.

exception smarter.apps.prompt.views.detailviews.prompt_workbench_view.SmarterChatappViewError(message='')[source]

Bases: SmarterException

Base class for all SmarterChatapp errors.

property get_formatted_err_message

The fixed error message prefix of the chatapp views.

class smarter.apps.prompt.views.detailviews.prompt_workbench_view.SmarterPromptSession(request, session_key, *args, llmclient=None, **kwargs)[source]

Bases: SmarterHelperMixin

Helper class that provides methods for creating a session key and client key.

__init__(request, session_key, *args, llmclient=None, **kwargs)[source]

Note: this needs to exist; something in the Python MRO requires it, even if it does nothing.

If you remove this, you will get a mysterious error about something downstream expecting exactly one object.

property chat_helper

The PromptHelper of the session.

clean_url(url)[source]

Clean the url of any query strings and trailing ‘/config/’ strings.

Return type:

str

property formatted_class_name: str

Returns a formatted string of the class name for logging purposes.

property llmclient

The LLMClient of the session.

property prompt

The Prompt of the session.

request: HttpRequest | None = None
property session_key: str

The session key for this prompt session.

This is used to identify the prompt session and is generated by the /config/ endpoint.

smarter.apps.prompt.views.detailviews.prompt_workbench_view.should_log(level)[source]

Check if logging should be done based on the waffle switch.

smarter.apps.prompt.views.detailviews.prompt_workbench_view.should_log_verbose(level)[source]

Check if logging should be done based on the waffle switch.