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.
- 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 = '/Users/mcdaniel/Desktop/gh/smarter-sh/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.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 = '/Users/mcdaniel/Desktop/gh/smarter-sh/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='/Users/mcdaniel/Desktop/gh/smarter-sh/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='/Users/mcdaniel/Desktop/gh/smarter-sh/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='/Users/mcdaniel/Desktop/gh/smarter-sh/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.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.RestApiErrorResponse'>, )
- class smarter.apps.api.v1.contract.models.CliApiApplied(**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.CliApiGet(**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(**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(**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(**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(**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(**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(**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(**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(**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(**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(**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(**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(**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(**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(**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(**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(**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(**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(**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(**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(**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(**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(**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(**data)[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(**data)[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(**data)[source]
Bases:
OpenApiModelAn OpenAPI 3.1 document.
- 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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**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,the chat api (
/api/v1/llm-clients/{id}/config/and.../prompt/), to chat with an LLMClient, as JSON or as a stream of Server-Sent Events,the REST reads of the resource families: the LLMClients’, Guardrails’, Secrets’, MCPClients’, vectorstores’, LLMHosts’, plugins’, Providers’ and Proxies’, whose responses are built from each app’s contract models, e.g.
smarter.apps.llmclient.contract.models. Only the reads are published: clients write through the cli api’s manifests, which the brokers validate.
It is built 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 envelope and the errors of every response,the Smarter Chat api contract (
smarter.apps.prompt.contract.models), the requests, responses and progress events of the chat api, and the chat configuration and completion of the cli’s prompt commands,the models of the other commands’ data (
smarter.apps.api.v1.contract.models),
so a change to any of them changes the document. manage.py export_api_contract writes it to
openapi.json, beside this module, and a test fails if the committed file is out of date, or if a
route of a family in DOCUMENTED_URLCONFS is neither in the document nor in
UNDOCUMENTED_ROUTES.
The live Swagger and Redoc pages (/docs/swagger/) are generated by drf-yasg from the views, and
describe every api of the platform in OpenAPI 2. This document describes fewer apis, but types their
requests and responses, so that clients can be generated from it.
- smarter.apps.api.v1.contract.openapi.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'>)
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'>, )
- smarter.apps.api.v1.contract.openapi.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', '/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.plugin.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.Every route of these urlconfs must be in the document, or in
UNDOCUMENTED_ROUTES.{ '/accounts/': 'smarter.apps.account.api.v1.urls', '/cli/': 'smarter.apps.api.v1.cli.urls', '/connections/': 'smarter.apps.connection.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.plugin.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.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, 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.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}/functions/{function_id}/plugins': 'It returns every plugin of the LLMClient, whatever the function, because it is routed to LLMClientPluginListView. Not published until it is fixed or removed.', '/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/add-example-plugins/{user_id}/': "A web console action, which clients replace with the cli api's manifests.", '/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.", '/vectorsearches/{id}/vectorsearch/': 'Running a Vectorsearch is not implemented yet: the route has no POST handler, and answers 405.'}
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}/functions/{function_id}/plugins': 'It returns every plugin of the LLMClient, whatever the function, because it is routed to LLMClientPluginListView. Not published until it is fixed or removed.', '/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/add-example-plugins/{user_id}/': "A web console action, which clients replace with the cli api's manifests.", '/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.", '/vectorsearches/{id}/vectorsearch/': 'Running a Vectorsearch is not implemented yet: the route has no POST handler, and answers 405.', }
- smarter.apps.api.v1.contract.openapi.UNDOCUMENTED_URLCONFS: dict[str, str] = {'/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.{'/tests/': "Views that only the platform's own unit tests call."}
- smarter.apps.api.v1.contract.openapi.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:
- smarter.apps.api.v1.contract.openapi.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_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.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:
- smarter.apps.api.v1.contract.openapi.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.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:
- smarter.apps.api.v1.contract.openapi.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:
- smarter.apps.api.v1.contract.openapi.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:
- smarter.apps.api.v1.contract.openapi.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.openapi_document()[source]
The Smarter api’s OpenAPI document.
- Returns:
The document.
- Return type:
- smarter.apps.api.v1.contract.openapi.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.plugin_paths()[source]
The plugins’ REST reads, relative to the server’s
/api/v1.- Returns:
The paths, e.g.
{"/plugins/": ...}.- Return type:
- smarter.apps.api.v1.contract.openapi.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:
- smarter.apps.api.v1.contract.openapi.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:
- smarter.apps.api.v1.contract.openapi.query(name, description, schema, required=False)[source]
A query parameter.
- Parameters:
- Returns:
The parameter.
- Return type:
- smarter.apps.api.v1.contract.openapi.rest_operation(operation_id, summary, description, tag, response, *, parameters, status='200', request_body=None)[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.
- Returns:
The operation.
- Return type:
- smarter.apps.api.v1.contract.openapi.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.")[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.
- Returns:
The operation.
- Return type:
- smarter.apps.api.v1.contract.openapi.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:
- smarter.apps.api.v1.contract.openapi.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:
- smarter.apps.api.v1.contract.openapi.write_openapi(path='/Users/mcdaniel/Desktop/gh/smarter-sh/smarter/smarter/smarter/apps/api/v1/contract/openapi.json')[source]
Write the Smarter api’s OpenAPI document.
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(**data)[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:
- 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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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 = list[dict[str, JsonValue]] | dict[str, JsonValue] | None
a list of key-value pairs, e.g.
[{"smarter.sh/purpose": "example"}], or,.in legacy rows, an object.
- 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.plugin.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.plugin.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.plugin.contract.models.PluginApiPluginMeta(**data)[source]
Bases:
AccountApiModelA plugin’s metadata: a
smarter.apps.plugin.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.LLMClientApiFunction'>, <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.LLMClientApiFunction'>, <class 'smarter.apps.llmclient.contract.models.LLMClientApiKey'>, <class 'smarter.apps.llmclient.contract.models.LLMClientApiCustomDomain'>, )
- class smarter.apps.llmclient.contract.models.LLMClientApiCustomDomain(**data)[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.LLMClientApiFunction(**data)[source]
Bases:
LLMClientApiOrmModelA built-in function of an LLMClient: a
smarter.apps.llmclient.models.LLMClientFunctions.- classmethod from_model(function)[source]
The contract’s model of a built-in function of an LLMClient.
- Parameters:
function (
LLMClientFunctions) – 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.LLMClientApiFunctionName
the choices of
LLMClientFunctions.name.A test fails if the two differ.
- Type:
A built-in function’s name
alias of
Literal[‘get_current_weather’, ‘date_calculator’, ‘calculator’]
- class smarter.apps.llmclient.contract.models.LLMClientApiKey(**data)[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(**data)[source]
Bases:
LLMClientApiOrmModelAn LLMClient: a
smarter.apps.llmclient.models.LLMClient, with its related rows and its urls.Its
functions,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]
- classmethod from_model(llmclient, user=None)[source]
The contract’s model of an LLMClient.
- Parameters:
- Returns:
The model.
- Return type:
- functions: list[LLMClientApiFunction]
- 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]
- user_profile: AccountApiUserProfile
- class smarter.apps.llmclient.contract.models.LLMClientApiOrmModel(**data)[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(**data)[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(**data)[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’]
- 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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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.VectorstoreApiDocument(**data)[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(**data)[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(**data)[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(**data)[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]
- 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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[source]
Bases:
AccountApiModelA vectorstore: a
smarter.apps.vectorstore.models.VectorstoreMeta.Its related rows are their names.
- 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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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(**data)[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.plugin.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(**data)[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(**data)[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(**data)[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(**data)[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]
The response’s item for a row: its contract model, dumped as JSON.
- Parameters:
row (django.db.models.Model) – A row of the view’s queryset.
- Returns:
The row’s JSON.
- Return type:
TypeAliasType