( ctx context.Context, db database.Store, id *uuid.UUID, )
| 510 | } |
| 511 | |
| 512 | func validateChatModelOverrideID( |
| 513 | ctx context.Context, |
| 514 | db database.Store, |
| 515 | id *uuid.UUID, |
| 516 | ) (int, *codersdk.Response) { |
| 517 | if id == nil { |
| 518 | return 0, nil |
| 519 | } |
| 520 | if *id == uuid.Nil { |
| 521 | return http.StatusBadRequest, &codersdk.Response{ |
| 522 | Message: "Invalid model_config_id.", |
| 523 | } |
| 524 | } |
| 525 | _, err := lookupEnabledChatModelConfigByID(ctx, db, *id) |
| 526 | if err == nil { |
| 527 | return 0, nil |
| 528 | } |
| 529 | if xerrors.Is(err, sql.ErrNoRows) { |
| 530 | return http.StatusBadRequest, &codersdk.Response{ |
| 531 | Message: "Invalid model_config_id.", |
| 532 | } |
| 533 | } |
| 534 | return http.StatusInternalServerError, &codersdk.Response{ |
| 535 | Message: "Internal error validating model config override.", |
| 536 | Detail: err.Error(), |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | func (api *API) getChatModelOverrideConfig( |
| 541 | ctx context.Context, |
no test coverage detected