From 553c8844748897a096d7bdc1940a7e00b6593af3 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Fri, 7 Jul 2023 16:48:13 -0400 Subject: [PATCH] allow specifying server host and port with `OLLAMA_HOST` and `OLLAMA_PORT` --- cmd/cmd.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/cmd.go b/cmd/cmd.go index e6c12367..8fea7e1e 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -153,7 +153,17 @@ func generateBatch(model string) error { } func RunServer(_ *cobra.Command, _ []string) error { - ln, err := net.Listen("tcp", "127.0.0.1:11434") + host := os.Getenv("OLLAMA_HOST") + if host == "" { + host = "127.0.0.1" + } + + port := os.Getenv("OLLAMA_PORT") + if port == "" { + port = "11434" + } + + ln, err := net.Listen("tcp", fmt.Sprintf("%s:%s", host, port)) if err != nil { return err }