Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 23 additions & 14 deletions runtime/models/hypermode.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package models

import (
"context"
"encoding/json"
"fmt"
"net/http"
"os"
Expand All @@ -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.
Expand All @@ -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,
}
Loading