2023-12-23 19:35:44 +00:00
|
|
|
package llm
|
|
|
|
|
|
|
|
import (
|
|
|
|
"embed"
|
|
|
|
"log"
|
|
|
|
"os"
|
2024-01-04 16:41:41 +00:00
|
|
|
"path/filepath"
|
2023-12-23 19:35:44 +00:00
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2024-01-04 17:40:15 +00:00
|
|
|
//go:embed llama.cpp/build/windows/*/lib/*.dll
|
2023-12-23 19:35:44 +00:00
|
|
|
var libEmbed embed.FS
|
|
|
|
|
|
|
|
func updatePath(dir string) {
|
2024-01-04 16:41:41 +00:00
|
|
|
tmpDir := filepath.Dir(dir)
|
2023-12-23 19:35:44 +00:00
|
|
|
pathComponents := strings.Split(os.Getenv("PATH"), ";")
|
2024-01-04 16:41:41 +00:00
|
|
|
i := 0
|
2023-12-23 19:35:44 +00:00
|
|
|
for _, comp := range pathComponents {
|
2024-01-04 16:41:41 +00:00
|
|
|
if strings.EqualFold(comp, dir) {
|
2023-12-23 19:35:44 +00:00
|
|
|
return
|
|
|
|
}
|
2024-01-04 16:41:41 +00:00
|
|
|
// Remove any other prior paths to our temp dir
|
|
|
|
if !strings.HasPrefix(strings.ToLower(comp), strings.ToLower(tmpDir)) {
|
|
|
|
pathComponents[i] = comp
|
|
|
|
i++
|
|
|
|
}
|
2023-12-23 19:35:44 +00:00
|
|
|
}
|
2024-01-04 16:41:41 +00:00
|
|
|
newPath := strings.Join(append([]string{dir}, pathComponents...), ";")
|
2023-12-23 19:35:44 +00:00
|
|
|
log.Printf("Updating PATH to %s", newPath)
|
|
|
|
os.Setenv("PATH", newPath)
|
|
|
|
}
|
|
|
|
|
|
|
|
func verifyDriverAccess() error {
|
|
|
|
// TODO if applicable
|
|
|
|
return nil
|
|
|
|
}
|