diff options
author | Grail Finder <wohilas@gmail.com> | 2025-02-01 16:32:36 +0300 |
---|---|---|
committer | Grail Finder <wohilas@gmail.com> | 2025-02-01 16:32:36 +0300 |
commit | 84c94ecea34753f246bdfd51f6ff989281e873e3 (patch) | |
tree | 3e4330ed00811cd46299968af69e6f3671316aa6 /config | |
parent | 336451340b86ba1f713b47d44225df61058f5a8f (diff) |
Feat: switch between completion and chat api
Diffstat (limited to 'config')
-rw-r--r-- | config/config.go | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/config/config.go b/config/config.go index eb5f3f1..2e48f34 100644 --- a/config/config.go +++ b/config/config.go @@ -7,7 +7,11 @@ import ( ) type Config struct { - APIURL string `toml:"APIURL"` + ChatAPI string `toml:"ChatAPI"` + CompletionAPI string `toml:"CompletionAPI"` + CurrentAPI string + APIMap map[string]string + // ShowSys bool `toml:"ShowSys"` LogFile string `toml:"LogFile"` UserRole string `toml:"UserRole"` @@ -34,7 +38,8 @@ func LoadConfigOrDefault(fn string) *Config { _, err := toml.DecodeFile(fn, &config) if err != nil { fmt.Println("failed to read config from file, loading default") - config.APIURL = "http://localhost:8080/v1/chat/completions" + config.ChatAPI = "http://localhost:8080/v1/chat/completions" + config.CompletionAPI = "http://localhost:8080/completion" config.RAGEnabled = false config.EmbedURL = "http://localhost:8080/v1/embiddings" config.ShowSys = true @@ -48,6 +53,16 @@ func LoadConfigOrDefault(fn string) *Config { config.SysDir = "sysprompts" config.ChunkLimit = 8192 } + config.CurrentAPI = config.ChatAPI + config.APIMap = map[string]string{ + config.ChatAPI: config.CompletionAPI, + } + if config.CompletionAPI != "" { + config.CurrentAPI = config.CompletionAPI + config.APIMap = map[string]string{ + config.CompletionAPI: config.ChatAPI, + } + } // if any value is empty fill with default return config } |