How the Web Console Hosts It
In the web console, Smarter Chat is the chat of the LLMClient prompt engineering workbench, at
/workbench/llm-clients/<hashed_id>/prompt/. The workbench is the platform’s own React package,
@smarter/workbench (packages/smarter-workbench in
smarter-sh/smarter-console), which imports
SmarterChat from the @smarter.sh/ui-chat npm package, as any React application does, and puts
the developer Console beside it. It is a page of the single-page console, @smarter/console
(ADR-035, and
Django-React Integration): the console renders the
workbench’s component at the page’s route, configured from the url’s hashed id and the console’s
session.
The Page
Piece |
Role |
|---|---|
Django’s view of the path, a |
|
|
The console’s route, |
|
|
|
Exports the |
The Configuration
Field |
Value |
|---|---|
|
The LLMClient in the platform api, |
|
|
|
Django’s CSRF cookie, and the cookies’ domain, from the session, or the page’s hostname. |
|
|
|
The session’s |
|
A new id of the page’s requests, sent as the |
|
The user’s server log stream, |
|
|
|
|
|
|
|
The LLM Clients list, |
|
The cli api’s urls, with which the Manifest tab’s editor saves, validates and deletes the manifest, as every manifest page’s editor does. |
|
The |
The guided tour’s onboarding state is the console session’s too.
The Chat and the Console
The workbench passes the chat its props, and follows it with the props that
@smarter.sh/ui-chat has for a page that hosts it:
verbose: the chat fetches the configuration’s diagnostic parts, e.g. the chat session’s tool calls, only while the Console displays them, in its Tool Calls and Config tabs.onConfig: the Console displays the configuration that the chat fetched, and streams the server logs of its chat session.onNewChat: a new chat clears the Console’s server logs.onModeChange: in production mode, the Console, its button and the Help menu are hidden, and the server logs are at the server’s own level, rather than DEBUG.reloadKey: when the Manifest tab’s editor saves the manifest, the chat reloads the LLMClient’s configuration, and the chat session continues.headerActions: the workbench’s Help menu and Console button, in the chat’s header, asHeaderButtons, which look like the chat’s own. The Help menu opens and closes withuseDropdown()from@smarter/common, as the console’s user menu does, and returns the focus to its button throughHeaderButton’sref.
Changing what the chat passes to the workbench is a change in both repositories: a prop of
SmarterChat in Smarter Chat, released, and the workbench here. Changing only what the console
passes to the workbench is a change here: WorkbenchConfig in the workbench’s src/lib/types.ts,
and workbenchConfig() in the console’s src/lib/workbench.ts.
Authentication in the Workbench
The workbench and its requests are authenticated by the web console’s Django session. The chat’s
requests are sent with credentials: "include", so the browser adds the session cookie, and the chat
adds the X-CSRFToken header from the CSRF cookie. Its apiUrl is on the platform’s own domain, so
the configuration request is same-origin. The prompt request, to the LLMClient’s url_llmclient, is
also on the platform domain, under /api/v1/. The Console’s Manifest, Architecture and Deployment tabs
fetch their data from the web console’s api, with the same session, and answer 404 for an LLMClient that
the user may not read.
The configuration comes from the platform api, so its sandbox_mode is false, and its
meta_data.is_authentication_required says whether the LLMClient has an active api key; neither the
chat nor the workbench reads them. The older /workbench/llm-clients/<hashed_id>/config/ is still
served, and is the only url whose configuration has sandbox_mode true.
Builds and Static Files
The workbench is bundled by the console’s build, npm run build -w @smarter/console in
smarter-console, into dist/react/@smarter/console/, in a chunk of its own. It imports Smarter Chat’s
built library, packages/smarter.sh-chat/dist/, as npm users do, so npm run build:deps builds the
library first; smarter-console’s make build, make test and make lint run it. Each
smarter-console release ships the build, and the Smarter repository installs the release that
smarter-console-version.txt pins, with make console, into
smarter/smarter/static/react/@smarter/console/. collectstatic copies it into staticfiles,
from which it is served. To try an unreleased change, make build in smarter-console, then
make console-local CONSOLE_DIST=../smarter-console/dist in the Smarter repository.