Private
Public Access
1
0

Add Ollama support

This commit is contained in:
2024-06-01 01:38:45 +00:00
parent 465b1d333e
commit ea576d24a6
2 changed files with 209 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ import (
"git.mlow.ca/mlow/lmcli/pkg/lmcli/provider"
"git.mlow.ca/mlow/lmcli/pkg/lmcli/provider/anthropic"
"git.mlow.ca/mlow/lmcli/pkg/lmcli/provider/google"
"git.mlow.ca/mlow/lmcli/pkg/lmcli/provider/ollama"
"git.mlow.ca/mlow/lmcli/pkg/lmcli/provider/openai"
"git.mlow.ca/mlow/lmcli/pkg/lmcli/tools"
"git.mlow.ca/mlow/lmcli/pkg/util"
@@ -113,6 +114,14 @@ func (c *Context) GetModelProvider(model string) (string, provider.ChatCompletio
BaseURL: url,
APIKey: *p.APIKey,
}, nil
case "ollama":
url := "http://localhost:11434/api"
if p.BaseURL != nil {
url = *p.BaseURL
}
return model, &ollama.OllamaClient{
BaseURL: url,
}, nil
case "openai":
url := "https://api.openai.com/v1"
if p.BaseURL != nil {