Browse Source

change ollama url

master
godo 6 months ago
parent
commit
e73a3a098a
  1. 4
      godo/ai/server/llms.go
  2. 4
      godo/ai/server/ollama.go
  3. 17
      godo/libs/dir.go

4
godo/ai/server/llms.go

@ -3,6 +3,7 @@ package server
import (
"fmt"
"godo/libs"
"log"
)
// ollama openai deepseek bigmodel alibaba 01ai cloudflare groq mistral anthropic llamafamily
@ -49,7 +50,8 @@ func GetHeadersAndUrl(req map[string]interface{}, chattype string) (map[string]s
} else if engine == "gitee" {
url = GetGiteeUrl(model, chattype)
} else if engine == "ollama" {
url = GetOllamaUrl()
url = GetOllamaUrl() + "/v1"
log.Printf("get ollama url is %v", url)
}
}

4
godo/ai/server/ollama.go

@ -396,11 +396,11 @@ func GetOllamaModelDir() string {
}
func GetOllamaUrl() string {
if s := strings.TrimSpace(Var("OLLAMA_HOST")); s != "" {
return s
return "http://" + s
}
ollamaUrl, ok := libs.GetConfig("ollamaUrl")
if ok {
return ollamaUrl.(string)
return "http://" + ollamaUrl.(string)
} else {
return "http://localhost:11434"
}

17
godo/libs/dir.go

@ -25,6 +25,7 @@ import (
"os"
"path/filepath"
"runtime"
"strings"
)
func InitServer() error {
@ -71,13 +72,21 @@ func InitOsDir() (string, error) {
}
func InitOllamaModelPath() {
ollamaDir, ok := GetConfig("ollamaDir")
if ok && ollamaDir.(string) != "" {
os.Setenv("OLLAMA_MODELS", ollamaDir.(string))
if ok {
dirStr, ok := ollamaDir.(string)
if ok && dirStr != "" {
os.Setenv("OLLAMA_MODELS", ollamaDir.(string))
}
}
ollamaUrl, ok := GetConfig("ollamaUrl")
if ok && ollamaUrl.(string) != "" {
os.Setenv("OLLAMA_HOST", ollamaUrl.(string))
if ok {
urlStr, ok := ollamaUrl.(string)
if ok && urlStr != "" {
urlStr = strings.TrimPrefix(strings.TrimPrefix(urlStr, "http://"), "https://")
os.Setenv("OLLAMA_HOST", urlStr)
}
}
}
func GetOsDir() (string, error) {
osDir, ok := GetConfig("osPath")

Loading…
Cancel
Save