From 84c94ecea34753f246bdfd51f6ff989281e873e3 Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Sat, 1 Feb 2025 16:32:36 +0300 Subject: Feat: switch between completion and chat api --- config/config.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'config/config.go') 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 } -- cgit v1.2.3