feat(ml): fuse two embedding models and protect the ML service with a token
This commit is contained in:
1 parent
bc00d6901f
commit
b24e5ff906
63 files changed
+2287
-276
No files matched your search
@@ -2,8 +2,21 @@ openapi: 3.2.0
|
||||
info:
|
||||
title: Lincodex ML Operational API
|
||||
version: 0.1.0
|
||||
description: |-
|
||||
Internal API of the ML service. Only the Go backend calls it; it is never
|
||||
exposed to browsers or to the public network.
|
||||
|
||||
Authentication: every operation except the health routes requires
|
||||
`Authorization: Bearer <token>` when the service has a token, and the
|
||||
service refuses to listen on a non-loopback address without one. The
|
||||
token is a shared random secret of at least 32 printable characters from
|
||||
the deployment secret store, never from this repository. A missing or
|
||||
wrong token answers 401 `unauthenticated`. A service without a token
|
||||
answers only callers on its own loopback interface.
|
||||
servers:
|
||||
- url: /
|
||||
security:
|
||||
- bearerAuth: []
|
||||
paths:
|
||||
/healthz:
|
||||
get:
|
||||
@@ -46,12 +59,11 @@ paths:
|
||||
/v1/embeddings:
|
||||
post:
|
||||
operationId: CreateMLEmbeddings
|
||||
summary: Encode texts into normalized vectors with the pinned embedding model.
|
||||
summary: Encode texts into normalized vectors with a pinned embedding model.
|
||||
description: |-
|
||||
Internal operation for the Go backend; it is not reachable from browsers and needs no credentials on the private network. The request carries only text that the caller is allowed to process, and the service never logs it.
|
||||
Internal operation for the Go backend; it is not reachable from browsers and needs the service bearer token. The request carries only text that the caller is allowed to process, and the service never logs it.
|
||||
|
||||
The service answers 503 service_unavailable until the model is loaded from the image and a warm-up encode has finished; `/readyz` reports the same state. A request above the body limit answers 413, and a request that breaks the schema, such as too many texts or a text over 8000 characters, or names a model that the service does not serve, answers 400.
|
||||
security: []
|
||||
The service may load several pinned models, for example the members of an ensemble; `model` selects one, and the response names the model, revision, dimension, and prompt version that produced the vectors. The service answers 503 service_unavailable until every configured model is loaded and a warm-up encode has finished, and when the device runs out of memory for a request; `/readyz` reports the same state. A request without a valid token answers 401, a request above the body limit answers 413, and a request that breaks the schema, such as too many texts or a text over 8000 characters, or names a model that the service does not serve, answers 400.
|
||||
tags:
|
||||
- inference
|
||||
requestBody:
|
||||
@@ -69,6 +81,8 @@ paths:
|
||||
$ref: '#/components/schemas/EmbeddingResponse'
|
||||
'400':
|
||||
$ref: '#/components/responses/Problem'
|
||||
'401':
|
||||
$ref: '#/components/responses/Problem'
|
||||
'413':
|
||||
$ref: '#/components/responses/Problem'
|
||||
'503':
|
||||
@@ -76,6 +90,11 @@ paths:
|
||||
default:
|
||||
$ref: '#/components/responses/Problem'
|
||||
components:
|
||||
securitySchemes:
|
||||
bearerAuth:
|
||||
type: http
|
||||
scheme: bearer
|
||||
description: 'Shared random service token sent as `Authorization: Bearer <token>`. The service compares it in constant time and never logs it. Rotation replaces the secret on both sides; there are no per-user tokens.'
|
||||
responses:
|
||||
Problem:
|
||||
description: Any error response. The body is a Problem whose `status` equals the HTTP status and whose `code` is one of ProblemCode.
|
||||
@@ -275,7 +294,7 @@ components:
|
||||
description: One plain text to encode. It is untrusted data and never an instruction. The service truncates it deterministically to the token limit of the model (`EmbeddingModel.max_tokens`); characters beyond 8000 are rejected instead.
|
||||
EmbeddingRequest:
|
||||
type: object
|
||||
description: 'Texts to encode in one call. The service encodes them in a fixed, deterministic way: texts are ordered by length with the request position as the tie-breaker, encoded in micro-batches of the configured size, and returned in request order. The same texts in the same request on the same image and thread count give the same vectors.'
|
||||
description: 'Texts to encode in one call. The service encodes them in a fixed, deterministic way: texts are ordered by length with the request position as the tie-breaker, encoded in micro-batches of the configured size, and returned in request order. The same texts in the same request on the same installation, device, precision, and thread count give the same vectors.'
|
||||
additionalProperties: false
|
||||
required:
|
||||
- kind
|
||||
@@ -286,7 +305,7 @@ components:
|
||||
minLength: 1
|
||||
maxLength: 200
|
||||
pattern: ^[A-Za-z0-9._/-]+$
|
||||
description: Identifier of the model to use, as `EmbeddingModel.id` reports it. Absent means the default model of the service. A service may load several models, for example the members of an ensemble; a model it does not serve answers 400 validation_failed with the pointer `/model`.
|
||||
description: Identifier of the model to use, as `EmbeddingModel.id` reports it. Absent means the default model of the service, the first one it is configured with. A service may load several models, for example the members of an ensemble; a model it does not serve answers 400 validation_failed with the pointer `/model`.
|
||||
kind:
|
||||
$ref: '#/components/schemas/EmbeddingInputKind'
|
||||
texts:
|
||||
|
||||
Reference in new issue
Block a user