From af9a73d55ef494b8f10e3c2686ee27d9dedaff6d Mon Sep 17 00:00:00 2001 From: macie Date: Fri, 19 Jan 2024 17:01:51 +0100 Subject: [PATCH] feat: Rename prompt prefix "Initial prompt" is misleading: is it a first prompt? --- cmd/boludo/config.go | 40 +++++++++++++++++++-------------------- cmd/boludo/config_test.go | 22 ++++++++++----------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/cmd/boludo/config.go b/cmd/boludo/config.go index 00ea63c..a1f7894 100644 --- a/cmd/boludo/config.go +++ b/cmd/boludo/config.go @@ -89,10 +89,10 @@ func NewAppConfig(cliArgs []string) (AppConfig, error) { options.Update(configArgs.Options()) prompt := configFile.Prompt(configArgs.ConfigId) - initialPrompt := configFile.InitialPrompt(configArgs.ConfigId) + promptPrefix := configFile.PromptPrefix(configArgs.ConfigId) userPrompt := configArgs.Prompt - if initialPrompt != "" { - userPrompt = fmt.Sprintf("%s %s", initialPrompt, userPrompt) + if promptPrefix != "" { + userPrompt = fmt.Sprintf("%s %s", promptPrefix, userPrompt) } return AppConfig{ @@ -186,12 +186,12 @@ type ConfigFile map[string]ModelSpec // ModelSpec represents a model specification in the configuration file. type ModelSpec struct { - Model string - SystemPrompt string - InitialPrompt string - Format string - Creativity float32 - Cutoff float32 + Model string + SystemPrompt string + PromptPrefix string + Format string + Creativity float32 + Cutoff float32 } // ParseFile reads the TOML configuration file and returns a ConfigFile. @@ -225,12 +225,12 @@ func (c *ConfigFile) UnmarshalTOML(data interface{}) error { definedConfigs, _ := data.(map[string]interface{}) for configId := range definedConfigs { defaultSpec := ModelSpec{ - Model: "", - SystemPrompt: "", - InitialPrompt: "", - Format: "", - Creativity: llama.DefaultOptions.Temp, - Cutoff: llama.DefaultOptions.MinP, + Model: "", + SystemPrompt: "", + PromptPrefix: "", + Format: "", + Creativity: llama.DefaultOptions.Temp, + Cutoff: llama.DefaultOptions.MinP, } for k, v := range definedConfigs[configId].(map[string]interface{}) { switch k { @@ -244,8 +244,8 @@ func (c *ConfigFile) UnmarshalTOML(data interface{}) error { defaultSpec.Format = v.(string) case "system-prompt": defaultSpec.SystemPrompt = v.(string) - case "initial-prompt": - defaultSpec.InitialPrompt = v.(string) + case "prompt-prefix": + defaultSpec.PromptPrefix = v.(string) } } (*c)[configId] = defaultSpec @@ -280,10 +280,10 @@ func (c *ConfigFile) Prompt(configId string) llama.Prompt { return llama.Prompt{} } -// InitialPrompt returns the initial prompt specified in the ConfigFile. -func (c *ConfigFile) InitialPrompt(configId string) string { +// PromptPrefix returns the prompt prefix specified in the ConfigFile. +func (c *ConfigFile) PromptPrefix(configId string) string { if spec, ok := (*c)[configId]; ok { - return spec.InitialPrompt + return spec.PromptPrefix } return "" } diff --git a/cmd/boludo/config_test.go b/cmd/boludo/config_test.go index e6bf81b..20b3896 100644 --- a/cmd/boludo/config_test.go +++ b/cmd/boludo/config_test.go @@ -101,12 +101,12 @@ func TestParseFile(t *testing.T) { Cutoff: 0.5, }, }}, - {"[edit]\nmodel = \"model.gguf\"\ninitial-prompt = 'Reword:'\n[unknown]", ConfigFile{ + {"[edit]\nmodel = \"model.gguf\"\nprompt-prefix = 'Reword:'\n[unknown]", ConfigFile{ "edit": ModelSpec{ - Model: "model.gguf", - Format: "", - InitialPrompt: "Reword:", - Creativity: 1.0, + Model: "model.gguf", + Format: "", + PromptPrefix: "Reword:", + Creativity: 1.0, }, "unknown": ModelSpec{ Model: "", @@ -115,13 +115,13 @@ func TestParseFile(t *testing.T) { Cutoff: 0.0, }, }}, - {"[assistant]\nmodel = \"model.gguf\"\ninitial-prompt = 'Reword:'\nsystem-prompt = 'You are an assistant.'", ConfigFile{ + {"[assistant]\nmodel = \"model.gguf\"\nprompt-prefix = 'Reword:'\nsystem-prompt = 'You are an assistant.'", ConfigFile{ "assistant": ModelSpec{ - Model: "model.gguf", - Format: "", - InitialPrompt: "Reword:", - SystemPrompt: "You are an assistant.", - Creativity: 1.0, + Model: "model.gguf", + Format: "", + PromptPrefix: "Reword:", + SystemPrompt: "You are an assistant.", + Creativity: 1.0, }, }}, }