shim_ext_server_windows.go 742 Bytes
Newer Older
1
2
3
4
5
6
package llm

import (
	"embed"
	"log"
	"os"
7
	"path/filepath"
8
9
10
	"strings"
)

11
//go:embed llama.cpp/build/windows/*/lib/*.dll
12
13
14
var libEmbed embed.FS

func updatePath(dir string) {
15
	tmpDir := filepath.Dir(dir)
16
	pathComponents := strings.Split(os.Getenv("PATH"), ";")
17
	i := 0
18
	for _, comp := range pathComponents {
19
		if strings.EqualFold(comp, dir) {
20
21
			return
		}
22
23
24
25
26
		// Remove any other prior paths to our temp dir
		if !strings.HasPrefix(strings.ToLower(comp), strings.ToLower(tmpDir)) {
			pathComponents[i] = comp
			i++
		}
27
	}
28
	newPath := strings.Join(append([]string{dir}, pathComponents...), ";")
29
30
31
32
33
34
35
36
	log.Printf("Updating PATH to %s", newPath)
	os.Setenv("PATH", newPath)
}

func verifyDriverAccess() error {
	// TODO if applicable
	return nil
}