diff --git a/CHANGELOG.md b/CHANGELOG.md index 906fe08f2..0e6cd8e4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ - fix: add json serialization support for neo4j sdk types [#699](https://github.com/hypermodeinc/modus/pull/699) - chore: update api-explorer to react 19 [#700](https://github.com/hypermodeinc/modus/pull/700) +- chore: remove localHypermodeModels list and handle 404s properly instead in local dev + [#703](https://github.com/hypermodeinc/modus/pull/703) - fix: remove fallback to default time zone [#706](https://github.com/hypermodeinc/modus/pull/706) ## 2025-01-09 - CLI 0.16.6 diff --git a/runtime/models/hypermode.go b/runtime/models/hypermode.go index bc7aab1bc..d33cf2204 100644 --- a/runtime/models/hypermode.go +++ b/runtime/models/hypermode.go @@ -27,9 +27,6 @@ func getHypermodeModelEndpointUrl(model *manifest.ModelInfo) (string, error) { // In development, use the shared Hypermode model server. // Note: Authentication via the Hypermode CLI is required. if config.IsDevEnvironment() { - if _, ok := localHypermodeModels[strings.ToLower(model.SourceModel)]; !ok { - return "", fmt.Errorf("model %s is not available in the local dev environment", model.SourceModel) - } endpoint := fmt.Sprintf("https://models.hypermode.host/%s", strings.ToLower(model.SourceModel)) return endpoint, nil } @@ -55,13 +52,3 @@ func authenticateHypermodeModelRequest(ctx context.Context, req *http.Request, c // In production, the Hypermode infrastructure protects the model server. return nil } - -// cSpell:disable -// These are the Hypermode models that are available in the local dev environment. -// This list may be updated as new models are added. -var localHypermodeModels = map[string]bool{ - "meta-llama/meta-llama-3.1-8b-instruct": true, - "sentence-transformers/all-minilm-l6-v2": true, - "antoinemc/distilbart-mnli-github-issues": true, - "distilbert/distilbert-base-uncased-finetuned-sst-2-english": true, -} diff --git a/runtime/models/models.go b/runtime/models/models.go index ba577cfb7..a87e4d0ae 100644 --- a/runtime/models/models.go +++ b/runtime/models/models.go @@ -11,11 +11,13 @@ package models import ( "context" + "errors" "fmt" "net/http" "strings" "github.com/hypermodeinc/modus/lib/manifest" + "github.com/hypermodeinc/modus/runtime/config" "github.com/hypermodeinc/modus/runtime/db" "github.com/hypermodeinc/modus/runtime/httpclient" "github.com/hypermodeinc/modus/runtime/manifestdata" @@ -89,6 +91,13 @@ func PostToModelEndpoint[TResult any](ctx context.Context, model *manifest.Model res, err := utils.PostHttp[TResult](ctx, url, payload, bs) if err != nil { var empty TResult + var httpe *utils.HttpError + if errors.As(err, &httpe) { + if config.IsDevEnvironment() && httpe.StatusCode == http.StatusNotFound { + return empty, fmt.Errorf("model %s is not available in the local dev environment", model.SourceModel) + } + } + return empty, err } diff --git a/runtime/utils/http.go b/runtime/utils/http.go index b6f31c6f3..91c560a97 100644 --- a/runtime/utils/http.go +++ b/runtime/utils/http.go @@ -20,6 +20,15 @@ import ( var httpClient = &http.Client{} +type HttpError struct { + StatusCode int + Message string +} + +func (e *HttpError) Error() string { + return "HTTP error: " + e.Message +} + func HttpClient() *http.Client { return httpClient } @@ -38,9 +47,15 @@ func sendHttp(req *http.Request) ([]byte, error) { if response.StatusCode != http.StatusOK { if len(body) == 0 { - return nil, fmt.Errorf("HTTP error: %s", response.Status) + return nil, &HttpError{ + StatusCode: response.StatusCode, + Message: response.Status, + } } else { - return nil, fmt.Errorf("HTTP error: %s\n%s", response.Status, body) + return nil, &HttpError{ + StatusCode: response.StatusCode, + Message: fmt.Sprintf("%s\n%s", response.Status, body), + } } }