(ctx *gin.Context, provider string, input *model_dto.Model)
| 55 | } |
| 56 | |
| 57 | func (i *imlProviderModelController) AddProviderModel(ctx *gin.Context, provider string, input *model_dto.Model) (*model_dto.SimpleModel, error) { |
| 58 | if !common.ModelNameValid(input.Name) { |
| 59 | return nil, fmt.Errorf("model name illegal(a-zA-Z0-9-_.:/)") |
| 60 | } |
| 61 | if strings.TrimSpace(provider) == "" { |
| 62 | return nil, fmt.Errorf("provider is empty") |
| 63 | } |
| 64 | // check access config & model parameter is json format |
| 65 | if strings.TrimSpace(input.AccessConfiguration) != "" && !json.Valid([]byte(input.AccessConfiguration)) { |
| 66 | return nil, fmt.Errorf("access configuration is not json format") |
| 67 | } |
| 68 | if strings.TrimSpace(input.ModelParameters) != "" && !json.Valid([]byte(input.ModelParameters)) { |
| 69 | return nil, fmt.Errorf("model parameters is not json format") |
| 70 | } |
| 71 | return i.module.AddProviderModel(ctx, provider, input) |
| 72 | } |
nothing calls this directly
no test coverage detected