From b3f43ab9382211ec9e5c3036b573051d1bdd2217 Mon Sep 17 00:00:00 2001 From: mudler Date: Sun, 9 Jul 2023 10:02:21 +0200 Subject: [PATCH] Add a way to disable default action --- api/config.go | 3 ++- api/openai.go | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/api/config.go b/api/config.go index 9f10033..60176ec 100644 --- a/api/config.go +++ b/api/config.go @@ -42,6 +42,8 @@ type Config struct { MainGPU string `yaml:"main_gpu"` ImageGenerationAssets string `yaml:"asset_dir"` + DisableDefaultAnswer bool `yaml:"disable_default_answer"` + PromptCachePath string `yaml:"prompt_cache_path"` PromptCacheAll bool `yaml:"prompt_cache_all"` PromptCacheRO bool `yaml:"prompt_cache_ro"` @@ -269,7 +271,6 @@ func updateConfig(config *Config, input *OpenAIRequest) { } } } - // Can be either a string or an object switch fnc := input.FunctionCall.(type) { case string: diff --git a/api/openai.go b/api/openai.go index 41796ac..c1b0104 100644 --- a/api/openai.go +++ b/api/openai.go @@ -425,7 +425,9 @@ func chatEndpoint(cm *ConfigMerger, o *Option) func(c *fiber.Ctx) error { // Append the no action function funcs = append(funcs, input.Functions...) - funcs = append(funcs, noActionGrammar) + if !config.DisableDefaultAnswer { + funcs = append(funcs, noActionGrammar) + } // Force picking one of the functions by the request if config.functionCallNameString != "" {