Skip to content

Commit 31a01fd

Browse files
committed
fix: ollama client connection string parse now include port detection
1 parent 55cf5bb commit 31a01fd

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

pkg/gpt/gpt.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package gpt
22

33
import (
44
"context"
5+
"net"
56
"net/http"
67
"net/url"
78
"os"
@@ -137,9 +138,21 @@ func init() {
137138
OHostURL = OHost
138139
}
139140

141+
var OHostPort string
142+
switch OHostSchema {
143+
case "http":
144+
OHostPort = "80"
145+
146+
case "https":
147+
OHostPort = "443"
148+
149+
default:
150+
OHostPort = "11434"
151+
}
152+
140153
OClient = Ollama.NewClient(&url.URL{
141154
Scheme: OHostSchema,
142-
Host: OHostURL,
155+
Host: net.JoinHostPort(OHostURL, OHostPort),
143156
Path: OHostPath,
144157
}, http.DefaultClient)
145158
}

0 commit comments

Comments
 (0)