diff --git a/docs/openapi.json b/docs/openapi.json index fd64a3ab..e6109188 100644 --- a/docs/openapi.json +++ b/docs/openapi.json @@ -556,6 +556,37 @@ } } } + }, + "/v1/models": { + "get": { + "tags": [ + "Text Generation Inference" + ], + "summary": "Get model info", + "operationId": "openai_get_model_info", + "responses": { + "200": { + "description": "Served model info", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ModelInfo" + } + } + } + }, + "404": { + "description": "Model not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } } }, "components": { @@ -1747,6 +1778,35 @@ } ] }, + "ModelInfo": { + "type": "object", + "required": [ + "id", + "object", + "created", + "owned_by" + ], + "properties": { + "created": { + "type": "integer", + "format": "int64", + "example": 1686935002, + "minimum": 0 + }, + "id": { + "type": "string", + "example": "gpt2" + }, + "object": { + "type": "string", + "example": "model" + }, + "owned_by": { + "type": "string", + "example": "openai" + } + } + }, "OutputMessage": { "oneOf": [ { @@ -2094,4 +2154,4 @@ "description": "Hugging Face Text Generation Inference API" } ] -} +} \ No newline at end of file diff --git a/router/src/server.rs b/router/src/server.rs index 518b50e1..24003d95 100644 --- a/router/src/server.rs +++ b/router/src/server.rs @@ -121,9 +121,13 @@ async fn get_model_info(info: Extension) -> Json { get, tag = "Text Generation Inference", path = "/v1/models", -responses((status = 200, description = "Served model info", body = ModelInfo)) +responses( +(status = 200, description = "Served model info", body = ModelInfo), +(status = 404, description = "Model not found", body = ErrorResponse), +) )] -#[instrument] +#[instrument(skip(info))] +/// Get model info async fn openai_get_model_info(info: Extension) -> Json { Json(ModelsInfo { data: vec![ModelInfo { @@ -1521,6 +1525,7 @@ chat_completions, completions, tokenize, metrics, +openai_get_model_info, ), components( schemas( @@ -1573,6 +1578,7 @@ ToolCall, Function, FunctionDefinition, ToolChoice, +ModelInfo, ) ), tags(