Prompt Architecture View

The Prompt Engineer’s Workbench’s Architecture tab: an LLMClient’s tree of SAM resources, and its contract.

LLMClientArchitectureView returns an llmclient’s architecture, for the “Architecture” tab of the workbench’s Console.

The tab is in the Prompt Engineer’s Workbench, between “Manifest” and “Server Logs”. It draws the tree of the SAM resources that the llmclient is built from: the llmclient, the Provider, plugins, MCPClients, Guardrails and api key that it uses, and, recursively, what those use, such as Connections and Secrets. Each resource is a card with its kind, its name and its owner, which opens the resource’s manifest page, where its manifest can be edited. Beneath the tree, the tab suggests what an llmclient that has no Guardrail, no tools, no styles or no api key could add, with links to the web console pages where those resources are browsed. The workbench, the @smarter/workbench React app, renders the @smarter/llmclient-architecture component, whose contract is smarter.apps.prompt.views.detailviews.architecture_contract, and fetches the tree from LLMClientArchitectureView when the tab is first opened.

class smarter.apps.prompt.views.detailviews.prompt_architecture_view.LLMClientArchitectureView(**kwargs)[source]

Bases: SmarterAuthenticatedNeverCachedWebView

Returns an llmclient’s architecture, as JSON, for the “Architecture” tab of the Prompt Engineer’s Workbench.

The architecture is an LLMClientArchitecture: the llmclient’s dependency_tree(), a SAMDependencyTreeNode, as the signed-in user may see it (a resource that the user may not read has only its kind and record locator), whether its chat is styled, and the urls of the web console’s Guardrails, Plugins, Extensions, MCPClients and API Keys pages.

The response is never cached, so that the tab shows the llmclient as it is when the workbench is reloaded. An llmclient that the user may not read is a 404.

Example usage:

GET /workbench/llm-clients/<str:hashed_id>/architecture/
{"tree": {"kind": "LLMClient", "name": "stackademy_sql", "owner": "Ada Lovelace (ada)", ...,
          "children": [{"kind": "SqlPlugin", ...}]},
 "styled": false,
 "links": {"guardrailsUrl": "/guardrail/", ...}}
property formatted_class_name: str

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

get(request, *args, **kwargs)[source]

The llmclient’s architecture: its tree, whether it is styled, and the console’s list pages.

The tree’s root is the llmclient of the url’s hashed id itself, not one found by its name, which users of other accounts may have too.

Parameters:

request (HttpRequest) – The request.

Returns:

The architecture, or {"error": ...}, a 404, if the user may not read the llmclient, or there is none.

Return type:

HttpResponse

http_method_names = ['get']

The contract of the Prompt Engineer’s Workbench’s “Architecture” tab: the JSON that it draws, as Pydantic models.

The tab draws an LLMClient’s architecture, an LLMClientArchitecture: the tree of the SAM resources that it is built from, which smarter.lib.manifest.broker.AbstractBroker.dependency_tree() returns as SAMDependencyTreeNode, whether its chat is styled, and the web console pages where a user browses the Guardrails, tools and api keys that it could use. Beneath the tree, the tab suggests the next steps for an LLMClient that has no Guardrail, no tools, no styles or no api key. The JSON is camelCase. The @smarter/llmclient-architecture React package draws it, and the workbench fetches it from LLMClientArchitectureView when the tab is first opened.

manage.py export_llmclient_architecture_schema writes the models’ JSON Schema to llmclient-architecture.schema.json, beside this module, from which @smarter/llmclient-architecture generates its TypeScript types (make llmclient-architecture-contract). A test fails if the committed schema is out of date.

class smarter.apps.prompt.views.detailviews.architecture_contract.LLMClientArchitecture(**data)[source]

Bases: LLMClientArchitectureModel

An LLMClient’s architecture, as the workbench’s Architecture tab draws it.

tree is the tree of the SAM resources that the LLMClient is built from, as the user may see it. It has no description of its own, which would make the TypeScript generator copy the node’s type.

model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'json_schema_serialization_defaults_required': True, 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

styled: bool
tree: SAMDependencyTreeNode

Bases: LLMClientArchitectureModel

The web console’s list pages, where a user browses the resources that an LLMClient can add.

api_keys_url: str
extensions_url: str
guardrails_url: str
mcp_clients_url: str
model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'json_schema_serialization_defaults_required': True, 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

plugins_url: str
class smarter.apps.prompt.views.detailviews.architecture_contract.LLMClientArchitectureModel(**data)[source]

Bases: BaseModel

The base class of the contract’s models: camelCase JSON, and no fields that a model doesn’t define.

model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', 'json_schema_serialization_defaults_required': True, 'serialize_by_alias': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

to_json()[source]

The model as the view sends it.

Return type:

dict[str, Any]

smarter.apps.prompt.views.detailviews.architecture_contract.RESPONSE_MODELS: tuple[type[BaseModel], ...] = (<class 'smarter.apps.prompt.views.detailviews.architecture_contract.LLMClientArchitecture'>,)

What the view sends.

(
    <class 'smarter.apps.prompt.views.detailviews.architecture_contract.LLMClientArchitecture'>,
)
smarter.apps.prompt.views.detailviews.architecture_contract.SCHEMA_PATH = PosixPath('/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/prompt/views/detailviews/llmclient-architecture.schema.json')

The committed JSON Schema of the contract.

smarter.apps.prompt.views.detailviews.architecture_contract.contract_schema()[source]

The contract’s JSON Schema (draft 2020-12): one definition, in $defs, per model.

Return type:

dict[str, Any]

smarter.apps.prompt.views.detailviews.architecture_contract.contract_schema_json()[source]

The contract’s JSON Schema, as the text of llmclient-architecture.schema.json.

Return type:

str