Skip to content

Commit

Permalink
feat: Rename prompt prefix
Browse files Browse the repository at this point in the history
"Initial prompt" is misleading: is it a first prompt?
  • Loading branch information
macie committed Jan 19, 2024
1 parent ad12b1d commit af9a73d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
40 changes: 20 additions & 20 deletions cmd/boludo/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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 ""
}
22 changes: 11 additions & 11 deletions cmd/boludo/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: "",
Expand All @@ -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,
},
}},
}
Expand Down

0 comments on commit af9a73d

Please sign in to comment.