2026-02-17 16:57:43 +00:00
|
|
|
//go:build darwin && arm64
|
2026-02-16 02:01:52 +00:00
|
|
|
|
|
|
|
|
package ml
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"log/slog"
|
|
|
|
|
|
2026-02-17 16:57:43 +00:00
|
|
|
"forge.lthn.ai/core/go-ai/ml"
|
2026-02-16 02:01:52 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func createServeBackend() (ml.Backend, error) {
|
|
|
|
|
if serveModelPath != "" {
|
|
|
|
|
slog.Info("ml serve: loading native MLX backend", "path", serveModelPath)
|
|
|
|
|
b, err := ml.NewMLXBackend(serveModelPath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, fmt.Errorf("mlx backend: %w", err)
|
|
|
|
|
}
|
|
|
|
|
return b, nil
|
|
|
|
|
}
|
|
|
|
|
return ml.NewHTTPBackend(apiURL, modelName), nil
|
|
|
|
|
}
|