From 6213da330abba6007c118a2b133bc119b2dd7e41 Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Sun, 25 Jun 2023 22:51:02 +0200 Subject: [PATCH] fix: add omitempty where needed (#671) --- pkg/gallery/models.go | 3 ++- pkg/gallery/request.go | 26 ++++++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/pkg/gallery/models.go b/pkg/gallery/models.go index a354d8b5..424b4240 100644 --- a/pkg/gallery/models.go +++ b/pkg/gallery/models.go @@ -42,7 +42,8 @@ prompt_templates: content: "" */ - +// Config is the model configuration which contains all the model details +// This configuration is read from the gallery endpoint and is used to download and install the model type Config struct { Description string `yaml:"description"` License string `yaml:"license"` diff --git a/pkg/gallery/request.go b/pkg/gallery/request.go index 2e2da3e8..d8b8e438 100644 --- a/pkg/gallery/request.go +++ b/pkg/gallery/request.go @@ -9,15 +9,25 @@ import ( "gopkg.in/yaml.v2" ) -// endpoints - +// GalleryModel is the struct used to represent a model in the gallery returned by the endpoint. +// It is used to install the model by resolving the URL and downloading the files. +// The other fields are used to override the configuration of the model. type GalleryModel struct { - URL string `json:"url" yaml:"url"` - Name string `json:"name" yaml:"name"` - Overrides map[string]interface{} `json:"overrides" yaml:"overrides"` - AdditionalFiles []File `json:"files" yaml:"files"` - Gallery Gallery `json:"gallery" yaml:"gallery"` - Installed bool `json:"installed" yaml:"installed"` + URL string `json:"url,omitempty" yaml:"url,omitempty"` + Name string `json:"name,omitempty" yaml:"name,omitempty"` + Description string `json:"description,omitempty" yaml:"description,omitempty"` + License string `json:"license,omitempty" yaml:"license,omitempty"` + URLs []string `json:"urls,omitempty" yaml:"urls,omitempty"` + Icon string `json:"icon,omitempty" yaml:"icon,omitempty"` + + // Overrides are used to override the configuration of the model + Overrides map[string]interface{} `json:"overrides,omitempty" yaml:"overrides,omitempty"` + // AdditionalFiles are used to add additional files to the model + AdditionalFiles []File `json:"files,omitempty" yaml:"files,omitempty"` + // Gallery is a reference to the gallery which contains the model + Gallery Gallery `json:"gallery,omitempty" yaml:"gallery,omitempty"` + // Installed is used to indicate if the model is installed or not + Installed bool `json:"installed,omitempty" yaml:"installed,omitempty"` } const (