Skip to content

Commit

Permalink
feat: Read system prompt from config file
Browse files Browse the repository at this point in the history
  • Loading branch information
macie committed Jan 2, 2024
1 parent 8be172c commit 6839423
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/boludo/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ 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
Expand Down Expand Up @@ -229,6 +230,7 @@ func (c *ConfigFile) UnmarshalTOML(data interface{}) error {
for configId := range definedConfigs {
defaultSpec := ModelSpec{
Model: "",
SystemPrompt: "",
InitialPrompt: "",
Format: "",
Creativity: llama.DefaultOptions.Temp,
Expand All @@ -244,6 +246,8 @@ func (c *ConfigFile) UnmarshalTOML(data interface{}) error {
defaultSpec.Cutoff = (float32)(v.(float64))
case "format":
defaultSpec.Format = v.(string)
case "system-prompt":
defaultSpec.SystemPrompt = v.(string)
case "initial-prompt":
defaultSpec.InitialPrompt = v.(string)
}
Expand Down Expand Up @@ -274,6 +278,7 @@ func (c *ConfigFile) Prompt(configId string) llama.Prompt {
if spec, ok := (*c)[configId]; ok {
return llama.Prompt{
Format: spec.Format,
System: spec.SystemPrompt,
}
}
return llama.Prompt{}
Expand Down
9 changes: 9 additions & 0 deletions cmd/boludo/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ func TestParseFile(t *testing.T) {
Cutoff: 0.0,
},
}},
{"[assistant]\nmodel = \"model.gguf\"\ninitial-prompt = 'Reword:'\nsystem-prompt = 'You are an assistant.'", ConfigFile{
"assistant": ModelSpec{
Model: "model.gguf",
Format: "",
InitialPrompt: "Reword:",
SystemPrompt: "You are an assistant.",
Creativity: 1.0,
},
}},
}
for _, tc := range testcases {
tc := tc
Expand Down

0 comments on commit 6839423

Please sign in to comment.