From b57433caef50f5dbc6f9ca7ab9daf189bebc1240 Mon Sep 17 00:00:00 2001 From: shenlan Date: Tue, 12 Aug 2025 23:39:32 +0800 Subject: [PATCH] fix: use OpenAI client for Ollama endpoint --- server/api/askai.go | 9 ++------- server/config/server.yaml | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/server/api/askai.go b/server/api/askai.go index ffe1cbb..d3c2382 100644 --- a/server/api/askai.go +++ b/server/api/askai.go @@ -12,7 +12,6 @@ import ( "github.com/gin-gonic/gin" "github.com/tmc/langchaingo/llms" - "github.com/tmc/langchaingo/llms/ollama" "github.com/tmc/langchaingo/llms/openai" "gopkg.in/yaml.v3" ) @@ -125,7 +124,7 @@ func loadConfig() (string, string, string, string, time.Duration, int) { switch provider { case "ollama": if endpoint == "" { - endpoint = "http://localhost:11434/v1/chat/completions" + endpoint = "http://localhost:11434/v1" } if model == "" { model = "llama2:13b" @@ -163,11 +162,7 @@ func callLLM(question string) (string, error) { switch provider { case "ollama": - llm, err = ollama.New( - ollama.WithModel(model), - ollama.WithServerURL(url), - ollama.WithHTTPClient(httpClient), - ) + fallthrough default: llm, err = openai.New( openai.WithToken(token), diff --git a/server/config/server.yaml b/server/config/server.yaml index e5d31c5..4c63aaa 100644 --- a/server/config/server.yaml +++ b/server/config/server.yaml @@ -29,7 +29,7 @@ models: provider: "ollama" models: - 'llama2:13b' - endpoint: "http://127.0.0.1:11434/v1/chat/completions" + endpoint: "http://127.0.0.1:11434/v1" token: "" # For PROD #models: