DRF Serializers
LLMClient serializers.
- class smarter.apps.llmclient.serializers.LLMClientAPIKeySerializer(*args, **kwargs)[source]
Bases:
SmarterCamelCaseSerializerAn api key of an LLMClient.
api_keyis the SmarterAuthToken’s public key_id. The token’s primary key is its digest, a hash of the key, which the api never returns.
- class smarter.apps.llmclient.serializers.LLMClientConfigSerializer(*args, **kwargs)[source]
Bases:
ModelSerializerSerializer for the smarter.apps.prompt.views.PromptConfigView which should not be camelCased.
- get_default_system_role(obj)[source]
Return the LLMClient’s default system role, with the current date and time prepended.
- Parameters:
obj (
LLMClient) – The LLMClient.- Returns:
The value of
obj.default_system_role_enhanced.
- get_fields()[source]
Return the serializer’s fields, each marked read-only.
- Returns:
The fields, keyed by name.
- get_total_tools(obj)[source]
The number of tools that the LLMClient adds to a prompt.
Counted, and cached until the LLMClient’s tools change, rather than serialized: Smarter Chat’s configuration api reads it on every page load.
- Parameters:
obj (
LLMClient) – The LLMClient.- Returns:
The length of
LLMClientSerializer.get_tools(): its extensions, plugins and MCPClients.- Return type:
- class smarter.apps.llmclient.serializers.LLMClientCustomDomainListSerializer(*args, **kwargs)[source]
Bases:
MetaDataWithOwnershipModelSerializerA custom domain: the resource’s metadata and owner, the domain, the llmclient that it serves, and its DNS records.
Used by the Custom Domain list in the web console, and by the CustomDomain broker’s
get.- get_dns_records(obj)[source]
Return the custom domain’s DNS records, ordered by record name.
- Parameters:
obj (
LLMClientCustomDomain) – The custom domain.- Returns:
One
{"name", "type", "value", "ttl"}dict perLLMClientCustomDomainDNSrow.
- class smarter.apps.llmclient.serializers.LLMClientCustomDomainSerializer(*args, **kwargs)[source]
Bases:
SmarterCamelCaseSerializerA custom domain of an LLMClient: every model field, plus its annotations, all read-only.
- class smarter.apps.llmclient.serializers.LLMClientExtensionsSerializer(*args, **kwargs)[source]
Bases:
SmarterCamelCaseSerializerAn Extension of an LLMClient: the link row, and the Extension’s slug as its name.
- class smarter.apps.llmclient.serializers.LLMClientGuardrailMiniSerializer(*args, **kwargs)[source]
Bases:
SmarterCamelCaseSerializerA Guardrail of an LLMClient: the link’s id, and the Guardrail’s name.
- class smarter.apps.llmclient.serializers.LLMClientMCPClientMiniSerializer(*args, **kwargs)[source]
Bases:
SmarterCamelCaseSerializerAn MCPClient of an LLMClient: the link’s id, and the MCPClient’s name.
- class smarter.apps.llmclient.serializers.LLMClientPluginMiniSerializer(*args, **kwargs)[source]
Bases:
SmarterCamelCaseSerializerA Plugin of an LLMClient: the link’s id, and the Plugin’s name.
- class smarter.apps.llmclient.serializers.LLMClientPluginSerializer(*args, **kwargs)[source]
Bases:
SmarterCamelCaseSerializerA Plugin of an LLMClient: the link row, with its PluginMeta nested, all read-only.
- class smarter.apps.llmclient.serializers.LLMClientRequestsSerializer(*args, **kwargs)[source]
Bases:
ModelSerializerSerializer for the LLMClientRequests model.
- class smarter.apps.llmclient.serializers.LLMClientSerializer(*args, **kwargs)[source]
Bases:
MetaDataWithOwnershipModelSerializerAn LLMClient: every model field, its owner, its related resources, and its computed hosts and urls.
Every field is read-only. The related resources (extensions, plugins, MCPClients, guardrails, custom domains and api keys) are serialized as nested lists.
- get_api_keys(obj)[source]
Return the LLMClient’s api keys.
- Parameters:
obj (
LLMClient) – The LLMClient.- Returns:
The serialized
LLMClientAPIKeyrows.
- get_base_api_domain(obj)[source]
Return the base api domain that the LLMClient’s default hostname uses.
- Parameters:
obj (
LLMClient) – The LLMClient.- Returns:
The value of
obj.base_api_domain.
- get_base_default_host(obj)[source]
Return the part of the LLMClient’s default hostname after its RFC 1034 compliant name.
- Parameters:
obj (
LLMClient) – The LLMClient.- Returns:
The value of
obj.base_default_host.
- get_custom_domains(obj)[source]
Return the LLMClient’s custom domain, as a list of zero or one.
- Parameters:
obj (
LLMClient) – The LLMClient.- Returns:
The serialized custom domain in a list, or an empty list if it has none.
- get_custom_host(obj)[source]
Return the LLMClient’s hostname on its custom domain.
- Parameters:
obj (
LLMClient) – The LLMClient.- Returns:
The value of
obj.custom_host.
- get_custom_url(obj)[source]
Return the LLMClient’s url on its custom domain.
- Parameters:
obj (
LLMClient) – The LLMClient.- Returns:
The value of
obj.custom_url.
- get_default_host(obj)[source]
Return the LLMClient’s default hostname.
- Parameters:
obj (
LLMClient) – The LLMClient.- Returns:
The value of
obj.default_host.
- get_default_system_role(obj)[source]
Return the LLMClient’s default system role, with the current date and time prepended.
- Parameters:
obj (
LLMClient) – The LLMClient.- Returns:
The value of
obj.default_system_role_enhanced.
- get_default_url(obj)[source]
Return the LLMClient’s default url.
- Parameters:
obj (
LLMClient) – The LLMClient.- Returns:
The value of
obj.default_url.
- get_extensions(obj)[source]
Return the LLMClient’s extensions, sorted by the Extension’s slug.
- Parameters:
obj (
LLMClient) – The LLMClient.- Returns:
The serialized
LLMClientExtensionsrows.
- get_fields()[source]
Return the serializer’s fields, each marked read-only.
- Returns:
The fields, keyed by name.
- get_guardrails(obj)[source]
Return the LLMClient’s guardrails.
- Parameters:
obj (
LLMClient) – The LLMClient.- Returns:
One
{"id", "name"}perLLMClientGuardrailsrow.
- get_hashed_id(obj)[source]
Return the LLMClient’s hashed id.
- Parameters:
obj (
LLMClient) – The LLMClient.- Returns:
The value of
obj.hashed_id.
- get_hostname(obj)[source]
Return the LLMClient’s hostname, which depends on its deployment status.
- Parameters:
obj (
LLMClient) – The LLMClient.- Returns:
The value of
obj.hostname.
- get_is_authentication_required(obj)[source]
Return whether the LLMClient’s api requires authentication.
- Parameters:
obj (
LLMClient) – The LLMClient.- Returns:
The value of
obj.is_authentication_required.
- get_manifest_url(obj)[source]
Return the url of the LLMClient’s manifest page in the web console.
- Parameters:
obj (
LLMClient) – The LLMClient.- Returns:
The value of
obj.manifest_url.
- get_mcpclients(obj)[source]
Return the LLMClient’s MCPClients.
- Parameters:
obj (
LLMClient) – The LLMClient.- Returns:
One
{"id", "name"}perLLMClientMCPClientsrow.
- get_plugins(obj)[source]
Return the LLMClient’s plugins.
- Parameters:
obj (
LLMClient) – The LLMClient.- Returns:
One
{"id", "name"}perLLMClientPluginrow.
- get_ready(obj)[source]
Return whether the LLMClient is ready: in sandbox mode, or deployed with verified DNS and an issued certificate.
- Parameters:
obj (
LLMClient) – The LLMClient.- Returns:
The value of
obj.ready.
- get_rfc1034_compliant_name(obj)[source]
Return the LLMClient’s RFC 1034 compliant name, used in its hostnames.
- Parameters:
obj (
LLMClient) – The LLMClient.- Returns:
The value of
obj.rfc1034_compliant_name.
- get_sandbox_host(obj)[source]
Return the LLMClient’s sandbox hostname.
- Parameters:
obj (
LLMClient) – The LLMClient.- Returns:
The value of
obj.sandbox_host.
- get_sandbox_url(obj)[source]
Return the LLMClient’s sandbox url.
- Parameters:
obj (
LLMClient) – The LLMClient.- Returns:
The value of
obj.sandbox_url.
- get_tools(obj)[source]
The tools that the LLMClient offers the LLM: its extensions, plugins and MCPClients.
Guardrails are left out: they constrain a prompt, but the LLM can’t call them.
- get_url(obj)[source]
Return the LLMClient’s url, which depends on its deployment status.
- Parameters:
obj (
LLMClient) – The LLMClient.- Returns:
The value of
obj.url.
- get_url_chat_config(obj)[source]
Return the api url of the LLMClient’s chat configuration.
- Parameters:
obj (
LLMClient) – The LLMClient.- Returns:
The value of
obj.url_chat_config.