Merge pull request #859 from jmorganca/mxyng/fix-hostname

fix: ollama host for hostname
This commit is contained in:
Michael Yang 2023-10-20 11:40:56 -07:00 committed by GitHub
commit 533d76368c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -52,8 +52,10 @@ func ClientFromEnvironment() (*Client, error) {
host, port, err := net.SplitHostPort(hostport) host, port, err := net.SplitHostPort(hostport)
if err != nil { if err != nil {
host, port = "127.0.0.1", "11434" host, port = "127.0.0.1", "11434"
if ip := net.ParseIP(strings.Trim(os.Getenv("OLLAMA_HOST"), "[]")); ip != nil { if ip := net.ParseIP(strings.Trim(hostport, "[]")); ip != nil {
host = ip.String() host = ip.String()
} else if hostport != "" {
host = hostport
} }
} }