(ctx context.Context, config types.ModelConfig, events api.EventProcessor)
| 159 | } |
| 160 | |
| 161 | func (m *modelAPI) ConfigureModel(ctx context.Context, config types.ModelConfig, events api.EventProcessor) error { |
| 162 | events.On(api.Resource{ |
| 163 | ID: config.Name, |
| 164 | Status: api.Working, |
| 165 | Text: api.StatusConfiguring, |
| 166 | }) |
| 167 | // configure [--context-size=<n>] MODEL [-- <runtime-flags...>] |
| 168 | args := []string{"configure"} |
| 169 | if config.ContextSize > 0 { |
| 170 | args = append(args, "--context-size", strconv.Itoa(config.ContextSize)) |
| 171 | } |
| 172 | args = append(args, config.Model) |
| 173 | // Only append RuntimeFlags if docker model CLI version is >= v1.0.6 |
| 174 | if len(config.RuntimeFlags) != 0 && m.supportsRuntimeFlags() { |
| 175 | args = append(args, "--") |
| 176 | args = append(args, config.RuntimeFlags...) |
| 177 | } |
| 178 | cmd := exec.CommandContext(ctx, m.path, args...) |
| 179 | err := m.prepare(ctx, cmd) |
| 180 | if err != nil { |
| 181 | return err |
| 182 | } |
| 183 | err = cmd.Run() |
| 184 | if err != nil { |
| 185 | events.On(errorEvent(config.Name, err.Error())) |
| 186 | return err |
| 187 | } |
| 188 | events.On(api.Resource{ |
| 189 | ID: config.Name, |
| 190 | Status: api.Done, |
| 191 | Text: api.StatusConfigured, |
| 192 | }) |
| 193 | return nil |
| 194 | } |
| 195 | |
| 196 | func (m *modelAPI) SetModelVariables(ctx context.Context, project *types.Project) error { |
| 197 | cmd := exec.CommandContext(ctx, m.path, "status", "--json") |
no test coverage detected