From 3e0612b8b49abf15e56ada6283384c2d9584fdd5 Mon Sep 17 00:00:00 2001 From: "LocalAI [bot]" <139863280+localai-bot@users.noreply.github.com> Date: Mon, 25 May 2026 22:40:32 +0200 Subject: [PATCH] feat(swagger): update swagger (#9992) Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: mudler <2420543+mudler@users.noreply.github.com> --- swagger/docs.go | 240 +++++++++++++++++++++++++++++++++++++++---- swagger/swagger.json | 240 +++++++++++++++++++++++++++++++++++++++---- swagger/swagger.yaml | 195 ++++++++++++++++++++++++++++++++--- 3 files changed, 616 insertions(+), 59 deletions(-) diff --git a/swagger/docs.go b/swagger/docs.go index de32b3f4a..c5d4471a4 100644 --- a/swagger/docs.go +++ b/swagger/docs.go @@ -1121,6 +1121,117 @@ const docTemplate = `{ } } }, + "/api/pii/decide": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "pii" + ], + "summary": "Scan text for PII and return findings + suggested action (decision oracle)", + "parameters": [ + { + "description": "decide params", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/schema.PIIDecideRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/schema.PIIDecideResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + }, + "/api/router/decide": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "router" + ], + "summary": "Classify a prompt against a router model's policies (decision oracle)", + "parameters": [ + { + "description": "decide params", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/schema.RouterDecideRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/schema.RouterDecideResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "404": { + "description": "Not Found", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "503": { + "description": "Service Unavailable", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + }, "/api/traces": { "get": { "description": "Returns captured API exchange traces (request/response pairs) in reverse chronological order", @@ -3286,7 +3397,6 @@ const docTemplate = `{ "downloaded_size": { "type": "string" }, - "error": {}, "file_name": { "type": "string" }, @@ -4709,27 +4819,6 @@ const docTemplate = `{ "description": "The message role", "type": "string" }, - "string_audios": { - "type": "array", - "items": { - "type": "string" - } - }, - "string_content": { - "type": "string" - }, - "string_images": { - "type": "array", - "items": { - "type": "string" - } - }, - "string_videos": { - "type": "array", - "items": { - "type": "string" - } - }, "tool_call_id": { "type": "string" }, @@ -5323,6 +5412,10 @@ const docTemplate = `{ } ] }, + "max_completion_tokens": { + "description": "MaxCompletionTokens is the modern alias for max_tokens\n(OpenAI deprecated max_tokens; gpt-5 / o-series reject it).\nAccepted on the wire so up-to-date clients can use the new\nname; the request middleware collapses it into Maxtokens so\ninternal code reads exactly one field.", + "type": "integer" + }, "max_tokens": { "type": "integer" }, @@ -5654,6 +5747,109 @@ const docTemplate = `{ } } }, + "schema.PIIDecideRequest": { + "type": "object", + "properties": { + "text": { + "description": "Text is the user-visible content to inspect. Required.", + "type": "string" + } + } + }, + "schema.PIIDecideResponse": { + "type": "object", + "properties": { + "findings": { + "description": "Findings is one entry per matched span — pattern id, byte\nrange, and audit-safe hash prefix (never the matched value).", + "type": "array", + "items": { + "$ref": "#/definitions/schema.PIIFinding" + } + }, + "redacted_preview": { + "description": "RedactedPreview is the input with mask-action spans replaced\nby their placeholders. Identical to Text when no findings or\nwhen the strongest action is block/route_local (which don't\nrewrite content).", + "type": "string" + }, + "suggested_action": { + "description": "SuggestedAction is the strongest action across all findings:\n\"block\", \"route_local\", \"mask\", or \"allow\" (no findings).", + "type": "string" + } + } + }, + "schema.PIIFinding": { + "type": "object", + "properties": { + "end": { + "type": "integer" + }, + "hash_prefix": { + "type": "string" + }, + "pattern": { + "type": "string" + }, + "start": { + "type": "integer" + } + } + }, + "schema.RouterDecideRequest": { + "type": "object", + "properties": { + "input": { + "description": "Input is the user-visible prompt text to classify. Required.\nSchema-shape extraction (chat-message concatenation, etc.) is\nthe caller's responsibility — matches the Probe contract used\nby the in-band middleware.", + "type": "string" + }, + "router": { + "description": "Router is the name of the router model (a ModelConfig with a\n` + "`" + `router:` + "`" + ` block). Required.", + "type": "string" + } + } + }, + "schema.RouterDecideResponse": { + "type": "object", + "properties": { + "cache_similarity": { + "description": "CacheSimilarity carries the cosine similarity of the cache hit\n(0 when not cached).", + "type": "number" + }, + "cached": { + "description": "Cached is true when the decision came from the L2 embedding\ncache rather than a fresh classifier run.", + "type": "boolean" + }, + "candidate": { + "description": "Candidate is the model that would be routed to. Empty when no\ncandidate covers Labels AND no fallback is configured.", + "type": "string" + }, + "classifier": { + "description": "Classifier is the classifier name that produced the decision\n(e.g. \"score\").", + "type": "string" + }, + "fallback": { + "description": "Fallback is true when Candidate is the router's configured\nfallback because no candidate covered Labels. Lets callers\ndistinguish \"matched\" from \"fell back\" without comparing names.", + "type": "boolean" + }, + "labels": { + "description": "Labels is the set of active policy labels.", + "type": "array", + "items": { + "type": "string" + } + }, + "latency_ms": { + "description": "LatencyMs is the classifier's wall-clock cost.", + "type": "integer" + }, + "router": { + "description": "Router echoes the requested router model.", + "type": "string" + }, + "score": { + "description": "Score is the top label's softmax probability (the\nclassifier-side confidence signal).", + "type": "number" + } + } + }, "schema.StreamOptions": { "type": "object", "properties": { diff --git a/swagger/swagger.json b/swagger/swagger.json index 7e6d59d59..1729898e9 100644 --- a/swagger/swagger.json +++ b/swagger/swagger.json @@ -1118,6 +1118,117 @@ } } }, + "/api/pii/decide": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "pii" + ], + "summary": "Scan text for PII and return findings + suggested action (decision oracle)", + "parameters": [ + { + "description": "decide params", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/schema.PIIDecideRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/schema.PIIDecideResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + }, + "/api/router/decide": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "router" + ], + "summary": "Classify a prompt against a router model's policies (decision oracle)", + "parameters": [ + { + "description": "decide params", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/schema.RouterDecideRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/schema.RouterDecideResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "404": { + "description": "Not Found", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "503": { + "description": "Service Unavailable", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + }, "/api/traces": { "get": { "description": "Returns captured API exchange traces (request/response pairs) in reverse chronological order", @@ -3283,7 +3394,6 @@ "downloaded_size": { "type": "string" }, - "error": {}, "file_name": { "type": "string" }, @@ -4706,27 +4816,6 @@ "description": "The message role", "type": "string" }, - "string_audios": { - "type": "array", - "items": { - "type": "string" - } - }, - "string_content": { - "type": "string" - }, - "string_images": { - "type": "array", - "items": { - "type": "string" - } - }, - "string_videos": { - "type": "array", - "items": { - "type": "string" - } - }, "tool_call_id": { "type": "string" }, @@ -5320,6 +5409,10 @@ } ] }, + "max_completion_tokens": { + "description": "MaxCompletionTokens is the modern alias for max_tokens\n(OpenAI deprecated max_tokens; gpt-5 / o-series reject it).\nAccepted on the wire so up-to-date clients can use the new\nname; the request middleware collapses it into Maxtokens so\ninternal code reads exactly one field.", + "type": "integer" + }, "max_tokens": { "type": "integer" }, @@ -5651,6 +5744,109 @@ } } }, + "schema.PIIDecideRequest": { + "type": "object", + "properties": { + "text": { + "description": "Text is the user-visible content to inspect. Required.", + "type": "string" + } + } + }, + "schema.PIIDecideResponse": { + "type": "object", + "properties": { + "findings": { + "description": "Findings is one entry per matched span — pattern id, byte\nrange, and audit-safe hash prefix (never the matched value).", + "type": "array", + "items": { + "$ref": "#/definitions/schema.PIIFinding" + } + }, + "redacted_preview": { + "description": "RedactedPreview is the input with mask-action spans replaced\nby their placeholders. Identical to Text when no findings or\nwhen the strongest action is block/route_local (which don't\nrewrite content).", + "type": "string" + }, + "suggested_action": { + "description": "SuggestedAction is the strongest action across all findings:\n\"block\", \"route_local\", \"mask\", or \"allow\" (no findings).", + "type": "string" + } + } + }, + "schema.PIIFinding": { + "type": "object", + "properties": { + "end": { + "type": "integer" + }, + "hash_prefix": { + "type": "string" + }, + "pattern": { + "type": "string" + }, + "start": { + "type": "integer" + } + } + }, + "schema.RouterDecideRequest": { + "type": "object", + "properties": { + "input": { + "description": "Input is the user-visible prompt text to classify. Required.\nSchema-shape extraction (chat-message concatenation, etc.) is\nthe caller's responsibility — matches the Probe contract used\nby the in-band middleware.", + "type": "string" + }, + "router": { + "description": "Router is the name of the router model (a ModelConfig with a\n`router:` block). Required.", + "type": "string" + } + } + }, + "schema.RouterDecideResponse": { + "type": "object", + "properties": { + "cache_similarity": { + "description": "CacheSimilarity carries the cosine similarity of the cache hit\n(0 when not cached).", + "type": "number" + }, + "cached": { + "description": "Cached is true when the decision came from the L2 embedding\ncache rather than a fresh classifier run.", + "type": "boolean" + }, + "candidate": { + "description": "Candidate is the model that would be routed to. Empty when no\ncandidate covers Labels AND no fallback is configured.", + "type": "string" + }, + "classifier": { + "description": "Classifier is the classifier name that produced the decision\n(e.g. \"score\").", + "type": "string" + }, + "fallback": { + "description": "Fallback is true when Candidate is the router's configured\nfallback because no candidate covered Labels. Lets callers\ndistinguish \"matched\" from \"fell back\" without comparing names.", + "type": "boolean" + }, + "labels": { + "description": "Labels is the set of active policy labels.", + "type": "array", + "items": { + "type": "string" + } + }, + "latency_ms": { + "description": "LatencyMs is the classifier's wall-clock cost.", + "type": "integer" + }, + "router": { + "description": "Router echoes the requested router model.", + "type": "string" + }, + "score": { + "description": "Score is the top label's softmax probability (the\nclassifier-side confidence signal).", + "type": "number" + } + } + }, "schema.StreamOptions": { "type": "object", "properties": { diff --git a/swagger/swagger.yaml b/swagger/swagger.yaml index 139301943..565094380 100644 --- a/swagger/swagger.yaml +++ b/swagger/swagger.yaml @@ -244,7 +244,6 @@ definitions: type: boolean downloaded_size: type: string - error: {} file_name: type: string file_size: @@ -1226,20 +1225,6 @@ definitions: role: description: The message role type: string - string_audios: - items: - type: string - type: array - string_content: - type: string - string_images: - items: - type: string - type: array - string_videos: - items: - type: string - type: array tool_call_id: type: string tool_calls: @@ -1636,6 +1621,14 @@ definitions: OpenAI API logprobs parameters logprobs: boolean - if true, returns log probabilities of each output token top_logprobs: integer 0-20 - number of most likely tokens to return at each token position + max_completion_tokens: + description: |- + MaxCompletionTokens is the modern alias for max_tokens + (OpenAI deprecated max_tokens; gpt-5 / o-series reject it). + Accepted on the wire so up-to-date clients can use the new + name; the request middleware collapses it into Maxtokens so + internal code reads exactly one field. + type: integer max_tokens: type: integer messages: @@ -1872,6 +1865,105 @@ definitions: $ref: '#/definitions/schema.NodeData' type: array type: object + schema.PIIDecideRequest: + properties: + text: + description: Text is the user-visible content to inspect. Required. + type: string + type: object + schema.PIIDecideResponse: + properties: + findings: + description: |- + Findings is one entry per matched span — pattern id, byte + range, and audit-safe hash prefix (never the matched value). + items: + $ref: '#/definitions/schema.PIIFinding' + type: array + redacted_preview: + description: |- + RedactedPreview is the input with mask-action spans replaced + by their placeholders. Identical to Text when no findings or + when the strongest action is block/route_local (which don't + rewrite content). + type: string + suggested_action: + description: |- + SuggestedAction is the strongest action across all findings: + "block", "route_local", "mask", or "allow" (no findings). + type: string + type: object + schema.PIIFinding: + properties: + end: + type: integer + hash_prefix: + type: string + pattern: + type: string + start: + type: integer + type: object + schema.RouterDecideRequest: + properties: + input: + description: |- + Input is the user-visible prompt text to classify. Required. + Schema-shape extraction (chat-message concatenation, etc.) is + the caller's responsibility — matches the Probe contract used + by the in-band middleware. + type: string + router: + description: |- + Router is the name of the router model (a ModelConfig with a + `router:` block). Required. + type: string + type: object + schema.RouterDecideResponse: + properties: + cache_similarity: + description: |- + CacheSimilarity carries the cosine similarity of the cache hit + (0 when not cached). + type: number + cached: + description: |- + Cached is true when the decision came from the L2 embedding + cache rather than a fresh classifier run. + type: boolean + candidate: + description: |- + Candidate is the model that would be routed to. Empty when no + candidate covers Labels AND no fallback is configured. + type: string + classifier: + description: |- + Classifier is the classifier name that produced the decision + (e.g. "score"). + type: string + fallback: + description: |- + Fallback is true when Candidate is the router's configured + fallback because no candidate covered Labels. Lets callers + distinguish "matched" from "fell back" without comparing names. + type: boolean + labels: + description: Labels is the set of active policy labels. + items: + type: string + type: array + latency_ms: + description: LatencyMs is the classifier's wall-clock cost. + type: integer + router: + description: Router echoes the requested router model. + type: string + score: + description: |- + Score is the top label's softmax probability (the + classifier-side confidence signal). + type: number + type: object schema.StreamOptions: properties: include_usage: @@ -2984,6 +3076,79 @@ paths: summary: Show the P2P token tags: - p2p + /api/pii/decide: + post: + consumes: + - application/json + parameters: + - description: decide params + in: body + name: request + required: true + schema: + $ref: '#/definitions/schema.PIIDecideRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/schema.PIIDecideResponse' + "400": + description: Bad Request + schema: + additionalProperties: + type: string + type: object + summary: Scan text for PII and return findings + suggested action (decision + oracle) + tags: + - pii + /api/router/decide: + post: + consumes: + - application/json + parameters: + - description: decide params + in: body + name: request + required: true + schema: + $ref: '#/definitions/schema.RouterDecideRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/schema.RouterDecideResponse' + "400": + description: Bad Request + schema: + additionalProperties: + type: string + type: object + "404": + description: Not Found + schema: + additionalProperties: + type: string + type: object + "500": + description: Internal Server Error + schema: + additionalProperties: + type: string + type: object + "503": + description: Service Unavailable + schema: + additionalProperties: + type: string + type: object + summary: Classify a prompt against a router model's policies (decision oracle) + tags: + - router /api/traces: get: description: Returns captured API exchange traces (request/response pairs) in