API Contract
The Smarter api contract: the JSON Schemas of the SAM manifests, and the OpenAPI document of the Smarter api.
Both are generated from the platform’s Pydantic models by manage.py export_api_contract, and
committed beside this package: sam/<Kind>.schema.json and openapi.json. Tests fail when a
committed file is out of date. They are the source from which the smarter cli and the SDKs
generate their clients, so a change to a SAM model is a change to the api.
See The Api Contract.
Constants of the Smarter api contract: the SAM JSON Schemas, and the OpenAPI document of the Smarter api.
- smarter.apps.api.v1.contract.const.API_VERSION = 'v1'
the version of the api, not of the platform.
The platform’s version changes with every release, which would make the committed document stale.
- Type:
The document’s
info.version
- smarter.apps.api.v1.contract.const.DEFAULT_PLATFORM_URL = 'https://platform.smarter.sh'
The default of the document’s
platformserver variable.Each Smarter installation has its own. The document is committed, and the SDKs copy it, so this example is fixed, not the running platform’s own url.
- smarter.apps.api.v1.contract.const.JSON_SCHEMA_DIALECT = 'https://json-schema.org/draft/2020-12/schema'
The dialect of the document’s schemas, and of the SAM JSON Schemas.
- smarter.apps.api.v1.contract.const.LOCAL_PLATFORM_URL = 'http://localhost:9357'
The platform of a local development environment.
- smarter.apps.api.v1.contract.const.OPENAPI_PATH = '/home/runner/work/smarter/smarter/smarter/smarter/apps/api/v1/contract/openapi.json'
The OpenAPI document of the Smarter api, generated from
smarter.apps.api.v1.contract.openapi.
- smarter.apps.api.v1.contract.const.OPENAPI_VERSION = '3.1.0'
The version of the OpenAPI Specification that the document follows.
3.1 schemas are JSON Schema 2020-12.
- smarter.apps.api.v1.contract.const.PROJECT_DOCS_URL = 'https://docs.smarter.sh'
The Smarter Project’s documentation, which the document’s description names.
Fixed, as
DEFAULT_PLATFORM_URLis, so that the committed document is the same on every platform.
- smarter.apps.api.v1.contract.const.PROJECT_WEBSITE_URL = 'https://smarter.sh'
The Smarter Project’s website, the document’s
info.contacturl.Fixed, as
PROJECT_DOCS_URLis.
- smarter.apps.api.v1.contract.const.SAM_EXAMPLE_HOST = 'localhost'
The host of the in-process request that renders an example manifest.
Every environment allows it.
- smarter.apps.api.v1.contract.const.SAM_EXAMPLE_SUFFIX = '.example.json'
The suffix of a SAM example manifest’s file name, after its kind.
- smarter.apps.api.v1.contract.const.SAM_SCHEMA_DIR = '/home/runner/work/smarter/smarter/smarter/smarter/apps/api/v1/contract/sam'
The folder of the SAM JSON Schemas, one
<Kind>.schema.jsonper kind.
- smarter.apps.api.v1.contract.const.SAM_SCHEMA_SUFFIX = '.schema.json'
The suffix of a SAM JSON Schema’s file name, after its kind.
The JSON Schemas of the SAM manifests, one per kind, generated from their Pydantic models, and an example manifest of each kind.
manage.py export_api_contract writes them to sam/<Kind>.schema.json and
sam/<Kind>.example.json, beside this module, and a test fails if a committed file is out of
date.
A schema is exactly the
dataof the cli’sjson-schema/<Kind>/response, so a client may read either. The SDKs generate their manifest models from them, andsmarter.apps.api.v1.contract.openapiincludes them in the OpenAPI document.An example is the
dataof the cli’sexample-manifest/<Kind>/response, without its read-onlystatus, whose timestamps change on every request. The SDKs test their generated models against them, and a test checks that each example is valid under its kind’s schema.
- smarter.apps.api.v1.contract.sam.sam_example(kind)[source]
A SAM kind’s example manifest, without its read-only
status.It is rendered in-process by the cli’s public
example-manifestview, so that it is exactly what the api returns, because the brokers build their examples for a request.
- smarter.apps.api.v1.contract.sam.sam_example_json(kind)[source]
A SAM kind’s example manifest, as the text of
sam/<Kind>.example.json.
- smarter.apps.api.v1.contract.sam.sam_example_path(kind, directory='/home/runner/work/smarter/smarter/smarter/smarter/apps/api/v1/contract/sam')[source]
The file of a SAM kind’s example manifest.
- smarter.apps.api.v1.contract.sam.sam_models()[source]
The Pydantic model of each SAM kind: the model that its broker validates manifests with.
The brokers are imported here, rather than at the module’s top, because they import most of the platform’s apps.
- smarter.apps.api.v1.contract.sam.sam_schema(kind)[source]
A SAM kind’s JSON Schema (draft 2020-12): the schema that the cli’s
json-schemacommand returns.
- smarter.apps.api.v1.contract.sam.sam_schema_json(kind)[source]
A SAM kind’s JSON Schema, as the text of
sam/<Kind>.schema.json.
- smarter.apps.api.v1.contract.sam.sam_schema_path(kind, directory='/home/runner/work/smarter/smarter/smarter/smarter/apps/api/v1/contract/sam')[source]
The file of a SAM kind’s JSON Schema.
- smarter.apps.api.v1.contract.sam.write_sam_schemas(directory='/home/runner/work/smarter/smarter/smarter/smarter/apps/api/v1/contract/sam')[source]
Write every SAM kind’s JSON Schema and example manifest, and remove the files of kinds that no longer exist.
Pydantic models of the Smarter cli api contract, and of the OpenAPI document that publishes it.
The cli api (/api/v1/cli/) is the api of the smarter cli and of the SDKs: it applies, gets,
describes and deletes the resources that SAM manifests declare. Its requests and responses are
described by:
the SAM models, one per kind, e.g.
smarter.apps.guardrail.manifest.models.guardrail.model.SAMGuardrail, for the manifests that it accepts and returns,the Smarter Journal api contract (
smarter.lib.journal.contract.models), for the envelope of every response, and for its errors,the Smarter Chat api contract (
smarter.apps.prompt.contract.models), for the chat configuration and the chat completion that the cli’s prompt commands return,the models in this module, for the
dataof the commands whose data is not a manifest. The views build their responses from them.
smarter.apps.api.v1.contract.openapi assembles them into an OpenAPI document, which is
modeled here too (OpenApi...), so that it is built from models rather than from nested dicts.
A schema inside the document is JSON Schema, which is arbitrary JSON, so it is a JsonValue.
The response models allow extra fields: adding a field is backward compatible. Removing or renaming one that is declared here is not.
- smarter.apps.api.v1.contract.models.CLI_API_MODELS: tuple[type[BaseModel], ...] = (<class 'smarter.apps.api.v1.contract.models.CliApiApplied'>, <class 'smarter.apps.api.v1.contract.models.CliApiValidation'>, <class 'smarter.apps.api.v1.contract.models.CliApiGet'>, <class 'smarter.apps.api.v1.contract.models.CliApiResource'>, <class 'smarter.apps.api.v1.contract.models.CliApiStatus'>, <class 'smarter.apps.api.v1.contract.models.CliApiVersion'>, <class 'smarter.apps.api.v1.contract.models.CliApiWhoami'>, <class 'smarter.apps.api.v1.contract.models.CliApiPromptBody'>, <class 'smarter.apps.api.v1.contract.models.CliApiPrompt'>, <class 'smarter.apps.api.v1.contract.models.CliApiDocuments'>, <class 'smarter.apps.api.v1.contract.models.RestApiErrorResponse'>)
The models of the cli api’s response data whose JSON Schema the OpenAPI document includes.
Their dependencies are included with them.
( <class 'smarter.apps.api.v1.contract.models.CliApiApplied'>, <class 'smarter.apps.api.v1.contract.models.CliApiValidation'>, <class 'smarter.apps.api.v1.contract.models.CliApiGet'>, <class 'smarter.apps.api.v1.contract.models.CliApiResource'>, <class 'smarter.apps.api.v1.contract.models.CliApiStatus'>, <class 'smarter.apps.api.v1.contract.models.CliApiVersion'>, <class 'smarter.apps.api.v1.contract.models.CliApiWhoami'>, <class 'smarter.apps.api.v1.contract.models.CliApiPromptBody'>, <class 'smarter.apps.api.v1.contract.models.CliApiPrompt'>, <class 'smarter.apps.api.v1.contract.models.CliApiDocuments'>, <class 'smarter.apps.api.v1.contract.models.RestApiErrorResponse'>, )
- class smarter.apps.api.v1.contract.models.CliApiApplied(*, apiVersion, kind, name, **extra_data)[source]
Bases:
CliApiModelThe
dataof anapplyresponse: the resource that the manifest created or updated.- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.api.v1.contract.models.CliApiDocuments(*, vectorstore, documents, added=<factory>, duplicates=<factory>, queued=None, removed=None, **extra_data)[source]
Bases:
CliApiModelThe
dataof adocumentsresponse: a Vectorstore’s documents after the command, and what it changed.Without files, text or a url, the command lists the documents. With them, it adds them, and with
remove, it removes one. Each document is the REST api’sVectorstoreApiDocument.- added: list[VectorstoreApiDocument]
- documents: list[VectorstoreApiDocument]
- duplicates: list[VectorstoreApiDocument]
- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- removed: VectorstoreApiDocument | None
- class smarter.apps.api.v1.contract.models.CliApiGet(*, apiVersion, kind, name=None, metadata, kwargs, data, **extra_data)[source]
Bases:
CliApiModelThe
dataof agetresponse: the resources of a kind that match the request’s criteria.- data: CliApiGetItems
- metadata: CliApiGetMetadata
- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.api.v1.contract.models.CliApiGetItems(*, titles, items, **extra_data)[source]
Bases:
CliApiModelThe table of a
getresponse: its columns, and one row per resource.- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- titles: list[CliApiGetTitle]
- class smarter.apps.api.v1.contract.models.CliApiGetMetadata(*, count, **extra_data)[source]
Bases:
CliApiModelThe
metadataof agetresponse’s data.- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.api.v1.contract.models.CliApiGetTitle(*, name, type, **extra_data)[source]
Bases:
CliApiModelA column of a
getresponse’s table: an item’s field, and its serializer field’s type.- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.api.v1.contract.models.CliApiModel(**extra_data)[source]
Bases:
BaseModelBase class of the models of the cli api’s response data, which allow extra fields.
- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.api.v1.contract.models.CliApiPrompt(*, request, response, **extra_data)[source]
Bases:
CliApiModelThe
dataof apromptresponse: the request that the cli api sent to the LLMClient, and its response.- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- request: CliApiPromptRequest
- response: CliApiPromptChatResponse
- class smarter.apps.api.v1.contract.models.CliApiPromptBody(*, prompt, session_key=None, messages=None, **extra_data)[source]
Bases:
CliApiModelThe request body of a
prompt.- messages: list[PromptChatApiMessage] | None
- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.api.v1.contract.models.CliApiPromptChatResponse(*, api, metadata, data, **extra_data)[source]
Bases:
CliApiModelThe LLMClient’s journaled response to a
prompt.- metadata: PromptChatApiJournalMetadata
- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.api.v1.contract.models.CliApiPromptLambdaResponse(*, isBase64Encoded=False, statusCode, headers=<factory>, body, **extra_data)[source]
Bases:
CliApiModelThe LLMClient’s response to a
prompt: the version 1 prompt response, with its body decoded from a JSON string.- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.api.v1.contract.models.CliApiPromptRequest(*, session_key, messages, **extra_data)[source]
Bases:
CliApiModelThe request that a
promptsent to the LLMClient.- messages: list[PromptChatApiMessage]
- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.api.v1.contract.models.CliApiResource(*, Singular, Plural, APIKind, Display, DisplayPlural, Deployable, **extra_data)[source]
Bases:
CliApiModelA kind of resource that the cli api manages: an item of the
resourcesresponse’s data.- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.api.v1.contract.models.CliApiStatus(*, infrastructures, compute, **extra_data)[source]
Bases:
CliApiModelThe
dataof astatusresponse: the platform’s infrastructure and compute.- compute: CliApiStatusCompute
- infrastructures: CliApiStatusInfrastructures
- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.api.v1.contract.models.CliApiStatusCompute(*, machine, release, platform, processor, system, version, **extra_data)[source]
Bases:
CliApiModelThe platform’s compute, from Python’s platform module.
- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.api.v1.contract.models.CliApiStatusInfrastructures(*, kubernetes, redis, **extra_data)[source]
Bases:
CliApiModelThe infrastructure of a
statusresponse.- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- redis: CliApiStatusRedis
- class smarter.apps.api.v1.contract.models.CliApiStatusRedis(*, gcc_version=None, os=None, redis_build_id=None, redis_version=None, **extra_data)[source]
Bases:
CliApiModelThe Redis server of a
statusresponse, from Redis’s INFO command.- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.api.v1.contract.models.CliApiValidation(*, valid, errors, **extra_data)[source]
Bases:
CliApiModelThe
dataof avalidateresponse.- errors: list[CliApiValidationError]
- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.api.v1.contract.models.CliApiValidationError(*, loc, message, type, **extra_data)[source]
Bases:
CliApiModelAn error of a manifest that
validatereports.- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.api.v1.contract.models.CliApiVersion(*, api, cli, **extra_data)[source]
Bases:
CliApiModelThe
dataof aversionresponse.- api: CliApiVersionApi
- cli: CliApiVersionCli
- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.api.v1.contract.models.CliApiVersionApi(*, version, python, **extra_data)[source]
Bases:
CliApiModelThe platform’s version, and the versions of its main Python packages.
- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.api.v1.contract.models.CliApiVersionCli(*, version, **extra_data)[source]
Bases:
CliApiModelThe smarter cli’s latest version.
- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.api.v1.contract.models.CliApiWhoami(*, user, account, environment, **extra_data)[source]
Bases:
CliApiModelThe
dataof awhoamiresponse: the api key’s user and account, and the platform’s environment.- account: CliApiWhoamiAccount
- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- user: CliApiWhoamiUser
- class smarter.apps.api.v1.contract.models.CliApiWhoamiAccount(*, id, hashedId=None, accountNumber, name=None, description=None, companyName=None, isDefaultAccount=None, isActive=None, createdAt=None, updatedAt=None, phoneNumber=None, address1=None, address2=None, city=None, state=None, postalCode=None, country=None, language=None, timezone=None, currency=None, **extra_data)[source]
Bases:
CliApiModelThe api key’s account.
- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.api.v1.contract.models.CliApiWhoamiUser(*, id, username, firstName=None, lastName=None, email=None, isStaff, isSuperuser, **extra_data)[source]
Bases:
CliApiModelThe api key’s user.
- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.api.v1.contract.models.OpenApiComponents(*, schemas, securitySchemes)[source]
Bases:
OpenApiModelThe document’s reusable schemas and security schemes.
- model_config = {'extra': 'forbid', '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].
- securitySchemes: dict[str, OpenApiSecurityScheme]
- class smarter.apps.api.v1.contract.models.OpenApiContact(*, name, url)[source]
Bases:
OpenApiModelThe document’s contact information.
- model_config = {'extra': 'forbid', '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].
- class smarter.apps.api.v1.contract.models.OpenApiDocument(*, openapi, info, servers, security, tags, paths, components)[source]
Bases:
OpenApiModelAn OpenAPI 3.1 document.
It has no
jsonSchemaDialect: its schemas use the default dialect of OpenAPI 3.1, which is JSON Schema 2020-12 with OpenAPI’s keywords. Viewers such as Swagger UI support no other value.- components: OpenApiComponents
- info: OpenApiInfo
- model_config = {'extra': 'forbid', '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].
- paths: dict[str, OpenApiPathItem]
- servers: list[OpenApiServer]
- tags: list[OpenApiTag]
- class smarter.apps.api.v1.contract.models.OpenApiInfo(*, title, version, summary=None, description=None, contact=None, license=None)[source]
Bases:
OpenApiModelThe document’s metadata.
- contact: OpenApiContact | None
- license: OpenApiLicense | None
- model_config = {'extra': 'forbid', '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].
- class smarter.apps.api.v1.contract.models.OpenApiLicense(*, name, url)[source]
Bases:
OpenApiModelThe api’s license.
- model_config = {'extra': 'forbid', '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].
- class smarter.apps.api.v1.contract.models.OpenApiMediaType(*, schema, x_smarter_events=None)[source]
Bases:
OpenApiModelThe schema of a request’s or response’s body, in one media type.
- model_config = {'extra': 'forbid', '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].
- schema_: JsonValue
- class smarter.apps.api.v1.contract.models.OpenApiModel[source]
Bases:
BaseModelBase class of the models of an OpenAPI 3.1 document.
They forbid extra fields, so a misspelled field fails rather than being published. Fields whose OpenAPI name is a Python keyword, or a
BaseModelattribute, have an alias: e.g.in_isin, andschema_isschema. A field that is None is left out of the dump, because no OpenAPI field may be null.exclude_nonewould also drop the nulls inside the schemas, e.g. a field’s"default": null, so the models drop their own Nones instead.- model_config = {'extra': 'forbid', '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].
- class smarter.apps.api.v1.contract.models.OpenApiOperation(*, operationId, summary, description=None, tags=<factory>, parameters=<factory>, requestBody=None, responses, security=None)[source]
Bases:
OpenApiModelAn http method of a path.
- model_config = {'extra': 'forbid', '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].
- parameters: list[OpenApiParameter]
- requestBody: OpenApiRequestBody | None
- responses: dict[str, OpenApiResponse]
- class smarter.apps.api.v1.contract.models.OpenApiParameter(*, name, in_, description=None, required=False, schema)[source]
Bases:
OpenApiModelA path, query or header parameter of an operation.
- model_config = {'extra': 'forbid', '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].
- schema_: JsonValue
- class smarter.apps.api.v1.contract.models.OpenApiPathItem(*, get=None, post=None, delete=None)[source]
Bases:
OpenApiModelA path, and its operations.
- delete: OpenApiOperation | None
- get: OpenApiOperation | None
- model_config = {'extra': 'forbid', '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].
- post: OpenApiOperation | None
- class smarter.apps.api.v1.contract.models.OpenApiRequestBody(*, description=None, required=False, content)[source]
Bases:
OpenApiModelAn operation’s request body.
- content: dict[str, OpenApiMediaType]
- model_config = {'extra': 'forbid', '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].
- class smarter.apps.api.v1.contract.models.OpenApiResponse(*, description, content=None)[source]
Bases:
OpenApiModelOne of an operation’s responses.
- content: dict[str, OpenApiMediaType] | None
- model_config = {'extra': 'forbid', '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].
- type smarter.apps.api.v1.contract.models.OpenApiSchema = _AllowAnyJson]
A JSON Schema (2020-12), e.g.
{"$ref": "#/components/schemas/SAMGuardrail"}.
- class smarter.apps.api.v1.contract.models.OpenApiSecurityScheme(*, type='apiKey', name, in_='header', description=None)[source]
Bases:
OpenApiModelAn api key scheme: the only one that the cli api accepts from programs.
- model_config = {'extra': 'forbid', '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].
- class smarter.apps.api.v1.contract.models.OpenApiServer(*, url, description=None, variables=None)[source]
Bases:
OpenApiModelA server that hosts the api.
- model_config = {'extra': 'forbid', '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].
- variables: dict[str, OpenApiServerVariable] | None
- class smarter.apps.api.v1.contract.models.OpenApiServerVariable(*, default, description=None)[source]
Bases:
OpenApiModelA variable of a server’s url.
- model_config = {'extra': 'forbid', '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].
- class smarter.apps.api.v1.contract.models.OpenApiTag(*, name, description=None)[source]
Bases:
OpenApiModelA tag, which groups operations.
- model_config = {'extra': 'forbid', '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].
- class smarter.apps.api.v1.contract.models.RestApiErrorResponse(*, detail, **extra_data)[source]
Bases:
BaseModelThe body of an error response of the REST api’s views: Django REST framework’s
{"detail": ...}.e.g. a 404 for a row that does not exist, or a 403 for a user who may not use the view.
- model_config = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
The OpenAPI 3.1 document of the Smarter api, generated from Pydantic models.
The document covers the apis that the smarter cli and the SDKs call, family by family:
the cli api (
/api/v1/cli/), to apply, get, describe, validate and delete the resources that SAM manifests declare (cli),the chat api (
/api/v1/llm-clients/{id}/config/,.../prompt/and.../provider-request/), to chat with an LLMClient, as JSON or as a stream of Server-Sent Events (chat),the REST api of each resource family, one module each in
families, whose responses are built from each app’s contract models, e.g.smarter.apps.llmclient.contract.models. Mostly reads: clients write through the cli api’s manifests, which the brokers validate.
The package’s modules:
builders: references, responses, operations and parameters, andbuilders.ApiFamily, from whose Django app’s name each family’s tag, operation ids, paths and resource words are derived.schemas: the document’s components, from the SAM models of every kind (smarter.apps.api.v1.contract.sam.sam_models()), the Smarter Journal api contract (smarter.lib.journal.contract.models), the Smarter Chat api contract (smarter.apps.prompt.contract.models), each family’s contract models, and the models of the cli commands’ data (smarter.apps.api.v1.contract.models).routes: which routes the document covers, and why it leaves out the others.document: the document, assembled.
A change to any of the models changes the document. manage.py export_api_contract writes it to
openapi.json, beside this package, and a test fails if the committed file is out of date, or if a
route of a family in routes.DOCUMENTED_URLCONFS is neither in the document nor in
routes.UNDOCUMENTED_ROUTES.
Every platform serves this document at /api/v1/openapi.json (smarter.apps.api.v1.contract.views;
/docs/openapi.json redirects there), and renders it with Scalar at /docs/openapi/. It is the platform’s
only api documentation.
The building blocks of the OpenAPI document: references, responses, operations, parameters, and families of routes.
Each family of the REST api is an ApiFamily, named after its Django app, from which its tag, its
operations’ ids, its paths, and the words that its descriptions use for its resource are derived, so that
each is written once.
- smarter.apps.api.v1.contract.openapi.builders.API_KEY_AUTH = 'ApiKeyAuth'
The name of the document’s security scheme.
- smarter.apps.api.v1.contract.openapi.builders.API_KEY_ONLY = 'Requires an api key.'
The note of the REST reads that any api key may call, and whose views filter nothing more.
- class smarter.apps.api.v1.contract.openapi.builders.ApiFamily(name, resource, urlconf, description, resources=None, tag_name=None, mount=None)[source]
A family of the REST api’s routes: one Django app’s, or one feature’s of an app.
Everything that the document says about the family is derived from a few names, so that each is written once: e.g.
ApiFamily(name="guardrail", resource="Guardrail", ...)has the tagguardrails, the routes/guardrails/..., the operation idsguardrail_listandguardrail_retrieve, the pluralGuardrailsand the articlea Guardrail.- __init__(name, resource, urlconf, description, resources=None, tag_name=None, mount=None)
- property a: str
e.g. an LLMClient, or a Guardrail.
- Type:
The resource with its article, as a sentence names it
- property a_capitalized: str
e.g. An LLMClient.
- Type:
The resource with its article, as a sentence’s or a summary’s first words
- description: str
The description of the family’s tag, in which
{plural}isplural, e.g. The {plural}’ REST reads.
- mount: str | None = None
Where
smarter.apps.api.v1.urlsmounts the family’s routes, if not at its tag, e.g. llm-clients.
- name: str
The family’s name, its Django app’s (the app’s
const.namespace), e.g. guardrail.Its operations’ ids start with it, and its tag is its plural.
- openapi_tag()[source]
The document’s tag of the family’s operations.
- Returns:
The tag.
- Return type:
- property prefix: str
mountortag, e.g. /guardrails/.- Type:
The path of the family’s routes, relative to
/api/v1
- resource: str
its SAM kind, e.g. Guardrail, or a word, e.g. vectorstore.
- Type:
The family’s resource, as its descriptions name it
- resources: str | None = None
it adds only an s to a capitalized Proxy.
- Type:
The plural of
resource, if inflect gets it wrong, e.g. Proxies
- smarter.apps.api.v1.contract.openapi.builders.OPERATION_ERROR = 'An error, e.g. 400 for an invalid request, or 404 for a row that the user may not read or own.'
The error of an action that every user may call, on what they may read or own.
- smarter.apps.api.v1.contract.openapi.builders.PUBLIC: list[dict[str, list[str]]] = []
The
securityof an operation that needs no api key.[]
- smarter.apps.api.v1.contract.openapi.builders.READ_ERROR = 'An error, e.g. 404 for a row that does not exist, or that the user may not read.'
The error of a read that every user may call, for what they may read.
- smarter.apps.api.v1.contract.openapi.builders.READ_PERMISSION = "Requires an api key. The response includes only what the user may read: their account's resources, and the platform's built-in ones."
The note of the REST reads whose views are SmarterAuthenticatedAPIView and SmarterAuthenticatedListAPIView.
- smarter.apps.api.v1.contract.openapi.builders.REF_TEMPLATE = '#/components/schemas/{model}'
Where the document’s schemas refer to each other’s definitions.
- smarter.apps.api.v1.contract.openapi.builders.SUPERUSER_ONLY = "Requires an api key of a superuser: the REST api's views refuse other users with a 403. Other users read their resources with the cli api's get and describe."
The note of the REST reads whose views are SmarterAdminAPIView and SmarterAdminListAPIView.
- smarter.apps.api.v1.contract.openapi.builders.SUPERUSER_OPERATION_ERROR = 'An error, e.g. 400 for an invalid request, 403 for a user who is not a superuser, or 404 for a row that does not exist.'
The error of an action that only superusers may call.
- smarter.apps.api.v1.contract.openapi.builders.SUPERUSER_READ_ERROR = 'An error, e.g. 404 for a row that does not exist, or 403 for a user who is not a superuser.'
-
- Type:
The error of a read that only superusers may call
- smarter.apps.api.v1.contract.openapi.builders.envelope(data, description)[source]
The schema of a journaled response: the journal’s envelope, beside the command’s
dataandmessage.
- smarter.apps.api.v1.contract.openapi.builders.id_or_hashed_id(resource)[source]
The
{id}path parameter of a resource whose routes take its numeric id or its hashed id.- Parameters:
resource (
str) – The resource’s kind, e.g. Guardrail.- Returns:
The parameter.
- Return type:
- smarter.apps.api.v1.contract.openapi.builders.inflect_word(word)[source]
A word, as inflect’s functions take it: a string of at least one character.
inflect declares
WordasAnnotated[str, ...]for mypy, but as a class at run time, behind a flag that other type checkers, e.g. Pylance, can’t follow, so they refuse astr. inflect checks the length at run time; this checks it first, with a clearer message.- Parameters:
word (
str) – The word, e.g. guardrail.- Returns:
The word, as an
inflect.Word.- Return type:
Word- Raises:
ValueError – If the word is empty.
- smarter.apps.api.v1.contract.openapi.builders.integer_id(name, description)[source]
A path parameter that is a row’s numeric id.
- Parameters:
- Returns:
The parameter.
- Return type:
- smarter.apps.api.v1.contract.openapi.builders.json_body(schema_name, description=None, required=True)[source]
A JSON request body whose schema is one of the document’s.
- Parameters:
- Returns:
The request body.
- Return type:
- smarter.apps.api.v1.contract.openapi.builders.json_response(description, schema_name)[source]
A JSON response whose body is one of the document’s schemas.
- Parameters:
- Returns:
The response.
- Return type:
- smarter.apps.api.v1.contract.openapi.builders.merge_paths(*families)[source]
The paths of several families, with the operations of a path that two families share in one path item.
- Parameters:
families (
dict[str,OpenApiPathItem]) – Each family’s paths.- Returns:
The paths.
- Return type:
- Raises:
ValueError – If two families define the same method of a path.
- smarter.apps.api.v1.contract.openapi.builders.path_string(name, description)[source]
A path parameter that is a string, e.g. a Provider’s name.
- Parameters:
- Returns:
The parameter.
- Return type:
- smarter.apps.api.v1.contract.openapi.builders.plural(word)[source]
The plural of a word or a phrase, e.g. guardrails, LLMClients, account contacts.
- smarter.apps.api.v1.contract.openapi.builders.query(name, description, schema, required=False)[source]
A query parameter.
- Parameters:
- Returns:
The parameter.
- Return type:
- smarter.apps.api.v1.contract.openapi.builders.ref(name)[source]
A reference to one of the document’s schemas.
- Parameters:
name (
str) – The schema’s name incomponents.schemas.- Returns:
e.g.
{"$ref": "#/components/schemas/SAMGuardrail"}.- Return type:
JsonValue
- smarter.apps.api.v1.contract.openapi.builders.rest_operation(operation_id, summary, description, tag, response, *, parameters, status='200', request_body=None, error='An error, e.g. 400 for an invalid request, or 404 for a row that the user may not read or own.')[source]
An operation of the REST api, whose success is one of the document’s schemas, and whose errors are DRF’s.
- Parameters:
operation_id (
str) – The operation’s id, e.g. vectorstore_search.summary (
str) – A one-line summary.description (
str) – A description, which says who may call it, and what it changes.tag (
str) – The operation’s tag.response (
str) – The successful response’s schema, incomponents.schemas.parameters (
list[OpenApiParameter]) – The operation’s parameters.status (
str) – The successful response’s http status, e.g. 202 for queued work.request_body (
OpenApiRequestBody|None) – The operation’s request body.error (
str) – The description of its errors, e.g.SUPERUSER_OPERATION_ERROR.
- Returns:
The operation.
- Return type:
- smarter.apps.api.v1.contract.openapi.builders.rest_read(operation_id, summary, description, tag, item, *, many, parameters, note="Requires an api key of a superuser: the REST api's views refuse other users with a 403. Other users read their resources with the cli api's get and describe.", success=None)[source]
A read of the REST api: a
GETwhose response is a row, or a list of rows, of one of the document’s schemas.- Parameters:
operation_id (
str) – The operation’s id, e.g. llmclient_list.summary (
str) – A one-line summary.description (
str) – A description, to whichnoteis added.tag (
str) – The operation’s tag.item (
str) – The schema of a row, incomponents.schemas.many (
bool) – Whether the response is a list of rows.parameters (
list[OpenApiParameter]) – The operation’s parameters.note (
str) – Who may read, e.g.SUPERUSER_ONLYorREAD_PERMISSION. It also chooses the error’s description:SUPERUSER_READ_ERRORforSUPERUSER_ONLY, elseREAD_ERROR.success (
str|None) – The successful response’s description, if the response is not a row or a list of rows, e.g. The window’s points.
- Returns:
The operation.
- Return type:
- smarter.apps.api.v1.contract.openapi.builders.superuser_list_and_retrieve(family, item)[source]
A family’s REST list and retrieve, whose views only superusers may call.
- Parameters:
- Returns:
The paths.
- Return type:
- smarter.apps.api.v1.contract.openapi.builders.with_article(word, capitalize=False)[source]
A word or a phrase with its indefinite article, e.g. a Guardrail, an LLMClient.
The document’s components: the JSON Schemas of the models that its operations use.
The schemas are generated from the platform’s Pydantic models in one pass, so that a model that two families
share is one schema: the SAM models of every kind, the journal and chat contracts, each family’s contract
models, and the cli’s data. cli_schemas() adds the schemas that no model has, e.g. a manifest of any kind.
- smarter.apps.api.v1.contract.openapi.schemas.CHAT_MODELS: tuple[type[BaseModel], ...] = (<class 'smarter.apps.prompt.contract.models.PromptChatApiConfigRequest'>, <class 'smarter.apps.prompt.contract.models.PromptChatApiConfigResponse'>, <class 'smarter.apps.prompt.contract.models.PromptChatApiPromptRequest'>, <class 'smarter.apps.prompt.contract.models.PromptChatApiPromptResponse'>, <class 'smarter.apps.prompt.contract.models.PromptChatApiErrorResponse'>, <class 'smarter.apps.prompt.contract.models.PromptChatApiProgressEvent'>, <class 'smarter.apps.prompt.contract.models.PromptChatApiProgressResult'>, <class 'smarter.apps.prompt.contract.models.PromptChatApiProviderRequestResponse'>)
The Smarter Chat api contract’s models that the chat api’s operations use.
( <class 'smarter.apps.prompt.contract.models.PromptChatApiConfigRequest'>, <class 'smarter.apps.prompt.contract.models.PromptChatApiConfigResponse'>, <class 'smarter.apps.prompt.contract.models.PromptChatApiPromptRequest'>, <class 'smarter.apps.prompt.contract.models.PromptChatApiPromptResponse'>, <class 'smarter.apps.prompt.contract.models.PromptChatApiErrorResponse'>, <class 'smarter.apps.prompt.contract.models.PromptChatApiProgressEvent'>, <class 'smarter.apps.prompt.contract.models.PromptChatApiProgressResult'>, <class 'smarter.apps.prompt.contract.models.PromptChatApiProviderRequestResponse'>, )
- smarter.apps.api.v1.contract.openapi.schemas.cli_schemas()[source]
Every schema of the document: the models’ schemas, a manifest of any kind, and the responses of the commands.
- smarter.apps.api.v1.contract.openapi.schemas.model_schemas()[source]
The JSON Schemas of the SAM models, the journal contract and the cli’s data, as the document’s components.
The cli api’s operations, under /api/v1/cli/: the commands of the smarter cli, as the SDKs send them.
Every command is a POST whose response is journaled: the journal’s envelope, beside the command’s data
or message, and whose errors are the journal’s error response.
- smarter.apps.api.v1.contract.openapi.cli.CLI_PREFIX = '/cli/'
The path of the cli api’s routes, relative to
/api/v1.
- smarter.apps.api.v1.contract.openapi.cli.CLI_TAGS = [OpenApiTag(name='manifests', description='Resources, and the manifests that declare them.'), OpenApiTag(name='deployment', description='Deployable resources, e.g. LLMClients.'), OpenApiTag(name='platform', description="The platform, and the api key's user.")]
The tags of the cli api’s commands, but its chat commands’, which are the chat api’s.
[ OpenApiTag(name='manifests', description='Resources, and the manifests that declare them.'), OpenApiTag(name='deployment', description='Deployable resources, e.g. LLMClients.'), OpenApiTag(name='platform', description="The platform, and the api key's user."), ]
- smarter.apps.api.v1.contract.openapi.cli.CLI_URLCONF = 'smarter.apps.api.v1.cli.urls'
The module of the cli api’s url patterns.
- smarter.apps.api.v1.contract.openapi.cli.cli_path(command)[source]
The path of a cli command, relative to the server’s
/api/v1.- Parameters:
command (
str) – The command’s path, relative toCLI_PREFIX, e.g.get/{kind}/.- Returns:
e.g.
/cli/get/{kind}/.- Return type:
- smarter.apps.api.v1.contract.openapi.cli.cli_paths()[source]
The cli api’s paths, relative to the server’s
/api/v1, by the url names of their routes.- Returns:
The paths, e.g.
{"/cli/apply/": ...}.- Return type:
- smarter.apps.api.v1.contract.openapi.cli.operation(operation_id, summary, description, tag, response, *, parameters=None, request_body=None, security=None)[source]
A cli command: an operation whose successful response is
200, and whose other responses are journaled errors.- Parameters:
operation_id (
str) – The operation’s id, e.g. apply.summary (
str) – A one-line summary.description (
str) – A description.tag (
str) – The operation’s tag.response (
str) – The successful response’s schema, incomponents.schemas.parameters (
list[OpenApiParameter] |None) – The operation’s parameters.request_body (
OpenApiRequestBody|None) – The operation’s request body.security (
list[dict[str,list[str]]] |None) – The operation’s security, e.g.PUBLIC, or None for the document’s.
- Returns:
The operation.
- Return type:
The chat api, under /api/v1/llm-clients/{id}/: what Smarter Chat and the SDKs call to chat with an LLMClient.
Its requests and responses are the Smarter Chat api contract’s, version 2
(smarter.apps.prompt.contract.models).
- smarter.apps.api.v1.contract.openapi.chat.CHAT_TAG = OpenApiTag(name='chat', description='Chats with LLMClients.')
The document’s tag of the chat api.
- smarter.apps.api.v1.contract.openapi.chat.TAG_CHAT = 'chat'
The tag of the chat api’s operations, and of the cli’s prompt commands.
- smarter.apps.api.v1.contract.openapi.chat.chat_paths()[source]
The chat api’s paths, relative to the server’s
/api/v1.The prompt’s
200response is JSON, or, for a client that acceptstext/event-stream, a stream of Server-Sent Events:progressevents, then oneresultevent, whoseresponseis the JSON that a non-streaming client receives. OpenAPI 3.1 can’t type the events of a stream, so the stream’s media type names their schemas in anx-smarter-eventsextension.- Returns:
The paths, e.g.
{"/llm-clients/{id}/prompt/": ...}.- Return type:
Which routes of /api/v1 the document covers, and why it leaves out the others.
test_every_route_is_documented and test_every_family_is_covered hold the document to these tables: every
route of a family in DOCUMENTED_URLCONFS must be in the document, or in UNDOCUMENTED_ROUTES,
and every family that smarter.apps.api.v1.urls mounts must be in DOCUMENTED_URLCONFS, or in
UNDOCUMENTED_URLCONFS.
- smarter.apps.api.v1.contract.openapi.routes.CONNECTIONS_PREFIX = '/connections/'
its urlconf has no routes.
- Type:
The path of the connections’ routes, a family that has none to document
- smarter.apps.api.v1.contract.openapi.routes.DOCUMENTED_URLCONFS: dict[str, str] = {'/accounts/': 'smarter.apps.account.api.v1.urls', '/cli/': 'smarter.apps.api.v1.cli.urls', '/connections/': 'smarter.apps.connection.api.v1.urls', '/extensions/': 'smarter.apps.llmtool.extension.api.v1.urls', '/guardrails/': 'smarter.apps.guardrail.api.v1.urls', '/journal/': 'smarter.lib.journal.api.v1.urls', '/llm-clients/': 'smarter.apps.llmclient.api.v1.urls', '/llmhosts/': 'smarter.apps.llmhost.api.v1.urls', '/mcpclients/': 'smarter.apps.mcpclient.api.v1.urls', '/orchestrators/': 'smarter.apps.orchestrator.api.v1.urls', '/plugins/': 'smarter.apps.llmtool.api.v1.urls', '/prompts/': 'smarter.apps.prompt.api.v1.urls', '/providers/': 'smarter.apps.provider.api.v1.urls', '/proxy/': 'smarter.apps.proxy.api.v1.urls', '/secrets/': 'smarter.apps.secret.api.v1.urls', '/vectorsearches/': 'smarter.apps.vectorsearch.api.v1.urls', '/vectorstores/': 'smarter.apps.vectorstore.api.v1.urls'}
each one’s path, relative to
/api/v1, and its urlconf.The cli api’s, the connections’, and each of
FAMILIES. Every route of these urlconfs must be in the document, or inUNDOCUMENTED_ROUTES.{ '/accounts/': 'smarter.apps.account.api.v1.urls', '/cli/': 'smarter.apps.api.v1.cli.urls', '/connections/': 'smarter.apps.connection.api.v1.urls', '/extensions/': 'smarter.apps.llmtool.extension.api.v1.urls', '/guardrails/': 'smarter.apps.guardrail.api.v1.urls', '/journal/': 'smarter.lib.journal.api.v1.urls', '/llm-clients/': 'smarter.apps.llmclient.api.v1.urls', '/llmhosts/': 'smarter.apps.llmhost.api.v1.urls', '/mcpclients/': 'smarter.apps.mcpclient.api.v1.urls', '/orchestrators/': 'smarter.apps.orchestrator.api.v1.urls', '/plugins/': 'smarter.apps.llmtool.api.v1.urls', '/prompts/': 'smarter.apps.prompt.api.v1.urls', '/providers/': 'smarter.apps.provider.api.v1.urls', '/proxy/': 'smarter.apps.proxy.api.v1.urls', '/secrets/': 'smarter.apps.secret.api.v1.urls', '/vectorsearches/': 'smarter.apps.vectorsearch.api.v1.urls', '/vectorstores/': 'smarter.apps.vectorstore.api.v1.urls', }
- Type:
The families of routes that the document covers
- smarter.apps.api.v1.contract.openapi.routes.ID_FAMILIES = (ApiFamily(name='llmclient', resource='LLMClient', urlconf='smarter.apps.llmclient.api.v1.urls', description="The {plural}' REST reads.", resources=None, tag_name=None, mount='llm-clients'), ApiFamily(name='guardrail', resource='Guardrail', urlconf='smarter.apps.guardrail.api.v1.urls', description="The {plural}' REST reads, and their dry run.", resources=None, tag_name=None, mount=None), ApiFamily(name='secret', resource='Secret', urlconf='smarter.apps.secret.api.v1.urls', description="The {plural}' REST reads: their metadata, never their values.", resources=None, tag_name=None, mount=None), ApiFamily(name='mcpclient', resource='MCPClient', urlconf='smarter.apps.mcpclient.api.v1.urls', description="The {plural}' REST reads, their reconnection, and tool calls.", resources=None, tag_name=None, mount=None), ApiFamily(name='vectorstore', resource='vectorstore', urlconf='smarter.apps.vectorstore.api.v1.urls', description="The {plural}' REST reads, search, documents and maintenance. Served only when the platform enables {plural} (SMARTER_APP_VECTORSTORE_ENABLE).", resources=None, tag_name=None, mount=None), ApiFamily(name='llmhost', resource='LLMHost', urlconf='smarter.apps.llmhost.api.v1.urls', description="The {plural}' REST reads, model discovery, and deployment.", resources=None, tag_name=None, mount=None), ApiFamily(name='orchestrator', resource='Orchestrator', urlconf='smarter.apps.orchestrator.api.v1.urls', description="The {plural}' REST reads, for superusers, and their runs, for any user who may read them.", resources=None, tag_name=None, mount=None), ApiFamily(name='vectorsearch', resource='Vectorsearch', urlconf='smarter.apps.vectorsearch.api.v1.urls', description="The {plural}' REST reads, for superusers, and their runs, for any user who may read them.", resources=None, tag_name=None, mount=None))
The families whose routes take
<int:<name>_id>, e.g.<int:guardrail_id>, beside<str:hashed_id>.( ApiFamily(name='llmclient', resource='LLMClient', urlconf='smarter.apps.llmclient.api.v1.urls', description="The {plural}' REST reads.", resources=None, tag_name=None, mount='llm-clients'), ApiFamily(name='guardrail', resource='Guardrail', urlconf='smarter.apps.guardrail.api.v1.urls', description="The {plural}' REST reads, and their dry run.", resources=None, tag_name=None, mount=None), ApiFamily(name='secret', resource='Secret', urlconf='smarter.apps.secret.api.v1.urls', description="The {plural}' REST reads: their metadata, never their values.", resources=None, tag_name=None, mount=None), ApiFamily(name='mcpclient', resource='MCPClient', urlconf='smarter.apps.mcpclient.api.v1.urls', description="The {plural}' REST reads, their reconnection, and tool calls.", resources=None, tag_name=None, mount=None), ApiFamily(name='vectorstore', resource='vectorstore', urlconf='smarter.apps.vectorstore.api.v1.urls', description="The {plural}' REST reads, search, documents and maintenance. Served only when the platform enables {plural} (SMARTER_APP_VECTORSTORE_ENABLE).", resources=None, tag_name=None, mount=None), ApiFamily(name='llmhost', resource='LLMHost', urlconf='smarter.apps.llmhost.api.v1.urls', description="The {plural}' REST reads, model discovery, and deployment.", resources=None, tag_name=None, mount=None), ApiFamily(name='orchestrator', resource='Orchestrator', urlconf='smarter.apps.orchestrator.api.v1.urls', description="The {plural}' REST reads, for superusers, and their runs, for any user who may read them.", resources=None, tag_name=None, mount=None), ApiFamily(name='vectorsearch', resource='Vectorsearch', urlconf='smarter.apps.vectorsearch.api.v1.urls', description="The {plural}' REST reads, for superusers, and their runs, for any user who may read them.", resources=None, tag_name=None, mount=None), )
- smarter.apps.api.v1.contract.openapi.routes.PATH_PARAMETER_ALIASES: dict[str, str] = {'guardrail_id': 'id', 'hashed_id': 'id', 'llmclient_id': 'id', 'llmhost_id': 'id', 'mcpclient_id': 'id', 'orchestrator_id': 'id', 'pk': 'id', 'secret_id': 'id', 'vectorsearch_id': 'id', 'vectorstore_id': 'id'}
The document’s names of the routes’ path parameters, where they differ.
A resource’s routes take either its numeric id or its hashed id, e.g.
<int:guardrail_id>and<str:hashed_id>, which the document describes as one{id}.{ 'guardrail_id': 'id', 'hashed_id': 'id', 'llmclient_id': 'id', 'llmhost_id': 'id', 'mcpclient_id': 'id', 'orchestrator_id': 'id', 'pk': 'id', 'secret_id': 'id', 'vectorsearch_id': 'id', 'vectorstore_id': 'id', }
- smarter.apps.api.v1.contract.openapi.routes.UNDOCUMENTED_ROUTES: dict[str, str] = {'/accounts/batch-create-users/': 'Creates users from a CSV file in the web console. Clients apply User manifests with the cli api.', '/llm-clients/{id}/prompt/config/': 'A legacy alias of /llm-clients/{id}/config/, for pages that installed an older Smarter Chat.', '/orchestrators/{id}/orchestrator/': 'Running an Orchestrator is not implemented yet: the route has no POST handler, and answers 405.', '/plugins/upload/': "A web console action, which clients replace with the cli api's manifests.", '/plugins/{plugin_id}/clone/{new_name}': "A web console action, which clients replace with the cli api's manifests.", '/prompts/passthrough/{provider_name}/': "A passthrough to an LLM provider's api, whose requests and responses are the provider's, not Smarter's.", '/prompts/smarter/{provider_name}/': "The chat api of an LLM provider through Smarter, whose requests and responses are the provider's, not Smarter's.", '/proxy/{name}/': "A Proxy's passthrough, whose requests and responses are its provider's api, not Smarter's.", '/proxy/{name}/{path}': "A Proxy's passthrough, whose requests and responses are its provider's api, not Smarter's."}
The paths of the routes of
DOCUMENTED_URLCONFSthat the document leaves out, and why.{ '/accounts/batch-create-users/': 'Creates users from a CSV file in the web console. Clients apply User manifests with the cli api.', '/llm-clients/{id}/prompt/config/': 'A legacy alias of /llm-clients/{id}/config/, for pages that installed an older Smarter Chat.', '/orchestrators/{id}/orchestrator/': 'Running an Orchestrator is not implemented yet: the route has no POST handler, and answers 405.', '/plugins/upload/': "A web console action, which clients replace with the cli api's manifests.", '/plugins/{plugin_id}/clone/{new_name}': "A web console action, which clients replace with the cli api's manifests.", '/prompts/passthrough/{provider_name}/': "A passthrough to an LLM provider's api, whose requests and responses are the provider's, not Smarter's.", '/prompts/smarter/{provider_name}/': "The chat api of an LLM provider through Smarter, whose requests and responses are the provider's, not Smarter's.", '/proxy/{name}/': "A Proxy's passthrough, whose requests and responses are its provider's api, not Smarter's.", '/proxy/{name}/{path}': "A Proxy's passthrough, whose requests and responses are its provider's api, not Smarter's.", }
- smarter.apps.api.v1.contract.openapi.routes.UNDOCUMENTED_URLCONFS: dict[str, str] = {'/demos/': "Fictional data for the platform's example resources, e.g. the Stackademy course catalogue that the Stackademy ApiPlugin queries. These are not part of the platform's api.", '/doodles/': "The sign-in page's doodle of the day and its artwork, smarter.apps.doodle, which only the page's own React app reads. These are not part of the platform's api.", '/mcp/': 'The MCPServer, smarter.apps.mcpserver: a JSON-RPC endpoint for its public tools and one for its staff-only tools, whose methods and messages the Model Context Protocol specification defines, not OpenAPI.', '/tests/': "Views that only the platform's own unit tests call."}
The families of routes under
/api/v1that the document leaves out, and why.Every family that
smarter.apps.api.v1.urlsmounts must be inDOCUMENTED_URLCONFSor here.{ '/demos/': "Fictional data for the platform's example resources, e.g. the Stackademy course catalogue that the Stackademy ApiPlugin queries. These are not part of the platform's api.", '/doodles/': "The sign-in page's doodle of the day and its artwork, smarter.apps.doodle, which only the page's own React app reads. These are not part of the platform's api.", '/mcp/': 'The MCPServer, smarter.apps.mcpserver: a JSON-RPC endpoint for its public tools and one for its staff-only tools, whose methods and messages the Model Context Protocol specification defines, not OpenAPI.', '/tests/': "Views that only the platform's own unit tests call.", }
The Smarter api’s OpenAPI document: its metadata, its tags, and every family’s paths, assembled.
manage.py export_api_contract writes it to openapi.json, with write_openapi().
- smarter.apps.api.v1.contract.openapi.document.openapi_document()[source]
The Smarter api’s OpenAPI document.
- Returns:
The document.
- Return type:
- smarter.apps.api.v1.contract.openapi.document.openapi_json()[source]
The Smarter api’s OpenAPI document, as the text of
openapi.json.- Returns:
The document, as indented JSON, with a final newline.
- Return type:
- smarter.apps.api.v1.contract.openapi.document.write_openapi(path='/home/runner/work/smarter/smarter/smarter/smarter/apps/api/v1/contract/openapi.json')[source]
Write the Smarter api’s OpenAPI document.
The REST api’s families of routes, one module per family.
Each module declares its family, an ApiFamily named
after its Django app, and a <family>_paths() function that returns its operations. FAMILIES lists
them in the order of the document’s tags.
- smarter.apps.api.v1.contract.openapi.families.FAMILIES: tuple[ApiFamily, ...] = (ApiFamily(name='llmclient', resource='LLMClient', urlconf='smarter.apps.llmclient.api.v1.urls', description="The {plural}' REST reads.", resources=None, tag_name=None, mount='llm-clients'), ApiFamily(name='guardrail', resource='Guardrail', urlconf='smarter.apps.guardrail.api.v1.urls', description="The {plural}' REST reads, and their dry run.", resources=None, tag_name=None, mount=None), ApiFamily(name='secret', resource='Secret', urlconf='smarter.apps.secret.api.v1.urls', description="The {plural}' REST reads: their metadata, never their values.", resources=None, tag_name=None, mount=None), ApiFamily(name='mcpclient', resource='MCPClient', urlconf='smarter.apps.mcpclient.api.v1.urls', description="The {plural}' REST reads, their reconnection, and tool calls.", resources=None, tag_name=None, mount=None), ApiFamily(name='vectorstore', resource='vectorstore', urlconf='smarter.apps.vectorstore.api.v1.urls', description="The {plural}' REST reads, search, documents and maintenance. Served only when the platform enables {plural} (SMARTER_APP_VECTORSTORE_ENABLE).", resources=None, tag_name=None, mount=None), ApiFamily(name='llmhost', resource='LLMHost', urlconf='smarter.apps.llmhost.api.v1.urls', description="The {plural}' REST reads, model discovery, and deployment.", resources=None, tag_name=None, mount=None), ApiFamily(name='plugin', resource='plugin', urlconf='smarter.apps.llmtool.api.v1.urls', description="The {plural}' REST reads.", resources=None, tag_name=None, mount=None), ApiFamily(name='provider', resource='Provider', urlconf='smarter.apps.provider.api.v1.urls', description="The LLM {plural}' REST reads, and their models.", resources=None, tag_name=None, mount=None), ApiFamily(name='proxy', resource='Proxy', urlconf='smarter.apps.proxy.api.v1.urls', description='The {plural} that the user may use. Served only when the platform enables {plural} (SMARTER_APP_PROXY_ENABLE).', resources='Proxies', tag_name=None, mount='proxy'), ApiFamily(name='account', resource='account', urlconf='smarter.apps.account.api.v1.urls', description='The {plural}, their users and contacts. For superusers.', resources=None, tag_name=None, mount=None), ApiFamily(name='history', resource='chat session', urlconf='smarter.apps.prompt.api.v1.urls', description='The {plural}, and their tool calls and plugin usage.', resources=None, tag_name='history', mount='prompts'), ApiFamily(name='journal', resource='journal entry', urlconf='smarter.lib.journal.api.v1.urls', description='The Smarter Journal: a record of every journaled request to the Smarter api. For superusers.', resources=None, tag_name='journal', mount=None), ApiFamily(name='orchestrator', resource='Orchestrator', urlconf='smarter.apps.orchestrator.api.v1.urls', description="The {plural}' REST reads, for superusers, and their runs, for any user who may read them.", resources=None, tag_name=None, mount=None), ApiFamily(name='vectorsearch', resource='Vectorsearch', urlconf='smarter.apps.vectorsearch.api.v1.urls', description="The {plural}' REST reads, for superusers, and their runs, for any user who may read them.", resources=None, tag_name=None, mount=None), ApiFamily(name='extension', resource='extension', urlconf='smarter.apps.llmtool.extension.api.v1.urls', description="The {plural}: what every user's account may use, and their management by superusers.", resources=None, tag_name=None, mount=None))
Every family that the document covers, in the order of the document’s tags.
( ApiFamily(name='llmclient', resource='LLMClient', urlconf='smarter.apps.llmclient.api.v1.urls', description="The {plural}' REST reads.", resources=None, tag_name=None, mount='llm-clients'), ApiFamily(name='guardrail', resource='Guardrail', urlconf='smarter.apps.guardrail.api.v1.urls', description="The {plural}' REST reads, and their dry run.", resources=None, tag_name=None, mount=None), ApiFamily(name='secret', resource='Secret', urlconf='smarter.apps.secret.api.v1.urls', description="The {plural}' REST reads: their metadata, never their values.", resources=None, tag_name=None, mount=None), ApiFamily(name='mcpclient', resource='MCPClient', urlconf='smarter.apps.mcpclient.api.v1.urls', description="The {plural}' REST reads, their reconnection, and tool calls.", resources=None, tag_name=None, mount=None), ApiFamily(name='vectorstore', resource='vectorstore', urlconf='smarter.apps.vectorstore.api.v1.urls', description="The {plural}' REST reads, search, documents and maintenance. Served only when the platform enables {plural} (SMARTER_APP_VECTORSTORE_ENABLE).", resources=None, tag_name=None, mount=None), ApiFamily(name='llmhost', resource='LLMHost', urlconf='smarter.apps.llmhost.api.v1.urls', description="The {plural}' REST reads, model discovery, and deployment.", resources=None, tag_name=None, mount=None), ApiFamily(name='plugin', resource='plugin', urlconf='smarter.apps.llmtool.api.v1.urls', description="The {plural}' REST reads.", resources=None, tag_name=None, mount=None), ApiFamily(name='provider', resource='Provider', urlconf='smarter.apps.provider.api.v1.urls', description="The LLM {plural}' REST reads, and their models.", resources=None, tag_name=None, mount=None), ApiFamily(name='proxy', resource='Proxy', urlconf='smarter.apps.proxy.api.v1.urls', description='The {plural} that the user may use. Served only when the platform enables {plural} (SMARTER_APP_PROXY_ENABLE).', resources='Proxies', tag_name=None, mount='proxy'), ApiFamily(name='account', resource='account', urlconf='smarter.apps.account.api.v1.urls', description='The {plural}, their users and contacts. For superusers.', resources=None, tag_name=None, mount=None), ApiFamily(name='history', resource='chat session', urlconf='smarter.apps.prompt.api.v1.urls', description='The {plural}, and their tool calls and plugin usage.', resources=None, tag_name='history', mount='prompts'), ApiFamily(name='journal', resource='journal entry', urlconf='smarter.lib.journal.api.v1.urls', description='The Smarter Journal: a record of every journaled request to the Smarter api. For superusers.', resources=None, tag_name='journal', mount=None), ApiFamily(name='orchestrator', resource='Orchestrator', urlconf='smarter.apps.orchestrator.api.v1.urls', description="The {plural}' REST reads, for superusers, and their runs, for any user who may read them.", resources=None, tag_name=None, mount=None), ApiFamily(name='vectorsearch', resource='Vectorsearch', urlconf='smarter.apps.vectorsearch.api.v1.urls', description="The {plural}' REST reads, for superusers, and their runs, for any user who may read them.", resources=None, tag_name=None, mount=None), ApiFamily(name='extension', resource='extension', urlconf='smarter.apps.llmtool.extension.api.v1.urls', description="The {plural}: what every user's account may use, and their management by superusers.", resources=None, tag_name=None, mount=None), )
The LLMClients’ REST reads, under /api/v1/llm-clients/.
Their chat api is in smarter.apps.api.v1.contract.openapi.chat.
- smarter.apps.api.v1.contract.openapi.families.llmclient.LLMCLIENTS = ApiFamily(name='llmclient', resource='LLMClient', urlconf='smarter.apps.llmclient.api.v1.urls', description="The {plural}' REST reads.", resources=None, tag_name=None, mount='llm-clients')
its REST reads, and the chat api, whose routes it shares.
- Type:
The LLMClients’ family
- smarter.apps.api.v1.contract.openapi.families.llmclient.LLMCLIENT_ID_PARAMETER = OpenApiParameter(name='id', in_='path', description="The LLMClient's numeric id, e.g. 12, or its hashed id, e.g. rMTAwMDAxMgx.", required=True, schema_={'type': 'string'})
its numeric id or its hashed id.
- Type:
The
{id}of an LLMClient’s routes
- smarter.apps.api.v1.contract.openapi.families.llmclient.llmclient_paths()[source]
The REST reads of the LLMClients, relative to the server’s
/api/v1.An LLMClient is read by its numeric id or its hashed id. Its related rows, by its numeric id only: their routes take no hashed id.
- Returns:
The paths, e.g.
{"/llm-clients/": ...}.- Return type:
The Guardrails’ REST reads, and the dry run of a Guardrail, under /api/v1/guardrails/.
- smarter.apps.api.v1.contract.openapi.families.guardrail.GUARDRAILS = ApiFamily(name='guardrail', resource='Guardrail', urlconf='smarter.apps.guardrail.api.v1.urls', description="The {plural}' REST reads, and their dry run.", resources=None, tag_name=None, mount=None)
The Guardrails’ family.
- smarter.apps.api.v1.contract.openapi.families.guardrail.guardrail_paths()[source]
The Guardrails’ REST reads, and the dry run of a Guardrail, relative to the server’s
/api/v1.- Returns:
The paths, e.g.
{"/guardrails/": ...}.- Return type:
The Secrets’ REST reads, under /api/v1/secrets/: their metadata, never their values.
- smarter.apps.api.v1.contract.openapi.families.secret.SECRETS = ApiFamily(name='secret', resource='Secret', urlconf='smarter.apps.secret.api.v1.urls', description="The {plural}' REST reads: their metadata, never their values.", resources=None, tag_name=None, mount=None)
The Secrets’ family.
- smarter.apps.api.v1.contract.openapi.families.secret.secret_paths()[source]
The Secrets’ REST reads, relative to the server’s
/api/v1.A Secret’s value is never returned.
- Returns:
The paths, e.g.
{"/secrets/": ...}.- Return type:
The MCPClients’ REST reads, their reconnection, and the call of a tool, under /api/v1/mcpclients/.
- smarter.apps.api.v1.contract.openapi.families.mcpclient.MCPCLIENTS = ApiFamily(name='mcpclient', resource='MCPClient', urlconf='smarter.apps.mcpclient.api.v1.urls', description="The {plural}' REST reads, their reconnection, and tool calls.", resources=None, tag_name=None, mount=None)
The MCPClients’ family.
- smarter.apps.api.v1.contract.openapi.families.mcpclient.mcpclient_paths()[source]
The MCPClients’ REST reads, their reconnection, and the call of a tool, relative to the server’s
/api/v1.- Returns:
The paths, e.g.
{"/mcpclients/": ...}.- Return type:
The vectorstores’ REST reads, search, documents and maintenance, under /api/v1/vectorstores/.
- smarter.apps.api.v1.contract.openapi.families.vectorstore.VECTORSTORES = ApiFamily(name='vectorstore', resource='vectorstore', urlconf='smarter.apps.vectorstore.api.v1.urls', description="The {plural}' REST reads, search, documents and maintenance. Served only when the platform enables {plural} (SMARTER_APP_VECTORSTORE_ENABLE).", resources=None, tag_name=None, mount=None)
The vectorstores’ family.
Its resource is its app’s name: the descriptions write it in lowercase.
- smarter.apps.api.v1.contract.openapi.families.vectorstore.vectorstore_paths()[source]
The vectorstores’ REST reads and maintenance, relative to the server’s
/api/v1.Reading and searching need read permission. Everything else needs ownership.
- Returns:
The paths, e.g.
{"/vectorstores/": ...}.- Return type:
The LLMHosts’ REST reads, model discovery and deployment, under /api/v1/llmhosts/.
- smarter.apps.api.v1.contract.openapi.families.llmhost.LLMHOSTS = ApiFamily(name='llmhost', resource='LLMHost', urlconf='smarter.apps.llmhost.api.v1.urls', description="The {plural}' REST reads, model discovery, and deployment.", resources=None, tag_name=None, mount=None)
The LLMHosts’ family.
- smarter.apps.api.v1.contract.openapi.families.llmhost.llmhost_paths()[source]
The LLMHosts’ REST reads, discovery and deployment, relative to the server’s
/api/v1.- Returns:
The paths, e.g.
{"/llmhosts/": ...}.- Return type:
The plugins’ REST reads, under /api/v1/plugins/: the llmtool app’s plugins.
- smarter.apps.api.v1.contract.openapi.families.plugin.PLUGINS = ApiFamily(name='plugin', resource='plugin', urlconf='smarter.apps.llmtool.api.v1.urls', description="The {plural}' REST reads.", resources=None, tag_name=None, mount=None)
The plugins’ family.
The llmtool app serves it, but its operations are named after its resource.
- smarter.apps.api.v1.contract.openapi.families.plugin.plugin_paths()[source]
The plugins’ REST reads, relative to the server’s
/api/v1.- Returns:
The paths, e.g.
{"/plugins/": ...}.- Return type:
The LLM Providers’ REST reads, and their models, under /api/v1/providers/.
- smarter.apps.api.v1.contract.openapi.families.provider.PROVIDERS = ApiFamily(name='provider', resource='Provider', urlconf='smarter.apps.provider.api.v1.urls', description="The LLM {plural}' REST reads, and their models.", resources=None, tag_name=None, mount=None)
The Providers’ family.
- smarter.apps.api.v1.contract.openapi.families.provider.provider_paths()[source]
The Providers’ REST reads, relative to the server’s
/api/v1.A Provider is read by its name.
- Returns:
The paths, e.g.
{"/providers/": ...}.- Return type:
The Proxies’ list, under /api/v1/proxy/.
Their passthroughs are the LLM providers’ own apis.
- smarter.apps.api.v1.contract.openapi.families.proxy.PROXIES = ApiFamily(name='proxy', resource='Proxy', urlconf='smarter.apps.proxy.api.v1.urls', description='The {plural} that the user may use. Served only when the platform enables {plural} (SMARTER_APP_PROXY_ENABLE).', resources='Proxies', tag_name=None, mount='proxy')
The Proxies’ family, whose routes are mounted at its app’s name, in the singular.
Its plural is given: inflect adds only an s to a capitalized Proxy.
- smarter.apps.api.v1.contract.openapi.families.proxy.proxy_paths()[source]
The Proxies’ list, relative to the server’s
/api/v1.Their passthroughs are the providers’ apis.
- Returns:
The paths, e.g.
{"/proxy/": ...}.- Return type:
The accounts’ REST reads, under /api/v1/accounts/, for superusers, and the user’s own token usage and data exports.
- smarter.apps.api.v1.contract.openapi.families.account.ACCOUNTS = ApiFamily(name='account', resource='account', urlconf='smarter.apps.account.api.v1.urls', description='The {plural}, their users and contacts. For superusers.', resources=None, tag_name=None, mount=None)
The accounts’ family.
Its routes also serve the user’s own token usage and data exports, tagged
TAG_USAGE.
- smarter.apps.api.v1.contract.openapi.families.account.OWN_DATA = 'Requires an api key. Every user may call it, for their own data only.'
their token usage and data exports.
- Type:
The note of the operations on the requesting user’s own data
- smarter.apps.api.v1.contract.openapi.families.account.TAG_USAGE = 'usage'
The tag of the user’s own token usage and data exports, which are not an app’s family, but the account app’s.
- smarter.apps.api.v1.contract.openapi.families.account.USAGE_TAG = OpenApiTag(name='usage', description="The user's own token usage and data exports.")
The document’s tag of the user’s own token usage and data exports.
- smarter.apps.api.v1.contract.openapi.families.account.account_paths()[source]
The accounts’ REST reads, relative to the server’s
/api/v1.Only superusers may call them. Each of the four resources, the accounts, their users, the user profiles (each user’s membership of an account) and the account contacts, has a list and a retrieve by id.
- Returns:
The paths, e.g.
{"/accounts/": ...}.- Return type:
- smarter.apps.api.v1.contract.openapi.families.account.usage_paths()[source]
The requesting user’s own token usage and data exports, relative to the server’s
/api/v1.They are under
/accounts/, whose other reads are for superusers, but every user may call them.- Returns:
The paths, e.g.
{"/accounts/usage/": ...}.- Return type:
The prompt history’s REST reads, under /api/v1/prompts/history/: the chat sessions, their tool calls and plugin usage.
- smarter.apps.api.v1.contract.openapi.families.history.HISTORY = ApiFamily(name='history', resource='chat session', urlconf='smarter.apps.prompt.api.v1.urls', description='The {plural}, and their tool calls and plugin usage.', resources=None, tag_name='history', mount='prompts')
a feature of the prompt app, whose routes are under the app’s
/prompts/.Its operations’ ids and its tag are the feature’s name, history, not the app’s.
- Type:
The prompt history’s family
- smarter.apps.api.v1.contract.openapi.families.history.HISTORY_PERMISSION = "Requires an api key. The response includes only the chat sessions whose user the user may manage: their own, their account's users' for an account admin, and every one for a superuser."
The note of the prompt history’s reads.
- smarter.apps.api.v1.contract.openapi.families.history.history_paths()[source]
The prompt history’s REST reads, relative to the server’s
/api/v1, newest first.- Returns:
The paths, e.g.
{"/prompts/history/prompt/": ...}.- Return type:
The Smarter Journal’s REST reads, under /api/v1/journal/: a record of every journaled request to the Smarter api.
- smarter.apps.api.v1.contract.openapi.families.journal.JOURNAL = ApiFamily(name='journal', resource='journal entry', urlconf='smarter.lib.journal.api.v1.urls', description='The Smarter Journal: a record of every journaled request to the Smarter api. For superusers.', resources=None, tag_name='journal', mount=None)
The Smarter Journal’s family, whose tag, and so its routes, are its name, in the singular.
- smarter.apps.api.v1.contract.openapi.families.journal.journal_paths()[source]
The Smarter Journal’s REST reads, relative to the server’s
/api/v1.Only superusers may call them.
- Returns:
The paths, e.g.
{"/journal/": ...}.- Return type:
The Orchestrators’ REST reads, under /api/v1/orchestrators/, and their runs.
The reads are for superusers. Any user may start a run of an Orchestrator that they may read, and read the runs that they started (ADR-037).
- smarter.apps.api.v1.contract.openapi.families.orchestrator.ORCHESTRATORS = ApiFamily(name='orchestrator', resource='Orchestrator', urlconf='smarter.apps.orchestrator.api.v1.urls', description="The {plural}' REST reads, for superusers, and their runs, for any user who may read them.", resources=None, tag_name=None, mount=None)
The Orchestrators’ family.
- smarter.apps.api.v1.contract.openapi.families.orchestrator.orchestrator_paths()[source]
The Orchestrators’ REST reads, relative to the server’s
/api/v1.Only superusers may call them.
- Returns:
The paths, e.g.
{"/orchestrators/": ...}.- Return type:
The Vectorsearches’ REST reads, for superusers, and the run of a Vectorsearch, under /api/v1/vectorsearches/.
- smarter.apps.api.v1.contract.openapi.families.vectorsearch.VECTORSEARCHES = ApiFamily(name='vectorsearch', resource='Vectorsearch', urlconf='smarter.apps.vectorsearch.api.v1.urls', description="The {plural}' REST reads, for superusers, and their runs, for any user who may read them.", resources=None, tag_name=None, mount=None)
The Vectorsearches’ family.
- smarter.apps.api.v1.contract.openapi.families.vectorsearch.vectorsearch_paths()[source]
The Vectorsearches’ REST reads, and the run of a Vectorsearch, relative to the server’s
/api/v1.Only superusers may read them. Any user who may read a Vectorsearch may run it.
- Returns:
The paths, e.g.
{"/vectorsearches/": ...}.- Return type:
The extensions’ REST reads and actions, under /api/v1/extensions/: what the web console’s Extensions pages do.
Every user may read the extensions that their account may use. Only superusers may act on them.
- smarter.apps.api.v1.contract.openapi.families.extension.EXTENSIONS = ApiFamily(name='extension', resource='extension', urlconf='smarter.apps.llmtool.extension.api.v1.urls', description="The {plural}: what every user's account may use, and their management by superusers.", resources=None, tag_name=None, mount=None)
The extensions’ family.
Its resource is its name: the descriptions write it in lowercase.
- smarter.apps.api.v1.contract.openapi.families.extension.EXTENSION_ACTION = 'Only superusers may call it: others get a 403.'
The note of the extensions’ actions.
- smarter.apps.api.v1.contract.openapi.families.extension.EXTENSION_READ = "Requires an api key. A user who is not a superuser sees only the extensions that their account may use, and receives their settings, the accounts that may use them and the platform admin's Secrets as empty lists, and who installed each version as null."
The note of the extensions’ reads.
- smarter.apps.api.v1.contract.openapi.families.extension.extension_paths()[source]
The extensions’ REST reads and actions, relative to the server’s
/api/v1.They are what the web console’s Extensions pages do. Every user may read the extensions that their account may use. Only superusers may act on them.
- Returns:
The paths, e.g.
{"/extensions/": ...}.- Return type:
The Smarter api’s OpenAPI document, GET /api/v1/openapi.json.
The document is the committed openapi.json of smarter.apps.api.v1.contract: the typed
OpenAPI 3.1 contract of the cli api, the chat api and the REST reads, from which clients and SDKs
are generated. The web console’s OpenAPI page renders it with Scalar, and /docs/openapi.json,
its earlier address, redirects here.
It is public: the document describes the api, and holds no data.
- class smarter.apps.api.v1.contract.views.ApiV1OpenApiJsonView(**kwargs)[source]
The Smarter api’s OpenAPI 3.1 document, as JSON.
- get(request, *args, **kwargs)[source]
Return the document.
- Parameters:
request (
HttpRequest) – The request.- Returns:
The document, indented, as JSON.
- smarter.apps.api.v1.contract.views.openapi_document(request)[source]
The committed OpenAPI document, whose first server is the platform that serves it.
The committed document’s servers are the default platform’s and a local one. This platform’s own
/api/v1, relative to the document’s url, is added before them, so that a viewer’s requests, e.g. Scalar’s “Test Request”, go to the platform that the reader is on.- Parameters:
request (
HttpRequest) – The request for the document.- Returns:
The document.
- Return type:
Pydantic models of the account data that the REST api’s responses include.
A resource that a user owns, e.g. an LLMClient or a plugin, is returned with its owner, as
AccountApiUserProfile: the owner’s username and email, and their account’s number. It is
the output of smarter.apps.account.serializers.UserProfileSerializer, which the REST api
returned before it was modeled, and which clients already read.
The accounts’ REST api (/api/v1/accounts/), which only superusers may call, returns accounts
(AccountApiAccountDetail), users (AccountApiUserDetail), user profiles
(AccountApiProfile) and account contacts (AccountApiContact): the outputs of
smarter.apps.account.serializers.AccountSerializer, UserSerializer and
AccountContactSerializer, which clients already read.
The models forbid extra fields: the api returns exactly what they declare.
- smarter.apps.account.contract.models.ACCOUNT_API_MODELS = (<class 'smarter.apps.account.contract.models.AccountApiAccountDetail'>, <class 'smarter.apps.account.contract.models.AccountApiUserDetail'>, <class 'smarter.apps.account.contract.models.AccountApiProfile'>, <class 'smarter.apps.account.contract.models.AccountApiContact'>)
The models whose JSON Schemas the Smarter api’s OpenAPI document includes.
( <class 'smarter.apps.account.contract.models.AccountApiAccountDetail'>, <class 'smarter.apps.account.contract.models.AccountApiUserDetail'>, <class 'smarter.apps.account.contract.models.AccountApiProfile'>, <class 'smarter.apps.account.contract.models.AccountApiContact'>, )
- class smarter.apps.account.contract.models.AccountApiAccount(*, accountNumber)[source]
Bases:
AccountApiModelAn account, as the owner of a resource: a
smarter.apps.account.models.Account’s number.- classmethod from_model(account)[source]
The contract’s model of an account.
- Parameters:
account (
Account) – The row.- Returns:
The model.
- Return type:
- Raises:
ValueError – when the account has no account number.
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- class smarter.apps.account.contract.models.AccountApiAccountDetail(*, id, hashedId, createdAt=None, updatedAt=None, name, description=None, version=None, tags=<factory>, annotations=None, accountNumber=None, isDefaultAccount, companyName, phoneNumber=None, address1=None, address2=None, city=None, state=None, postalCode=None, country=None, language=None, timezone=None, currency=None, isActive)[source]
Bases:
AccountApiModelAn account: a
smarter.apps.account.models.Account.- classmethod from_model(account)[source]
The contract’s model of an account.
- Parameters:
account (
Account) – The row.- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- class smarter.apps.account.contract.models.AccountApiContact(*, id, account, createdAt=None, updatedAt=None, firstName, lastName, email, phone=None, isPrimary, isTest, welcomed, welcomedAt=None, slackInvitedAt=None, unsubscribedAt=None)[source]
Bases:
AccountApiModelA contact of an account, who receives its notices: a
smarter.apps.account.models.AccountContact.- account: AccountApiAccount
- classmethod from_model(contact)[source]
The contract’s model of an account contact.
- Parameters:
contact (
AccountContact) – The row, whoseaccountshould be fetched with it.- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- class smarter.apps.account.contract.models.AccountApiModel[source]
Bases:
BaseModelBase class of the account contract’s models.
The api’s JSON is camelCase, e.g.
accountNumber. The models’ fields are snake_case, and their camelCase aliases are what they validate and dump.- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- class smarter.apps.account.contract.models.AccountApiProfile(*, id, hashedId, createdAt=None, updatedAt=None, name, description=None, version=None, tags=<factory>, annotations=None, user, account, profileImageUrl=None, profileImage=None, isTest, isAccountAdmin=False)[source]
Bases:
AccountApiModelA user’s membership of an account: a
smarter.apps.account.models.UserProfile.- account: AccountApiAccount
- classmethod from_model(user_profile)[source]
The contract’s model of a user profile.
- Parameters:
user_profile (
UserProfile) – The row, whoseuserandaccountshould be fetched with it.- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- user: AccountApiUserDetail
- class smarter.apps.account.contract.models.AccountApiUser(*, username, email=None)[source]
Bases:
AccountApiModelA user, as the owner of a resource: a
django.contrib.auth.models.User’s username and email.- classmethod from_model(user)[source]
The contract’s model of a user.
- Parameters:
user (
User) – The row.- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- class smarter.apps.account.contract.models.AccountApiUserDetail(*, id, username, firstName='', lastName='', email='', isStaff, isSuperuser)[source]
Bases:
AccountApiModelA user: a
django.contrib.auth.models.User, without its password and permissions.- classmethod from_model(user)[source]
The contract’s model of a user.
- Parameters:
user (
User) – The row.- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- class smarter.apps.account.contract.models.AccountApiUserProfile(*, user, account)[source]
Bases:
AccountApiModelThe owner of a resource: a
smarter.apps.account.models.UserProfile’s user and account.- account: AccountApiAccount
- classmethod from_model(user_profile)[source]
The contract’s model of a resource’s owner.
- Parameters:
user_profile (
UserProfile) – The row, whoseuserandaccountshould be fetched with it.- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- user: AccountApiUser
- smarter.apps.account.contract.models.MetaDataApiAnnotations = dict[str, str] | None
a map of keys to string values, as in Kubernetes, e.g.
{"acme.com/crm-account-id": "A-10042"}.- Type:
MetaDataModel.annotations
Pydantic models of the plugin data that the REST api’s responses include.
PluginApiPluginMeta is a plugin’s metadata, as the REST api returns it, e.g. in an
LLMClient’s plugins. It is the output of smarter.apps.llmtool.serializers.PluginMetaSerializer,
which the REST api returned before it was modeled, and which clients already read: the owner is
nested, rather than its id.
The models forbid extra fields: the api returns exactly what they declare.
- smarter.apps.llmtool.contract.models.PluginApiPluginClass
the choices of
PluginMeta.plugin_class.A test fails if the two differ.
- Type:
A plugin’s class
alias of
Literal[‘api’, ‘skill’, ‘sql’, ‘static’, ‘websearch’, ‘imagesearch’]
- class smarter.apps.llmtool.contract.models.PluginApiPluginMeta(*, id, createdAt=None, updatedAt=None, name, userProfile, description=None, pluginClass, version=None, annotations=None, tags=<factory>, manifestUrl, ready, kind, canDelete, detailUrl=None)[source]
Bases:
AccountApiModelA plugin’s metadata: a
smarter.apps.llmtool.models.PluginMeta.- classmethod from_model(plugin_meta, user=None)[source]
The contract’s model of a plugin’s metadata.
- Parameters:
plugin_meta (
PluginMeta) – The row, whoseuser_profileand tags should be fetched with it.user (
object) – The requesting user, forcan_delete. None may delete nothing.
- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- user_profile: AccountApiUserProfile
Pydantic models of the LLMClients’ REST api responses (/api/v1/llm-clients/).
The REST api’s views build their responses from these models, and the Smarter api’s OpenAPI
document (smarter.apps.api.v1.contract.openapi) publishes their JSON Schemas. Each model
is built from its row by from_model().
They describe the JSON that smarter.apps.llmclient.serializers produced before the api
was modeled, which clients already read: camelCase keys, an LLMClient’s owner nested rather than
its id, and an LLMClient’s related rows inline. Two values changed: canDelete is computed for
the requesting user, where the serializers, called without a request, always said false, and an api
key’s apiKey is its token’s public key_id, where it was the token’s digest.
The models forbid extra fields: the api returns exactly what they declare. Adding a field is backward compatible. Removing or renaming one is not.
- smarter.apps.llmclient.contract.models.LLMCLIENT_API_MODELS = (<class 'smarter.apps.llmclient.contract.models.LLMClientApiLLMClient'>, <class 'smarter.apps.llmclient.contract.models.LLMClientApiPlugin'>, <class 'smarter.apps.llmclient.contract.models.LLMClientApiExtension'>, <class 'smarter.apps.llmclient.contract.models.LLMClientApiKey'>, <class 'smarter.apps.llmclient.contract.models.LLMClientApiCustomDomain'>)
The models whose JSON Schemas the Smarter api’s OpenAPI document includes.
Their dependencies are included with them.
( <class 'smarter.apps.llmclient.contract.models.LLMClientApiLLMClient'>, <class 'smarter.apps.llmclient.contract.models.LLMClientApiPlugin'>, <class 'smarter.apps.llmclient.contract.models.LLMClientApiExtension'>, <class 'smarter.apps.llmclient.contract.models.LLMClientApiKey'>, <class 'smarter.apps.llmclient.contract.models.LLMClientApiCustomDomain'>, )
- class smarter.apps.llmclient.contract.models.LLMClientApiCustomDomain(*, id, createdAt=None, updatedAt=None, name, description=None, version=None, annotations=None, userProfile, awsHostedZoneId, domainName, verificationStatus, verifiedAt=None, verificationMessage)[source]
Bases:
LLMClientApiOrmModelA custom domain of an LLMClient: a
smarter.apps.llmclient.models.LLMClientCustomDomain.- classmethod from_model(custom_domain)[source]
The contract’s model of a custom domain.
- Parameters:
custom_domain (
LLMClientCustomDomain) – The row.- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- smarter.apps.llmclient.contract.models.LLMClientApiDnsVerificationStatus
The choices of
LLMClient.dns_verification_status.A test fails if the two differ.
alias of
Literal[‘Verifying’, ‘Not Verified’, ‘Verified’, ‘Failed’]
- class smarter.apps.llmclient.contract.models.LLMClientApiExtension(*, id, createdAt=None, updatedAt=None, name, extension, llmclient)[source]
Bases:
LLMClientApiOrmModelAn extension of an LLMClient: a
smarter.apps.llmclient.models.LLMClientExtensions.- classmethod from_model(link)[source]
The contract’s model of an extension of an LLMClient.
- Parameters:
link (
LLMClientExtensions) – The row, whoseextensionshould be fetched with it.- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- class smarter.apps.llmclient.contract.models.LLMClientApiGuardrailRef(*, id, name)[source]
Bases:
AccountApiModelA Guardrail of an LLMClient, in the LLMClient’s own response: the LLMClientGuardrails’ id, and the Guardrail’s name.
- classmethod from_model(link)[source]
The contract’s reference to a Guardrail of an LLMClient.
- Parameters:
link (
LLMClientGuardrails) – The row, whoseguardrailshould be fetched with it.- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- class smarter.apps.llmclient.contract.models.LLMClientApiKey(*, id, createdAt=None, updatedAt=None, llmclient, apiKey)[source]
Bases:
LLMClientApiOrmModelAn api key of an LLMClient: a
smarter.apps.llmclient.models.LLMClientAPIKey.- classmethod from_model(api_key)[source]
The contract’s model of an api key of an LLMClient.
- Parameters:
api_key (
LLMClientAPIKey) – The row, whoseapi_keyshould be fetched with it.- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- class smarter.apps.llmclient.contract.models.LLMClientApiLLMClient(*, id, createdAt=None, updatedAt=None, hashedId, name, description=None, version=None, tags=<factory>, annotations=None, userProfile, canDelete, detailUrl=None, extensions, plugins, mcpclients, vectorsearches, guardrails, tools, customDomains, apiKeys, rfc1034CompliantName=None, defaultSystemRole=None, baseApiDomain=None, baseDefaultHost=None, defaultHost=None, defaultUrl=None, customHost=None, customUrl=None, sandboxHost=None, sandboxUrl=None, manifestUrl=None, hostname=None, url=None, urlLlmclient=None, urlChatConfig=None, urlChatapp=None, ready, isAuthenticationRequired, deployed=None, provider=None, defaultModel=None, defaultTemperature=None, defaultReasoningEffort=None, defaultMaxTokens=None, appName=None, appAssistant=None, appWelcomeMessage=None, appExamplePrompts=None, appPlaceholder=None, appInfoUrl=None, appFileAttachment=None, styles=None, allowedOrigins, staffOnly, dnsVerificationStatus=None, tlsCertificateIssuanceStatus=None, subdomain=None, customDomain=None)[source]
Bases:
LLMClientApiOrmModelAn LLMClient: a
smarter.apps.llmclient.models.LLMClient, with its related rows and its urls.Its
extensions,plugins,custom_domainsandapi_keysare inline, and its urls and hosts are computed, as the LLMClient’s properties compute them for the platform that serves the request.- api_keys: list[LLMClientApiKey]
- custom_domains: list[LLMClientApiCustomDomain]
- extensions: list[LLMClientApiExtension]
- classmethod from_model(llmclient, user=None)[source]
The contract’s model of an LLMClient.
- Parameters:
- Returns:
The model.
- Return type:
- guardrails: list[LLMClientApiGuardrailRef]
- mcpclients: list[LLMClientApiMCPClientRef]
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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: list[LLMClientApiPluginRef]
- tools: list[LLMClientApiTool]
- user_profile: AccountApiUserProfile
- class smarter.apps.llmclient.contract.models.LLMClientApiMCPClientRef(*, id, name)[source]
Bases:
AccountApiModelAn MCPClient of an LLMClient, in the LLMClient’s own response: the LLMClientMCPClients’ id, and the MCPClient’s name.
- classmethod from_model(link)[source]
The contract’s reference to an MCPClient of an LLMClient.
- Parameters:
link (
LLMClientMCPClients) – The row, whosemcpclientshould be fetched with it.- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- class smarter.apps.llmclient.contract.models.LLMClientApiOrmModel(*, id, createdAt=None, updatedAt=None)[source]
Bases:
AccountApiModelBase class of the models of LLMClient rows: their primary key and timestamps.
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- class smarter.apps.llmclient.contract.models.LLMClientApiPlugin(*, id, createdAt=None, updatedAt=None, pluginMeta, llmclient)[source]
Bases:
LLMClientApiOrmModelA plugin of an LLMClient: a
smarter.apps.llmclient.models.LLMClientPlugin, with the plugin’s metadata.- classmethod from_model(plugin, user=None)[source]
The contract’s model of a plugin of an LLMClient.
- Parameters:
plugin (
LLMClientPlugin) – The row, whoseplugin_metashould be fetched with it.user (
object) – The requesting user, for the plugin’scanDelete.
- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- plugin_meta: PluginApiPluginMeta
- class smarter.apps.llmclient.contract.models.LLMClientApiPluginRef(*, id, name)[source]
Bases:
AccountApiModelA plugin of an LLMClient, in the LLMClient’s own response: the LLMClientPlugin’s id, and the plugin’s name.
- classmethod from_model(plugin)[source]
The contract’s reference to a plugin of an LLMClient.
- Parameters:
plugin (
LLMClientPlugin) – The row, whoseplugin_metashould be fetched with it.- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- smarter.apps.llmclient.contract.models.LLMClientApiTlsCertificateIssuanceStatus
The choices of
LLMClient.tls_certificate_issuance_status.A test fails if the two differ.
alias of
Literal[‘No Certificate’, ‘Requested’, ‘Issued’, ‘Failed’]
- class smarter.apps.llmclient.contract.models.LLMClientApiTool(*, id, name, kind)[source]
Bases:
AccountApiModelSomething that an LLMClient adds to a prompt: an extension, plugin, MCPClient, Vectorsearch or guardrail.
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- smarter.apps.llmclient.contract.models.LLMClientApiToolKind
an extension, or the linked resource’s manifest kind.
- Type:
What adds a tool to an LLMClient’s prompts
alias of
Literal[‘Extension’, ‘Plugin’, ‘MCPClient’, ‘Vectorsearch’, ‘Guardrail’]
- smarter.apps.llmclient.contract.models.LLMClientApiVerificationStatus
The choices of
LLMClientCustomDomain.verification_status.A test fails if the two differ.
alias of
Literal[‘Not Verified’, ‘Verifying’, ‘Verified’, ‘Failed’]
Pydantic models of the Guardrails’ REST api requests and responses (/api/v1/guardrails/).
The REST api’s views build their responses from these models, and the Smarter api’s OpenAPI
document (smarter.apps.api.v1.contract.openapi) publishes their JSON Schemas.
GuardrailApiGuardrail is a Guardrail, as smarter.apps.guardrail.serializers.GuardrailSerializer
returned it before the api was modeled, and GuardrailApiEvent an event, as
GuardrailEventSerializer returned it. Clients already
read them, so their shapes are kept: a Guardrail’s keys are camelCase, and an event’s snake_case.
One value changed: a Guardrail’s canDelete is computed for the requesting user. The serializer
was called without a request, so it was always false.
The models forbid extra fields: the api returns exactly what they declare.
- smarter.apps.guardrail.contract.models.GUARDRAIL_API_MODELS = (<class 'smarter.apps.guardrail.contract.models.GuardrailApiGuardrail'>, <class 'smarter.apps.guardrail.contract.models.GuardrailApiEvents'>, <class 'smarter.apps.guardrail.contract.models.GuardrailApiEvaluateRequest'>, <class 'smarter.apps.guardrail.contract.models.GuardrailApiEvaluation'>)
The models whose JSON Schemas the Smarter api’s OpenAPI document includes.
Their dependencies are included with them.
( <class 'smarter.apps.guardrail.contract.models.GuardrailApiGuardrail'>, <class 'smarter.apps.guardrail.contract.models.GuardrailApiEvents'>, <class 'smarter.apps.guardrail.contract.models.GuardrailApiEvaluateRequest'>, <class 'smarter.apps.guardrail.contract.models.GuardrailApiEvaluation'>, )
- smarter.apps.guardrail.contract.models.GuardrailApiAction
The choices of
Guardrail.action.A test fails if the two differ.
alias of
Literal[‘log’, ‘flag’, ‘redact’, ‘transform’, ‘block’, ‘escalate’]
- smarter.apps.guardrail.contract.models.GuardrailApiCategory
The choices of
Guardrail.category.A test fails if the two differ.
alias of
Literal[‘pii’, ‘secrets’, ‘prompt_injection’, ‘jailbreak’, ‘toxicity’, ‘self_harm’, ‘hallucination’, ‘off_topic’, ‘compliance’, ‘formatting’, ‘custom’]
- class smarter.apps.guardrail.contract.models.GuardrailApiEvaluateRequest(*, text, stage='input')[source]
Bases:
GuardrailApiSnakeModelThe request body of a dry run of a Guardrail on a text.
- model_config = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.guardrail.contract.models.GuardrailApiEvaluation(*, guardrail, stage, triggered, disposition, text, message=None, error=None, durationMs=None, findings)[source]
Bases:
AccountApiModelThe result of a dry run of a Guardrail on a text.
It records no events.
- disposition: PipelineDisposition
- findings: list[GuardrailApiFinding]
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- class smarter.apps.guardrail.contract.models.GuardrailApiEvent(*, id, created_at=None, updated_at=None, guardrail=None, guardrail_name, llmclient=None, session_key=None, stage, category, strategy, action, mode, disposition, severity, confidence=None, excerpt=None, rationale=None, error=None, reviewed)[source]
Bases:
GuardrailApiSnakeModelA Guardrail’s event: a
smarter.apps.guardrail.models.GuardrailEvent, a record of what it did to a prompt.Its keys are snake_case: the serializer that the api used was not camelCase.
- category: Literal['pii', 'secrets', 'prompt_injection', 'jailbreak', 'toxicity', 'self_harm', 'hallucination', 'off_topic', 'compliance', 'formatting', 'custom']
- disposition: Literal['logged', 'flagged', 'redacted', 'transformed', 'blocked', 'escalated', 'monitored', 'error']
- classmethod from_model(event)[source]
The contract’s model of a Guardrail’s event.
- Parameters:
event (
GuardrailEvent) – The row, whosellmclientshould be fetched with it.- Returns:
The model.
- Return type:
- model_config = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- smarter.apps.guardrail.contract.models.GuardrailApiEventDisposition
what a guardrail did.
A test fails if the two differ.
- Type:
The choices of
GuardrailEvent.disposition
alias of
Literal[‘logged’, ‘flagged’, ‘redacted’, ‘transformed’, ‘blocked’, ‘escalated’, ‘monitored’, ‘error’]
- class smarter.apps.guardrail.contract.models.GuardrailApiEvents(*, guardrail, events)[source]
Bases:
GuardrailApiSnakeModelThe response of a Guardrail’s events: its name, and its latest events, newest first.
- events: list[GuardrailApiEvent]
- model_config = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.guardrail.contract.models.GuardrailApiFinding(*, confidence=None, rationale=None, matches)[source]
Bases:
GuardrailApiSnakeModelWhat a Guardrail found in a text.
- model_config = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.guardrail.contract.models.GuardrailApiGuardrail(*, id, hashedId, createdAt=None, updatedAt=None, name, description=None, version=None, tags=<factory>, annotations=None, userProfile, canDelete, manifestUrl, detailUrl=None, ready, rfc1034CompliantName=None, stage, category, strategy, pattern=None, config=None, threshold=None, action, replacement=None, message=None, severity, mode, failClosed, priority, isActive)[source]
Bases:
AccountApiModelA Guardrail: a
smarter.apps.guardrail.models.Guardrail.- category: Literal['pii', 'secrets', 'prompt_injection', 'jailbreak', 'toxicity', 'self_harm', 'hallucination', 'off_topic', 'compliance', 'formatting', 'custom']
- classmethod from_model(guardrail, user=None)[source]
The contract’s model of a Guardrail.
- Parameters:
- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- user_profile: AccountApiUserProfile
- smarter.apps.guardrail.contract.models.GuardrailApiMode
The choices of
Guardrail.mode.A test fails if the two differ.
alias of
Literal[‘enforce’, ‘monitor’]
- class smarter.apps.guardrail.contract.models.GuardrailApiSnakeModel[source]
Bases:
BaseModelBase class of the guardrail contract’s models whose keys are snake_case, as their api returned them.
- model_config = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- smarter.apps.guardrail.contract.models.GuardrailApiStage
The choices of
Guardrail.stage.A test fails if the two differ.
alias of
Literal[‘input’, ‘output’, ‘both’]
- smarter.apps.guardrail.contract.models.GuardrailApiStrategy
The choices of
Guardrail.strategy.A test fails if the two differ.
alias of
Literal[‘regex’, ‘keyword’, ‘detector’, ‘semantic’, ‘moderation’, ‘llm_judge’]
Pydantic models of the Secrets’ REST api responses (/api/v1/secrets/).
A Secret’s response is its metadata. Its value is never returned.
SecretApiSecret is a Secret, as smarter.apps.secret.serializers.SecretSerializer
returned it before the api was modeled, which clients already read. One value changed: its
canDelete is computed for the requesting user. The serializer was called without a request, so
it was always false.
- smarter.apps.secret.contract.models.SECRET_API_MODELS = (<class 'smarter.apps.secret.contract.models.SecretApiSecret'>,)
The models whose JSON Schemas the Smarter api’s OpenAPI document includes.
(<class 'smarter.apps.secret.contract.models.SecretApiSecret'>, )
- class smarter.apps.secret.contract.models.SecretApiSecret(*, id, createdAt=None, updatedAt=None, name, userProfile, description=None, version=None, annotations=None, tags=<factory>, manifestUrl=None, detailUrl=None, ready, expiresAt=None, lastAccessed=None, canDelete)[source]
Bases:
AccountApiModelA Secret’s metadata: a
smarter.apps.secret.models.Secret, without its value.- classmethod from_model(secret, user=None)[source]
The contract’s model of a Secret.
- Parameters:
- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- user_profile: AccountApiUserProfile
- class smarter.apps.secret.contract.models.SecretApiSecretRef(*, id, name, manifestUrl=None, detailUrl=None, ready, canDelete)[source]
Bases:
AccountApiModelA Secret, as another resource refers to it, e.g. a Provider’s api key: its name, never its value.
- classmethod from_model(secret, user=None)[source]
The contract’s reference to a Secret.
- Parameters:
- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
Pydantic models of the MCPClients’ REST api responses (/api/v1/mcpclients/).
The REST api’s views build their responses from these models, and the Smarter api’s OpenAPI
document (smarter.apps.api.v1.contract.openapi) publishes their JSON Schemas.
MCPClientApiMCPClient is an MCPClient, as smarter.apps.mcpclient.serializers.MCPClientSerializer
returned it before the api was modeled, which clients already read. One value changed: its
canDelete is computed for the requesting user. The other models replace the dicts that the
views built by hand, with the same keys. lastConnected is now an ISO 8601 date-time ending in
Z, where it ended in +00:00: the same instant.
The models forbid extra fields: the api returns exactly what they declare.
- smarter.apps.mcpclient.contract.models.MCPCLIENT_API_MODELS = (<class 'smarter.apps.mcpclient.contract.models.MCPClientApiMCPClient'>, <class 'smarter.apps.mcpclient.contract.models.MCPClientApiStatus'>, <class 'smarter.apps.mcpclient.contract.models.MCPClientApiStatusError'>, <class 'smarter.apps.mcpclient.contract.models.MCPClientApiTools'>, <class 'smarter.apps.mcpclient.contract.models.MCPClientApiToolResult'>)
The models whose JSON Schemas the Smarter api’s OpenAPI document includes.
Their dependencies are included with them.
( <class 'smarter.apps.mcpclient.contract.models.MCPClientApiMCPClient'>, <class 'smarter.apps.mcpclient.contract.models.MCPClientApiStatus'>, <class 'smarter.apps.mcpclient.contract.models.MCPClientApiStatusError'>, <class 'smarter.apps.mcpclient.contract.models.MCPClientApiTools'>, <class 'smarter.apps.mcpclient.contract.models.MCPClientApiToolResult'>, )
- smarter.apps.mcpclient.contract.models.MCPClientApiAuthType
The choices of
MCPClient.auth_type.A test fails if the two differ.
alias of
Literal[‘none’, ‘api_key’, ‘oauth2’, ‘bearer_token’]
- smarter.apps.mcpclient.contract.models.MCPClientApiConnectionStatus
the result of the last connection.
A test fails if the two differ.
- Type:
The choices of
MCPClient.status
alias of
Literal[‘unconfigured’, ‘connected’, ‘disconnected’, ‘error’]
- class smarter.apps.mcpclient.contract.models.MCPClientApiMCPClient(*, id, hashedId, createdAt=None, updatedAt=None, name, description=None, version=None, tags=<factory>, annotations=None, userProfile, canDelete, credentials=None, manifestUrl, detailUrl=None, ready, rfc1034CompliantName=None, transport=None, endpointUrl=None, command=None, headers=None, timeout, authType, apiKeyHeader, allowedTools=None, allowedResources=None, includeInstructions, cacheTtl, isActive, status, priority, protocolVersion=None, serverName=None, serverVersion=None, tools=None, lastConnectedAt=None, lastError=None)[source]
Bases:
AccountApiModelAn MCPClient: a
smarter.apps.mcpclient.models.MCPClient.Its credentials are their Secret’s name.
- classmethod from_model(mcpclient, user=None)[source]
The contract’s model of an MCPClient.
- Parameters:
- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- user_profile: AccountApiUserProfile
- class smarter.apps.mcpclient.contract.models.MCPClientApiStatus(*, name, status, protocolVersion=None, serverName=None, serverVersion=None, lastConnected=None, lastError=None, tools)[source]
Bases:
AccountApiModelAn MCPClient’s connection to its MCP server: the result of the last connection, and what the server reported.
- classmethod from_model(mcpclient)[source]
The connection status of an MCPClient.
- Parameters:
mcpclient (
MCPClient) – The row.- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- class smarter.apps.mcpclient.contract.models.MCPClientApiStatusError(*, name, status, protocolVersion=None, serverName=None, serverVersion=None, lastConnected=None, lastError=None, tools, detail)[source]
Bases:
MCPClientApiStatusA failed connection to an MCP server: the error, beside the MCPClient’s connection status.
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- class smarter.apps.mcpclient.contract.models.MCPClientApiTool(*, name, title=None, description='', inputSchema, readOnly=None, destructive=None)[source]
Bases:
AccountApiModelA tool that an MCP server offers, and that the MCPClient allows.
- classmethod from_tool(tool)[source]
The contract’s model of a tool from an MCP server’s catalog.
- Parameters:
tool (
MCPToolInfo) – The tool.- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- class smarter.apps.mcpclient.contract.models.MCPClientApiToolResult(*, name, tool, isError, content)[source]
Bases:
AccountApiModelThe result of a call of an MCPClient’s tool, as text for an LLM.
- classmethod from_result(mcpclient, tool, result)[source]
The contract’s model of a tool call’s result.
- Parameters:
mcpclient (
MCPClient) – The row.tool (
str) – The tool’s name.result (
MCPToolResult) – The result.
- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- class smarter.apps.mcpclient.contract.models.MCPClientApiTools(*, name, status, protocolVersion=None, serverName=None, serverVersion=None, lastConnected=None, lastError=None, instructions=None, tools)[source]
Bases:
AccountApiModelAn MCPClient’s connection status, its server’s instructions, and the tools that it offers the LLM.
- classmethod from_catalog(mcpclient, catalog, tools)[source]
The tools of an MCPClient, from its server’s catalog.
- Parameters:
mcpclient (
MCPClient) – The row.catalog (
MCPServerCatalog) – The server’s catalog.tools (
list[MCPToolInfo]) – The catalog’s tools that the MCPClient allows.
- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- tools: list[MCPClientApiTool]
- smarter.apps.mcpclient.contract.models.MCPClientApiTransport
The choices of
MCPClient.transport.A test fails if the two differ.
alias of
Literal[‘stdio’, ‘sse’, ‘http’]
Pydantic models of the vectorstores’ REST api requests and responses (/api/v1/vectorstores/).
The REST api’s views build their responses from these models, and the Smarter api’s OpenAPI
document (smarter.apps.api.v1.contract.openapi) publishes their JSON Schemas.
VectorstoreApiVectorstore, VectorstoreApiDocument and
VectorstoreApiSnapshot are the rows, as smarter.apps.vectorstore.serializers
returned them before the api was modeled, which clients already read. One value changed: a
vectorstore’s canDelete is computed for the requesting user. The serializer was called without a
request, so it was always false. The other models replace the dicts that the views built by hand,
with the same keys.
The models forbid extra fields: the api returns exactly what they declare.
- smarter.apps.vectorstore.contract.models.VECTORSTORE_API_MODELS = (<class 'smarter.apps.vectorstore.contract.models.VectorstoreApiVectorstore'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiStatus'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiDocuments'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiAddText'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiDocumentsAdded'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiDocumentDeleted'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiSearch'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiSearchResults'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiSnapshot'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiSnapshots'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiRestored'>)
The models whose JSON Schemas the Smarter api’s OpenAPI document includes.
Their dependencies are included with them.
( <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiVectorstore'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiStatus'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiDocuments'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiAddText'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiDocumentsAdded'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiDocumentDeleted'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiSearch'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiSearchResults'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiSnapshot'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiSnapshots'>, <class 'smarter.apps.vectorstore.contract.models.VectorstoreApiRestored'>, )
- class smarter.apps.vectorstore.contract.models.VectorstoreApiAddText(*, name=None, text=None, url=None, metadata=None)[source]
Bases:
AccountApiModelThe JSON request body that adds a text, or the document at a url, to a vectorstore.
Files are multipart/form-data.
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- smarter.apps.vectorstore.contract.models.VectorstoreApiBackend
The choices of
VectorstoreMeta.backend.A test fails if the two differ.
alias of
Literal[‘qdrant’, ‘pinecone’]
- class smarter.apps.vectorstore.contract.models.VectorstoreApiCondition(*, type, status, reason, message, lastTransitionTime=None)[source]
Bases:
AccountApiModelOne of the things that a vectorstore’s database needs before it is ready, and whether it has it.
The same as the Vectorstore manifest’s
status.conditions: seesmarter.apps.vectorstore.manifest.models.vectorstore.status.SAMVectorstoreCondition.- classmethod from_condition(condition)[source]
The contract’s model of a condition.
- Parameters:
condition (
SAMVectorstoreCondition) – The condition, as the deploy recorded it.- Return type:
- Returns:
The model.
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- class smarter.apps.vectorstore.contract.models.VectorstoreApiDocument(*, id, hashedId, createdAt=None, updatedAt=None, name, source, contentType, sha256, sizeBytes, metadata, status, statusMessage, chunkCount, loadedAt=None)[source]
Bases:
AccountApiModelA document of a vectorstore: a
smarter.apps.vectorstore.models.VectorstoreDocument, without its content.- classmethod from_model(document)[source]
The contract’s model of a vectorstore’s document.
- Parameters:
document (
VectorstoreDocument) – The row.- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- class smarter.apps.vectorstore.contract.models.VectorstoreApiDocumentDeleted(*, document, status)[source]
Bases:
AccountApiModelA document that is being removed, with its chunks.
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- smarter.apps.vectorstore.contract.models.VectorstoreApiDocumentSource
The choices of
VectorstoreDocument.source.A test fails if the two differ.
alias of
Literal[‘upload’, ‘url’, ‘text’, ‘file’]
- smarter.apps.vectorstore.contract.models.VectorstoreApiDocumentStatus
The choices of
VectorstoreDocument.status.A test fails if the two differ.
alias of
Literal[‘pending’, ‘loading’, ‘loaded’, ‘failed’, ‘deleting’]
- class smarter.apps.vectorstore.contract.models.VectorstoreApiDocuments(*, documents)[source]
Bases:
AccountApiModelA vectorstore’s documents, newest first.
- documents: list[VectorstoreApiDocument]
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- class smarter.apps.vectorstore.contract.models.VectorstoreApiDocumentsAdded(*, documents, duplicates, queued, message)[source]
Bases:
AccountApiModelThe documents that a request added, the ones that the vectorstore already had, and whether they’re queued.
- documents: list[VectorstoreApiDocument]
- duplicates: list[VectorstoreApiDocument]
- classmethod from_result(result)[source]
The contract’s model of the documents that a request added.
- Parameters:
result (
DocumentsAdded) – Whatsmarter.apps.vectorstore.service.VectorstoreService.add_documents()returned.- Return type:
- Returns:
The model.
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- smarter.apps.vectorstore.contract.models.VectorstoreApiHosting
The choices of
VectorstoreMeta.hosting.A test fails if the two differ.
alias of
Literal[‘self_hosted’, ‘managed’]
- smarter.apps.vectorstore.contract.models.VectorstoreApiMetric
The choices of
VectorstoreMeta.metric.A test fails if the two differ.
alias of
Literal[‘cosine’, ‘euclidean’, ‘dotproduct’]
- class smarter.apps.vectorstore.contract.models.VectorstoreApiRestored(*, vectorstore, restored, vectorCount)[source]
Bases:
AccountApiModelA vectorstore whose data was replaced with one of its snapshots.
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- class smarter.apps.vectorstore.contract.models.VectorstoreApiSearch(*, query, k=4, searchType='similarity', scoreThreshold=None, fetchK=None, lambdaMult=None, filter=None)[source]
Bases:
AccountApiModelThe request body of a search of a vectorstore.
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- class smarter.apps.vectorstore.contract.models.VectorstoreApiSearchResult(*, id=None, text, metadata, score=None)[source]
Bases:
AccountApiModelA chunk that a search found.
- classmethod from_result(result)[source]
The contract’s model of a search result.
- Parameters:
result (
SearchResult) – The result.- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- class smarter.apps.vectorstore.contract.models.VectorstoreApiSearchResults(*, vectorstore, results)[source]
Bases:
AccountApiModelThe results of a search of a vectorstore, most similar first.
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- results: list[VectorstoreApiSearchResult]
- smarter.apps.vectorstore.contract.models.VectorstoreApiSearchType
smarter.apps.vectorstore.backends.base.SEARCH_TYPES.A test fails if the two differ.
- Type:
The search types
alias of
Literal[‘similarity’, ‘similarity_score_threshold’, ‘mmr’]
- class smarter.apps.vectorstore.contract.models.VectorstoreApiSnapshot(*, id, hashedId, createdAt=None, updatedAt=None, name, status, statusMessage, sizeBytes=None, vectorCount=None, scheduled)[source]
Bases:
AccountApiModelA snapshot of a vectorstore: a
smarter.apps.vectorstore.models.VectorstoreSnapshot, a Qdrant snapshot or Pinecone backup.- classmethod from_model(snapshot)[source]
The contract’s model of a vectorstore’s snapshot.
- Parameters:
snapshot (
VectorstoreSnapshot) – The row.- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- smarter.apps.vectorstore.contract.models.VectorstoreApiSnapshotStatus
The choices of
VectorstoreSnapshot.status.A test fails if the two differ.
alias of
Literal[‘creating’, ‘ready’, ‘failed’]
- class smarter.apps.vectorstore.contract.models.VectorstoreApiSnapshots(*, snapshots)[source]
Bases:
AccountApiModelA vectorstore’s snapshots.
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- snapshots: list[VectorstoreApiSnapshot]
- class smarter.apps.vectorstore.contract.models.VectorstoreApiStatus(*, vectorstore, status, message, vectorCount, stats)[source]
Bases:
AccountApiModelA vectorstore’s status and statistics, checked now.
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- smarter.apps.vectorstore.contract.models.VectorstoreApiStatusValue
The choices of
VectorstoreMeta.status.A test fails if the two differ.
alias of
Literal[‘pending’, ‘provisioning’, ‘ready’, ‘stopped’, ‘failed’, ‘deleting’]
- class smarter.apps.vectorstore.contract.models.VectorstoreApiVectorstore(*, id, hashedId, createdAt=None, updatedAt=None, name, description=None, version=None, tags=<factory>, annotations=None, userProfile, canDelete, connection=None, embeddingsProvider=None, apiKeySecret=None, documentCount, snapshotCount, manifestUrl, detailUrl=None, spec, backend, hosting, isActive, dimension, metric, deletionProtection, embeddingsModel, status, statusMessage, indexName, endpointUrl, vectorCount, stats, deployedAt=None, lastCheckedAt=None, lastSnapshotAt=None, lastMaintenanceAt=None, conditions=<factory>, attempt=None, maxAttempts=None, nextRetryAt=None, lastError=None)[source]
Bases:
AccountApiModelA vectorstore: a
smarter.apps.vectorstore.models.VectorstoreMeta.Its related rows are their names.
- conditions: list[VectorstoreApiCondition]
- classmethod from_model(vectorstore, user=None)[source]
The contract’s model of a vectorstore.
- Parameters:
vectorstore (
VectorstoreMeta) – The row, whoseuser_profileshould be fetched with it.user (
object) – The requesting user, forcan_delete. None may delete nothing.
- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- user_profile: AccountApiUserProfile
Pydantic models of the LLMHosts’ REST api responses (/api/v1/llmhosts/).
The REST api’s views build their responses from these models, and the Smarter api’s OpenAPI
document (smarter.apps.api.v1.contract.openapi) publishes their JSON Schemas.
LLMHostApiLLMHost is an LLMHost, as smarter.apps.llmhost.serializers.LLMHostSerializer
returned it before the api was modeled, which clients already read. One value changed: its
canDelete is computed for the requesting user. The other models replace the dicts that the views
and the LLMHost service built by hand, with the same keys. Their date-times now end in Z, where
they ended in +00:00: the same instant. A catalog’s model keeps its snake_case keys.
The models forbid extra fields: the api returns exactly what they declare.
- smarter.apps.llmhost.contract.models.LLMHOST_API_MODELS = (<class 'smarter.apps.llmhost.contract.models.LLMHostApiLLMHost'>, <class 'smarter.apps.llmhost.contract.models.LLMHostApiStatus'>, <class 'smarter.apps.llmhost.contract.models.LLMHostApiLogs'>, <class 'smarter.apps.llmhost.contract.models.LLMHostApiPlan'>, <class 'smarter.apps.llmhost.contract.models.LLMHostApiUndeployed'>, <class 'smarter.apps.llmhost.contract.models.LLMHostApiReport'>, <class 'smarter.apps.llmhost.contract.models.LLMHostApiDiscovery'>, <class 'smarter.apps.llmhost.contract.models.LLMHostApiDraftManifest'>)
The models whose JSON Schemas the Smarter api’s OpenAPI document includes.
Their dependencies are included with them.
( <class 'smarter.apps.llmhost.contract.models.LLMHostApiLLMHost'>, <class 'smarter.apps.llmhost.contract.models.LLMHostApiStatus'>, <class 'smarter.apps.llmhost.contract.models.LLMHostApiLogs'>, <class 'smarter.apps.llmhost.contract.models.LLMHostApiPlan'>, <class 'smarter.apps.llmhost.contract.models.LLMHostApiUndeployed'>, <class 'smarter.apps.llmhost.contract.models.LLMHostApiReport'>, <class 'smarter.apps.llmhost.contract.models.LLMHostApiDiscovery'>, <class 'smarter.apps.llmhost.contract.models.LLMHostApiDraftManifest'>, )
- class smarter.apps.llmhost.contract.models.LLMHostApiCatalogModel(*, catalog, source, repository, task, description=None, license=None, gated=False, architecture=None, parameter_count=None, context_window=None, quantization='none', downloads=None, likes=None, tags=<factory>, files=<factory>, manifest=None)[source]
Bases:
BaseModelA model, as a catalog, e.g. Hugging Face, describes it.
Its keys are snake_case, e.g.
parameter_count, as the api returned them before it was modeled.- classmethod from_model_info(model)[source]
The contract’s model of a catalog’s model.
- Parameters:
model (
ModelInfo) – The model.- Returns:
The model.
- Return type:
- model_config = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.llmhost.contract.models.LLMHostApiDiscovery(*, models)[source]
Bases:
AccountApiModelThe models of a catalog that match a search, most popular first.
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- models: list[LLMHostApiCatalogModel]
- class smarter.apps.llmhost.contract.models.LLMHostApiDraftManifest(*, manifest)[source]
Bases:
AccountApiModelA draft LLMHost manifest for a model, to review and apply.
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- smarter.apps.llmhost.contract.models.LLMHostApiFormat
The choices of
LLMHost.api_format.A test fails if the two differ.
alias of
Literal[‘openai_compatible’, ‘huggingface’, ‘ollama_native’, ‘custom’]
- smarter.apps.llmhost.contract.models.LLMHostApiInferenceEngine
The choices of
LLMHost.inference_engine.A test fails if the two differ.
alias of
Literal[‘vllm’, ‘tgi’, ‘sglang’, ‘llama_cpp’, ‘ollama’, ‘tei’, ‘custom’]
- class smarter.apps.llmhost.contract.models.LLMHostApiLLMHost(*, id, hashedId, createdAt=None, updatedAt=None, name, description=None, version=None, tags=<factory>, annotations=None, userProfile, canDelete, manifestUrl, detailUrl=None, spec, modelSource, modelRepository, modelRevision, modelTask, servedModelName, license, modelArchitecture, parameterCount=None, contextWindow=None, quantization, embeddingDimensions=None, supportsStreaming, supportsFunctionCalling, supportsVision, supportsReasoning, inferenceEngine, apiFormat, apiKeySecret=None, compute=None, gpuType, gpuCount, vramRequiredGb=None, replicas, costPerHour=None, status, statusMessage, isActive, readyReplicas, endpointUrl, publicUrl, healthCheckUrl, lastHealthCheckAt=None, lastHealthOk=None, deployedAt=None)[source]
Bases:
AccountApiModelA self-hosted LLM: a
smarter.apps.llmhost.models.LLMHost.- classmethod from_model(llmhost, user=None)[source]
The contract’s model of an LLMHost.
- Parameters:
- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- quantization: Literal['none', 'fp32', 'fp16', 'bf16', 'fp8', 'mxfp4', 'int8', 'int4', 'gguf', 'awq', 'gptq']
- status: Literal['provisioning', 'pending', 'downloading', 'deploying', 'active', 'degraded', 'inactive', 'error']
- user_profile: AccountApiUserProfile
- class smarter.apps.llmhost.contract.models.LLMHostApiLogs(*, llmhost, logs)[source]
Bases:
AccountApiModelThe inference server’s recent logs.
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- smarter.apps.llmhost.contract.models.LLMHostApiModelSource
The choices of
LLMHost.model_source.A test fails if the two differ.
alias of
Literal[‘huggingface’, ‘ollama’, ‘s3’, ‘url’, ‘pvc’]
- smarter.apps.llmhost.contract.models.LLMHostApiModelTask
The choices of
LLMHost.model_task.A test fails if the two differ.
alias of
Literal[‘text-generation’, ‘embedding’]
- class smarter.apps.llmhost.contract.models.LLMHostApiObservation(*, status, message='', replicas=0, readyReplicas=0, healthy=None, endpoint=None, publicUrl=None, pods=<factory>, checkedAt=None)[source]
Bases:
AccountApiModelWhat is known about an LLMHost, as of a status check.
- classmethod from_observation(observation)[source]
The contract’s model of a status check.
- Parameters:
observation (
LLMHostObservation) – The observation.- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- pods: list[LLMHostApiPod]
- class smarter.apps.llmhost.contract.models.LLMHostApiPlan(*, llmhost, resources)[source]
Bases:
AccountApiModelThe Kubernetes resources that a deployment would apply, with secrets redacted.
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- class smarter.apps.llmhost.contract.models.LLMHostApiPod(*, name=None, phase=None, ready, restarts, downloading, reason=None)[source]
Bases:
AccountApiModelA pod of an LLMHost: its name, phase, readiness, restarts, and why it is not ready, if it isn’t.
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- smarter.apps.llmhost.contract.models.LLMHostApiQuantization
The choices of
LLMHost.quantization.A test fails if the two differ.
alias of
Literal[‘none’, ‘fp32’, ‘fp16’, ‘bf16’, ‘fp8’, ‘mxfp4’, ‘int8’, ‘int4’, ‘gguf’, ‘awq’, ‘gptq’]
- class smarter.apps.llmhost.contract.models.LLMHostApiReport(*, totals, byStatus, byEngine, llmhosts)[source]
Bases:
AccountApiModelA summary of LLMHosts: their count by status and engine, the GPUs they use, and their cost.
- llmhosts: list[LLMHostApiReportHost]
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- totals: LLMHostApiReportTotals
- class smarter.apps.llmhost.contract.models.LLMHostApiReportHost(*, name, owner, status, engine, model, task, replicas, readyReplicas, compute=None, gpus, gpuType=None, endpoint=None, publicUrl=None, deployedAt=None, uptimeHours=None, costPerHour=None, estimatedCost=None)[source]
Bases:
AccountApiModelAn LLMHost in a report: its status, model, GPUs and cost.
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- class smarter.apps.llmhost.contract.models.LLMHostApiReportTotals(*, llmhosts, deployed, active, errors, gpus, costPerHour, estimatedCost)[source]
Bases:
AccountApiModelThe totals of a report of LLMHosts.
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- class smarter.apps.llmhost.contract.models.LLMHostApiStatus(*, status, message='', replicas=0, readyReplicas=0, healthy=None, endpoint=None, publicUrl=None, pods=<factory>, checkedAt=None, llmhost)[source]
Bases:
LLMHostApiObservationAn LLMHost’s status, checked now, or after a deployment: the observation, with the LLMHost’s name.
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- smarter.apps.llmhost.contract.models.LLMHostApiStatusValue
The choices of
LLMHost.status.A test fails if the two differ.
alias of
Literal[‘provisioning’, ‘pending’, ‘downloading’, ‘deploying’, ‘active’, ‘degraded’, ‘inactive’, ‘error’]
- class smarter.apps.llmhost.contract.models.LLMHostApiUndeployed(*, llmhost, status, message)[source]
Bases:
AccountApiModelAn LLMHost whose Kubernetes resources were destroyed.
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- smarter.apps.llmhost.contract.models.money(value, decimal_places=4)[source]
A decimal amount as the api returns it: a string with the field’s decimal places, e.g.
"0.1768".
Pydantic models of the Providers’ REST api responses (/api/v1/providers/).
The REST api’s views build their responses from these models, and the Smarter api’s OpenAPI
document (smarter.apps.api.v1.contract.openapi) publishes their JSON Schemas.
ProviderApiProvider and ProviderApiModel are the rows, as
smarter.apps.provider.serializers returned them before the api was modeled, which clients
already read: a Provider’s api key is its Secret’s name and status, never the key.
The models forbid extra fields: the api returns exactly what they declare.
- smarter.apps.provider.contract.models.PROVIDER_API_MODELS = (<class 'smarter.apps.provider.contract.models.ProviderApiProvider'>, <class 'smarter.apps.provider.contract.models.ProviderApiModel'>)
The models whose JSON Schemas the Smarter api’s OpenAPI document includes.
( <class 'smarter.apps.provider.contract.models.ProviderApiProvider'>, <class 'smarter.apps.provider.contract.models.ProviderApiModel'>, )
- class smarter.apps.provider.contract.models.ProviderApiModel(*, id, provider, createdAt=None, updatedAt=None, name, description=None, isDefault, isActive, isDeprecated, isFlagged, isSuspended, maxCompletionTokens, temperature, topP, supportsTextInput, supportsTextGeneration, supportsTranslation, supportsSummarization, supportsStreaming, supportsTools, supportsImageInput, supportsAudioInput, supportsEmbedding, supportsFineTuning, supportsSearch, supportsCodeInterpreter, supportsImageGeneration, supportsAudioGeneration)[source]
Bases:
AccountApiModelA model of an LLM provider: a
smarter.apps.provider.models.ProviderModel, with its provider.- classmethod from_model(provider_model, user=None)[source]
The contract’s model of a provider’s model.
- Parameters:
provider_model (
ProviderModel) – The row, whoseprovidershould be fetched with it.user (
object) – The requesting user, for the provider’scan_delete.
- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- provider: ProviderApiProvider
- class smarter.apps.provider.contract.models.ProviderApiProvider(*, id, createdAt=None, updatedAt=None, name, userProfile, status, description=None, version=None, annotations=None, tags=<factory>, manifestUrl=None, detailUrl=None, ready, isDefault, isActive, isVerified, isFeatured, isDeprecated, isFlagged, isSuspended, baseUrl=None, apiKey=None, defaultModel=None, connectivityTestPath=None, logo=None, websiteUrl=None, ownershipRequested=None, contactEmail=None, contactEmailVerified=None, supportEmail=None, supportEmailVerified=None, docsUrl=None, termsOfServiceUrl=None, privacyPolicyUrl=None, isOfficialProvider, tosAccepted, tosAcceptedAt=None, tosAcceptedBy=None, rfc1034CompliantName=None, canDelete)[source]
Bases:
AccountApiModelAn LLM provider: a
smarter.apps.provider.models.Provider.- api_key: SecretApiSecretRef | None
- classmethod from_model(provider, user=None)[source]
The contract’s model of a Provider.
- Parameters:
- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- tos_accepted_by: AccountApiUser | None
- user_profile: AccountApiUserProfile
- smarter.apps.provider.contract.models.ProviderApiStatus
The choices of
Provider.status.A test fails if the two differ.
alias of
Literal[‘unverified’, ‘verifying’, ‘failed’, ‘verified’, ‘suspended’, ‘deprecated’]
Pydantic models of the Proxies’ REST api responses (/api/v1/proxy/).
The list of the Proxies that the caller may use is built from ProxyApiProxies, with the
keys that the view built by hand before the api was modeled. A Proxy’s passthrough
(/api/v1/proxy/<name>/<path>) forwards the request to the provider’s api, and returns its
response, as it is, so its requests and responses are the provider’s, not Smarter’s, and are not modeled.
- smarter.apps.proxy.contract.models.PROXY_API_MODELS = (<class 'smarter.apps.proxy.contract.models.ProxyApiProxies'>,)
The models whose JSON Schemas the Smarter api’s OpenAPI document includes.
(<class 'smarter.apps.proxy.contract.models.ProxyApiProxies'>, )
- class smarter.apps.proxy.contract.models.ProxyApiProxies(*, proxies)[source]
Bases:
AccountApiModelThe Proxies that the caller may use, by name.
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
- proxies: list[ProxyApiProxy]
- class smarter.apps.proxy.contract.models.ProxyApiProxy(*, name, description=None, provider, url, upstreamUrl, allowedPaths, isActive)[source]
Bases:
AccountApiModelA Proxy that the caller may use: its name, provider and urls.
- classmethod from_model(proxy, request)[source]
The contract’s model of a Proxy.
- Parameters:
proxy (
Proxy) – The row, whoseprovidershould be fetched with it.request (
HttpRequest) – The request, whose host makes the Proxy’s url absolute.
- Returns:
The model.
- Return type:
- model_config = {'alias_generator': <function to_camel>, 'extra': 'forbid', '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].
Pydantic models of the prompt history’s REST api responses (/api/v1/prompts/history/).
The prompt history is the chat sessions (PromptHistoryApiSession) of the users whose
resources the requesting user may manage, the tool calls that the LLMs made in them
(PromptHistoryApiToolCall), and the plugins that they used
(PromptHistoryApiPluginUsage).
The models are the outputs of the serializers of smarter.apps.prompt.api.v1.serializers,
which the REST api returned before it was modeled, and which clients already read. Their keys are
snake_case, unlike the rest of the REST api’s, for the same reason. A plugin is a
smarter.apps.llmtool.contract.models.PluginApiPluginMeta, in camelCase.
The models forbid extra fields: the api returns exactly what they declare.
- smarter.apps.prompt.contract.history.PROMPT_HISTORY_API_MODELS = (<class 'smarter.apps.prompt.contract.history.PromptHistoryApiSession'>, <class 'smarter.apps.prompt.contract.history.PromptHistoryApiToolCall'>, <class 'smarter.apps.prompt.contract.history.PromptHistoryApiPluginUsage'>)
The models whose JSON Schemas the Smarter api’s OpenAPI document includes.
( <class 'smarter.apps.prompt.contract.history.PromptHistoryApiSession'>, <class 'smarter.apps.prompt.contract.history.PromptHistoryApiToolCall'>, <class 'smarter.apps.prompt.contract.history.PromptHistoryApiPluginUsage'>, )
- class smarter.apps.prompt.contract.history.PromptHistoryApiModel(*, id, created_at=None, updated_at=None)[source]
Bases:
BaseModelBase class of the prompt history’s models: the fields of a row, and a TimestampedModel’s.
- model_config = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.prompt.contract.history.PromptHistoryApiPluginUsage(*, id, created_at=None, updated_at=None, prompt, plugin, input_text=None)[source]
Bases:
PromptHistoryApiModelA use of a plugin in a chat session: a
smarter.apps.prompt.models.PromptPluginUsage.- classmethod from_model(row, user=None)[source]
The contract’s model of a use of a plugin.
- Parameters:
row (
PromptPluginUsage) – The row, whosepromptandpluginshould be fetched with it.user (
object) – The requesting user, for the plugin’scanDelete. None may delete nothing.
- Returns:
The model.
- Return type:
- model_config = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- plugin: PluginApiPluginMeta
- prompt: PromptHistoryApiSession
- class smarter.apps.prompt.contract.history.PromptHistoryApiSession(*, id, created_at=None, updated_at=None, name='', description=None, version=None, annotations=None, session_key, ip_address, user_agent, url, user_profile, llmclient)[source]
Bases:
PromptHistoryApiModelA chat session: one conversation with an LLMClient, a
smarter.apps.prompt.models.Prompt.- classmethod from_model(prompt)[source]
The contract’s model of a chat session.
- Parameters:
prompt (
Prompt) – The row.- Returns:
The model.
- Return type:
- model_config = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class smarter.apps.prompt.contract.history.PromptHistoryApiToolCall(*, id, created_at=None, updated_at=None, prompt, plugin=None, function_name=None, function_args=None, request=None, response=None)[source]
Bases:
PromptHistoryApiModelA tool call that the LLM made in a chat session: a
smarter.apps.prompt.models.PromptToolCall.- classmethod from_model(row)[source]
The contract’s model of a tool call.
- Parameters:
row (
PromptToolCall) – The row, whosepromptshould be fetched with it.- Returns:
The model.
- Return type:
- model_config = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- prompt: PromptHistoryApiSession
A mixin of the REST api’s list views whose rows are built from api contract models.
The REST api’s responses are built from Pydantic models of their rows, e.g.
smarter.apps.llmclient.contract.models, which the Smarter api’s OpenAPI document
(smarter.apps.api.v1.contract.openapi) publishes. A list view that mixes in
ContractListMixin sets contract_model, the model of one row, and
its GET returns its queryset’s rows, each built by the model’s from_model().
- class smarter.lib.drf.views.contract.ContractListMixin[source]
The
list()of a DRFListAPIViewwhose rows are built fromcontract_model.A view whose rows need the request, e.g. for their
canDelete, overridesitem().- contract_model: type[BaseModel]
The contract model of one row.
It must have a
from_model(row)classmethod.
- item(row)[source]
Return the response’s item for a row: its contract model, dumped as JSON.
- Parameters:
row – A row of the view’s queryset, a
django.db.models.Model.- Return type:
JsonValue- Returns:
The row’s JSON.