From 23835f8cca84e2d6d0cc114aee36a121c37316fc Mon Sep 17 00:00:00 2001 From: "LocalAI [bot]" <139863280+localai-bot@users.noreply.github.com> Date: Sun, 14 Jul 2024 23:44:18 +0200 Subject: [PATCH] feat(swagger): update swagger (#2858) 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 | 386 +++++++++++++++++++++++++++++++++++++++++++ swagger/swagger.json | 386 +++++++++++++++++++++++++++++++++++++++++++ swagger/swagger.yaml | 254 ++++++++++++++++++++++++++++ 3 files changed, 1026 insertions(+) diff --git a/swagger/docs.go b/swagger/docs.go index 513a6dea..bf624094 100644 --- a/swagger/docs.go +++ b/swagger/docs.go @@ -22,6 +22,134 @@ const docTemplate = `{ "host": "{{.Host}}", "basePath": "{{.BasePath}}", "paths": { + "/models/apply": { + "post": { + "summary": "Install models to LocalAI.", + "parameters": [ + { + "description": "query params", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/localai.GalleryModel" + } + } + ], + "responses": { + "200": { + "description": "Response", + "schema": { + "$ref": "#/definitions/schema.GalleryResponse" + } + } + } + } + }, + "/models/available": { + "get": { + "summary": "List installable models.", + "responses": { + "200": { + "description": "Response", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/gallery.GalleryModel" + } + } + } + } + } + }, + "/models/delete/{name}": { + "post": { + "summary": "delete models to LocalAI.", + "parameters": [ + { + "type": "string", + "description": "Model name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Response", + "schema": { + "$ref": "#/definitions/schema.GalleryResponse" + } + } + } + } + }, + "/models/galleries": { + "get": { + "summary": "List all Galleries", + "responses": { + "200": { + "description": "Response", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/config.Gallery" + } + } + } + } + }, + "post": { + "summary": "Adds a gallery in LocalAI", + "parameters": [ + { + "description": "Gallery details", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/config.Gallery" + } + } + ], + "responses": { + "200": { + "description": "Response", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/config.Gallery" + } + } + } + } + }, + "delete": { + "summary": "removes a gallery from LocalAI", + "parameters": [ + { + "description": "Gallery details", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/config.Gallery" + } + } + ], + "responses": { + "200": { + "description": "Response", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/config.Gallery" + } + } + } + } + } + }, "/tts": { "post": { "consumes": [ @@ -287,6 +415,30 @@ const docTemplate = `{ } } }, + "/v1/rerank": { + "post": { + "summary": "Reranks a list of phrases by relevance to a given text query.", + "parameters": [ + { + "description": "query params", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/schema.JINARerankRequest" + } + } + ], + "responses": { + "200": { + "description": "Response", + "schema": { + "$ref": "#/definitions/schema.JINARerankResponse" + } + } + } + } + }, "/v1/text-to-speech/{voice-id}": { "post": { "summary": "Generates audio from the input text.", @@ -320,6 +472,17 @@ const docTemplate = `{ } }, "definitions": { + "config.Gallery": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "url": { + "type": "string" + } + } + }, "functions.Argument": { "type": "object", "properties": { @@ -452,6 +615,148 @@ const docTemplate = `{ } } }, + "gallery.File": { + "type": "object", + "properties": { + "filename": { + "type": "string" + }, + "sha256": { + "type": "string" + }, + "uri": { + "type": "string" + } + } + }, + "gallery.GalleryModel": { + "type": "object", + "properties": { + "config_file": { + "description": "config_file is read in the situation where URL is blank - and therefore this is a base config.", + "type": "object", + "additionalProperties": true + }, + "description": { + "type": "string" + }, + "files": { + "description": "AdditionalFiles are used to add additional files to the model", + "type": "array", + "items": { + "$ref": "#/definitions/gallery.File" + } + }, + "gallery": { + "description": "Gallery is a reference to the gallery which contains the model", + "allOf": [ + { + "$ref": "#/definitions/config.Gallery" + } + ] + }, + "icon": { + "type": "string" + }, + "installed": { + "description": "Installed is used to indicate if the model is installed or not", + "type": "boolean" + }, + "license": { + "type": "string" + }, + "name": { + "type": "string" + }, + "overrides": { + "description": "Overrides are used to override the configuration of the model located at URL", + "type": "object", + "additionalProperties": true + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + }, + "url": { + "type": "string" + }, + "urls": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "localai.GalleryModel": { + "type": "object", + "properties": { + "config_file": { + "description": "config_file is read in the situation where URL is blank - and therefore this is a base config.", + "type": "object", + "additionalProperties": true + }, + "config_url": { + "type": "string" + }, + "description": { + "type": "string" + }, + "files": { + "description": "AdditionalFiles are used to add additional files to the model", + "type": "array", + "items": { + "$ref": "#/definitions/gallery.File" + } + }, + "gallery": { + "description": "Gallery is a reference to the gallery which contains the model", + "allOf": [ + { + "$ref": "#/definitions/config.Gallery" + } + ] + }, + "icon": { + "type": "string" + }, + "id": { + "type": "string" + }, + "installed": { + "description": "Installed is used to indicate if the model is installed or not", + "type": "boolean" + }, + "license": { + "type": "string" + }, + "name": { + "type": "string" + }, + "overrides": { + "description": "Overrides are used to override the configuration of the model located at URL", + "type": "object", + "additionalProperties": true + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + }, + "url": { + "type": "string" + }, + "urls": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, "openai.Assistant": { "type": "object", "properties": { @@ -636,6 +941,17 @@ const docTemplate = `{ } } }, + "schema.GalleryResponse": { + "type": "object", + "properties": { + "status": { + "type": "string" + }, + "uuid": { + "type": "string" + } + } + }, "schema.Item": { "type": "object", "properties": { @@ -660,6 +976,76 @@ const docTemplate = `{ } } }, + "schema.JINADocumentResult": { + "type": "object", + "properties": { + "document": { + "$ref": "#/definitions/schema.JINAText" + }, + "index": { + "type": "integer" + }, + "relevance_score": { + "type": "number" + } + } + }, + "schema.JINARerankRequest": { + "type": "object", + "properties": { + "documents": { + "type": "array", + "items": { + "type": "string" + } + }, + "model": { + "type": "string" + }, + "query": { + "type": "string" + }, + "top_n": { + "type": "integer" + } + } + }, + "schema.JINARerankResponse": { + "type": "object", + "properties": { + "model": { + "type": "string" + }, + "results": { + "type": "array", + "items": { + "$ref": "#/definitions/schema.JINADocumentResult" + } + }, + "usage": { + "$ref": "#/definitions/schema.JINAUsageInfo" + } + } + }, + "schema.JINAText": { + "type": "object", + "properties": { + "text": { + "type": "string" + } + } + }, + "schema.JINAUsageInfo": { + "type": "object", + "properties": { + "prompt_tokens": { + "type": "integer" + }, + "total_tokens": { + "type": "integer" + } + } + }, "schema.Message": { "type": "object", "properties": { diff --git a/swagger/swagger.json b/swagger/swagger.json index aedfd438..a2e9de4a 100644 --- a/swagger/swagger.json +++ b/swagger/swagger.json @@ -15,6 +15,134 @@ }, "basePath": "/", "paths": { + "/models/apply": { + "post": { + "summary": "Install models to LocalAI.", + "parameters": [ + { + "description": "query params", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/localai.GalleryModel" + } + } + ], + "responses": { + "200": { + "description": "Response", + "schema": { + "$ref": "#/definitions/schema.GalleryResponse" + } + } + } + } + }, + "/models/available": { + "get": { + "summary": "List installable models.", + "responses": { + "200": { + "description": "Response", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/gallery.GalleryModel" + } + } + } + } + } + }, + "/models/delete/{name}": { + "post": { + "summary": "delete models to LocalAI.", + "parameters": [ + { + "type": "string", + "description": "Model name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Response", + "schema": { + "$ref": "#/definitions/schema.GalleryResponse" + } + } + } + } + }, + "/models/galleries": { + "get": { + "summary": "List all Galleries", + "responses": { + "200": { + "description": "Response", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/config.Gallery" + } + } + } + } + }, + "post": { + "summary": "Adds a gallery in LocalAI", + "parameters": [ + { + "description": "Gallery details", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/config.Gallery" + } + } + ], + "responses": { + "200": { + "description": "Response", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/config.Gallery" + } + } + } + } + }, + "delete": { + "summary": "removes a gallery from LocalAI", + "parameters": [ + { + "description": "Gallery details", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/config.Gallery" + } + } + ], + "responses": { + "200": { + "description": "Response", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/config.Gallery" + } + } + } + } + } + }, "/tts": { "post": { "consumes": [ @@ -280,6 +408,30 @@ } } }, + "/v1/rerank": { + "post": { + "summary": "Reranks a list of phrases by relevance to a given text query.", + "parameters": [ + { + "description": "query params", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/schema.JINARerankRequest" + } + } + ], + "responses": { + "200": { + "description": "Response", + "schema": { + "$ref": "#/definitions/schema.JINARerankResponse" + } + } + } + } + }, "/v1/text-to-speech/{voice-id}": { "post": { "summary": "Generates audio from the input text.", @@ -313,6 +465,17 @@ } }, "definitions": { + "config.Gallery": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "url": { + "type": "string" + } + } + }, "functions.Argument": { "type": "object", "properties": { @@ -445,6 +608,148 @@ } } }, + "gallery.File": { + "type": "object", + "properties": { + "filename": { + "type": "string" + }, + "sha256": { + "type": "string" + }, + "uri": { + "type": "string" + } + } + }, + "gallery.GalleryModel": { + "type": "object", + "properties": { + "config_file": { + "description": "config_file is read in the situation where URL is blank - and therefore this is a base config.", + "type": "object", + "additionalProperties": true + }, + "description": { + "type": "string" + }, + "files": { + "description": "AdditionalFiles are used to add additional files to the model", + "type": "array", + "items": { + "$ref": "#/definitions/gallery.File" + } + }, + "gallery": { + "description": "Gallery is a reference to the gallery which contains the model", + "allOf": [ + { + "$ref": "#/definitions/config.Gallery" + } + ] + }, + "icon": { + "type": "string" + }, + "installed": { + "description": "Installed is used to indicate if the model is installed or not", + "type": "boolean" + }, + "license": { + "type": "string" + }, + "name": { + "type": "string" + }, + "overrides": { + "description": "Overrides are used to override the configuration of the model located at URL", + "type": "object", + "additionalProperties": true + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + }, + "url": { + "type": "string" + }, + "urls": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "localai.GalleryModel": { + "type": "object", + "properties": { + "config_file": { + "description": "config_file is read in the situation where URL is blank - and therefore this is a base config.", + "type": "object", + "additionalProperties": true + }, + "config_url": { + "type": "string" + }, + "description": { + "type": "string" + }, + "files": { + "description": "AdditionalFiles are used to add additional files to the model", + "type": "array", + "items": { + "$ref": "#/definitions/gallery.File" + } + }, + "gallery": { + "description": "Gallery is a reference to the gallery which contains the model", + "allOf": [ + { + "$ref": "#/definitions/config.Gallery" + } + ] + }, + "icon": { + "type": "string" + }, + "id": { + "type": "string" + }, + "installed": { + "description": "Installed is used to indicate if the model is installed or not", + "type": "boolean" + }, + "license": { + "type": "string" + }, + "name": { + "type": "string" + }, + "overrides": { + "description": "Overrides are used to override the configuration of the model located at URL", + "type": "object", + "additionalProperties": true + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + }, + "url": { + "type": "string" + }, + "urls": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, "openai.Assistant": { "type": "object", "properties": { @@ -629,6 +934,17 @@ } } }, + "schema.GalleryResponse": { + "type": "object", + "properties": { + "status": { + "type": "string" + }, + "uuid": { + "type": "string" + } + } + }, "schema.Item": { "type": "object", "properties": { @@ -653,6 +969,76 @@ } } }, + "schema.JINADocumentResult": { + "type": "object", + "properties": { + "document": { + "$ref": "#/definitions/schema.JINAText" + }, + "index": { + "type": "integer" + }, + "relevance_score": { + "type": "number" + } + } + }, + "schema.JINARerankRequest": { + "type": "object", + "properties": { + "documents": { + "type": "array", + "items": { + "type": "string" + } + }, + "model": { + "type": "string" + }, + "query": { + "type": "string" + }, + "top_n": { + "type": "integer" + } + } + }, + "schema.JINARerankResponse": { + "type": "object", + "properties": { + "model": { + "type": "string" + }, + "results": { + "type": "array", + "items": { + "$ref": "#/definitions/schema.JINADocumentResult" + } + }, + "usage": { + "$ref": "#/definitions/schema.JINAUsageInfo" + } + } + }, + "schema.JINAText": { + "type": "object", + "properties": { + "text": { + "type": "string" + } + } + }, + "schema.JINAUsageInfo": { + "type": "object", + "properties": { + "prompt_tokens": { + "type": "integer" + }, + "total_tokens": { + "type": "integer" + } + } + }, "schema.Message": { "type": "object", "properties": { diff --git a/swagger/swagger.yaml b/swagger/swagger.yaml index 9c23c811..685dd198 100644 --- a/swagger/swagger.yaml +++ b/swagger/swagger.yaml @@ -1,5 +1,12 @@ basePath: / definitions: + config.Gallery: + properties: + name: + type: string + url: + type: string + type: object functions.Argument: properties: properties: @@ -86,6 +93,105 @@ definitions: type: type: string type: object + gallery.File: + properties: + filename: + type: string + sha256: + type: string + uri: + type: string + type: object + gallery.GalleryModel: + properties: + config_file: + additionalProperties: true + description: config_file is read in the situation where URL is blank - and + therefore this is a base config. + type: object + description: + type: string + files: + description: AdditionalFiles are used to add additional files to the model + items: + $ref: '#/definitions/gallery.File' + type: array + gallery: + allOf: + - $ref: '#/definitions/config.Gallery' + description: Gallery is a reference to the gallery which contains the model + icon: + type: string + installed: + description: Installed is used to indicate if the model is installed or not + type: boolean + license: + type: string + name: + type: string + overrides: + additionalProperties: true + description: Overrides are used to override the configuration of the model + located at URL + type: object + tags: + items: + type: string + type: array + url: + type: string + urls: + items: + type: string + type: array + type: object + localai.GalleryModel: + properties: + config_file: + additionalProperties: true + description: config_file is read in the situation where URL is blank - and + therefore this is a base config. + type: object + config_url: + type: string + description: + type: string + files: + description: AdditionalFiles are used to add additional files to the model + items: + $ref: '#/definitions/gallery.File' + type: array + gallery: + allOf: + - $ref: '#/definitions/config.Gallery' + description: Gallery is a reference to the gallery which contains the model + icon: + type: string + id: + type: string + installed: + description: Installed is used to indicate if the model is installed or not + type: boolean + license: + type: string + name: + type: string + overrides: + additionalProperties: true + description: Overrides are used to override the configuration of the model + located at URL + type: object + tags: + items: + type: string + type: array + url: + type: string + urls: + items: + type: string + type: array + type: object openai.Assistant: properties: created: @@ -214,6 +320,13 @@ definitions: name: type: string type: object + schema.GalleryResponse: + properties: + status: + type: string + uuid: + type: string + type: object schema.Item: properties: b64_json: @@ -230,6 +343,51 @@ definitions: description: Images type: string type: object + schema.JINADocumentResult: + properties: + document: + $ref: '#/definitions/schema.JINAText' + index: + type: integer + relevance_score: + type: number + type: object + schema.JINARerankRequest: + properties: + documents: + items: + type: string + type: array + model: + type: string + query: + type: string + top_n: + type: integer + type: object + schema.JINARerankResponse: + properties: + model: + type: string + results: + items: + $ref: '#/definitions/schema.JINADocumentResult' + type: array + usage: + $ref: '#/definitions/schema.JINAUsageInfo' + type: object + schema.JINAText: + properties: + text: + type: string + type: object + schema.JINAUsageInfo: + properties: + prompt_tokens: + type: integer + total_tokens: + type: integer + type: object schema.Message: properties: content: @@ -458,6 +616,87 @@ info: title: LocalAI API version: 2.0.0 paths: + /models/apply: + post: + parameters: + - description: query params + in: body + name: request + required: true + schema: + $ref: '#/definitions/localai.GalleryModel' + responses: + "200": + description: Response + schema: + $ref: '#/definitions/schema.GalleryResponse' + summary: Install models to LocalAI. + /models/available: + get: + responses: + "200": + description: Response + schema: + items: + $ref: '#/definitions/gallery.GalleryModel' + type: array + summary: List installable models. + /models/delete/{name}: + post: + parameters: + - description: Model name + in: path + name: name + required: true + type: string + responses: + "200": + description: Response + schema: + $ref: '#/definitions/schema.GalleryResponse' + summary: delete models to LocalAI. + /models/galleries: + delete: + parameters: + - description: Gallery details + in: body + name: request + required: true + schema: + $ref: '#/definitions/config.Gallery' + responses: + "200": + description: Response + schema: + items: + $ref: '#/definitions/config.Gallery' + type: array + summary: removes a gallery from LocalAI + get: + responses: + "200": + description: Response + schema: + items: + $ref: '#/definitions/config.Gallery' + type: array + summary: List all Galleries + post: + parameters: + - description: Gallery details + in: body + name: request + required: true + schema: + $ref: '#/definitions/config.Gallery' + responses: + "200": + description: Response + schema: + items: + $ref: '#/definitions/config.Gallery' + type: array + summary: Adds a gallery in LocalAI /tts: post: consumes: @@ -626,6 +865,21 @@ paths: schema: $ref: '#/definitions/schema.ModelsDataResponse' summary: List and describe the various models available in the API. + /v1/rerank: + post: + parameters: + - description: query params + in: body + name: request + required: true + schema: + $ref: '#/definitions/schema.JINARerankRequest' + responses: + "200": + description: Response + schema: + $ref: '#/definitions/schema.JINARerankResponse' + summary: Reranks a list of phrases by relevance to a given text query. /v1/text-to-speech/{voice-id}: post: parameters: