diff --git a/runtime/models/hypermode.go b/runtime/models/hypermode.go index bc7aab1bc..9f1b71788 100644 --- a/runtime/models/hypermode.go +++ b/runtime/models/hypermode.go @@ -11,6 +11,7 @@ package models import ( "context" + "encoding/json" "fmt" "net/http" "os" @@ -27,11 +28,29 @@ 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) + // Fetch the JSON data from the URL + resp, err := http.Get("https://releases-bucket.hypermode.com/shared-models.json") + if err != nil { + return "", fmt.Errorf("failed to fetch shared models: %v", err) } - endpoint := fmt.Sprintf("https://models.hypermode.host/%s", strings.ToLower(model.SourceModel)) - return endpoint, nil + defer resp.Body.Close() + + // Parse the JSON data into an array of strings + var sharedModels []string + if err := json.NewDecoder(resp.Body).Decode(&sharedModels); err != nil { + return "", fmt.Errorf("failed to parse shared models: %v", err) + } + + // Check if the model exists in the array + modelName := strings.ToLower(model.SourceModel) + for _, sharedModel := range sharedModels { + if sharedModel == modelName { + endpoint := fmt.Sprintf("https://models.hypermode.host/%s", modelName) + return endpoint, nil + } + } + + return "", fmt.Errorf("model %s is not available in the local dev environment", model.SourceModel) } // In production, use the Hypermode internal model endpoint. @@ -55,13 +74,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, -}