diff --git a/core/http/endpoints/openai/files.go b/core/http/endpoints/openai/files.go index 23a6eba6..d7741580 100644 --- a/core/http/endpoints/openai/files.go +++ b/core/http/endpoints/openai/files.go @@ -123,7 +123,10 @@ func getFileFromRequest(c *fiber.Ctx) (*File, error) { return nil, fmt.Errorf("unable to find file id %s", id) } -// GetFilesEndpoint https://platform.openai.com/docs/api-reference/files/retrieve +// GetFilesEndpoint is the OpenAI API endpoint to get files https://platform.openai.com/docs/api-reference/files/retrieve +// @Summary Returns information about a specific file. +// @Success 200 {object} File "Response" +// @Router /v1/files/{file_id} [get] func GetFilesEndpoint(cm *config.BackendConfigLoader, appConfig *config.ApplicationConfig) func(c *fiber.Ctx) error { return func(c *fiber.Ctx) error { file, err := getFileFromRequest(c) @@ -135,13 +138,17 @@ func GetFilesEndpoint(cm *config.BackendConfigLoader, appConfig *config.Applicat } } -// DeleteFilesEndpoint https://platform.openai.com/docs/api-reference/files/delete +type DeleteStatus struct { + Id string + Object string + Deleted bool +} + +// DeleteFilesEndpoint is the OpenAI API endpoint to delete files https://platform.openai.com/docs/api-reference/files/delete +// @Summary Delete a file. +// @Success 200 {object} DeleteStatus "Response" +// @Router /v1/files/{file_id} [delete] func DeleteFilesEndpoint(cm *config.BackendConfigLoader, appConfig *config.ApplicationConfig) func(c *fiber.Ctx) error { - type DeleteStatus struct { - Id string - Object string - Deleted bool - } return func(c *fiber.Ctx) error { file, err := getFileFromRequest(c) @@ -174,7 +181,11 @@ func DeleteFilesEndpoint(cm *config.BackendConfigLoader, appConfig *config.Appli } } -// GetFilesContentsEndpoint https://platform.openai.com/docs/api-reference/files/retrieve-contents +// GetFilesContentsEndpoint is the OpenAI API endpoint to get files content https://platform.openai.com/docs/api-reference/files/retrieve-contents +// @Summary Returns information about a specific file. +// @Success 200 {string} binary "file" +// @Router /v1/files/{file_id}/content [get] +// GetFilesContentsEndpoint func GetFilesContentsEndpoint(cm *config.BackendConfigLoader, appConfig *config.ApplicationConfig) func(c *fiber.Ctx) error { return func(c *fiber.Ctx) error { file, err := getFileFromRequest(c) diff --git a/core/http/endpoints/openai/list.go b/core/http/endpoints/openai/list.go index 3253c38a..ba6bd1d7 100644 --- a/core/http/endpoints/openai/list.go +++ b/core/http/endpoints/openai/list.go @@ -6,6 +6,10 @@ import ( "github.com/mudler/LocalAI/core/services" ) +// ListModelsEndpoint is the OpenAI Models API endpoint https://platform.openai.com/docs/api-reference/models +// @Summary List and describe the various models available in the API. +// @Success 200 {object} schema.ModelsDataResponse "Response" +// @Router /v1/models [get] func ListModelsEndpoint(lms *services.ListModelsService) func(ctx *fiber.Ctx) error { return func(c *fiber.Ctx) error { // If blank, no filter is applied. @@ -18,10 +22,7 @@ func ListModelsEndpoint(lms *services.ListModelsService) func(ctx *fiber.Ctx) er if err != nil { return err } - return c.JSON(struct { - Object string `json:"object"` - Data []schema.OpenAIModel `json:"data"` - }{ + return c.JSON(schema.ModelsDataResponse{ Object: "list", Data: dataModels, }) diff --git a/core/schema/openai.go b/core/schema/openai.go index e95b7d8f..9735bb32 100644 --- a/core/schema/openai.go +++ b/core/schema/openai.go @@ -155,3 +155,8 @@ type OpenAIRequest struct { // AutoGPTQ ModelBaseName string `json:"model_base_name" yaml:"model_base_name"` } + +type ModelsDataResponse struct { + Object string `json:"object"` + Data []OpenAIModel `json:"data"` +}