Update system prompt handling (again)
Add `api.ApplySystemPrompt`, renamed `GetSystemPrompt` to `DefaultSystemPrompt`.
This commit is contained in:
@@ -70,14 +70,3 @@ func NewConfig(configFile string) (*Config, error) {
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func (c *Config) GetSystemPrompt() string {
|
||||
if c.Defaults.SystemPromptFile != "" {
|
||||
content, err := util.ReadFileContents(c.Defaults.SystemPromptFile)
|
||||
if err != nil {
|
||||
Fatal("Could not read file contents at %s: %v\n", c.Defaults.SystemPromptFile, err)
|
||||
}
|
||||
return content
|
||||
}
|
||||
return c.Defaults.SystemPrompt
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"git.mlow.ca/mlow/lmcli/pkg/api/provider/google"
|
||||
"git.mlow.ca/mlow/lmcli/pkg/api/provider/ollama"
|
||||
"git.mlow.ca/mlow/lmcli/pkg/api/provider/openai"
|
||||
"git.mlow.ca/mlow/lmcli/pkg/util"
|
||||
"git.mlow.ca/mlow/lmcli/pkg/util/tty"
|
||||
"gorm.io/driver/sqlite"
|
||||
"gorm.io/gorm"
|
||||
@@ -81,6 +82,17 @@ func (c *Context) GetModels() (models []string) {
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Context) DefaultSystemPrompt() string {
|
||||
if c.Config.Defaults.SystemPromptFile != "" {
|
||||
content, err := util.ReadFileContents(c.Config.Defaults.SystemPromptFile)
|
||||
if err != nil {
|
||||
Fatal("Could not read file contents at %s: %v\n", c.Config.Defaults.SystemPromptFile, err)
|
||||
}
|
||||
return content
|
||||
}
|
||||
return c.Config.Defaults.SystemPrompt
|
||||
}
|
||||
|
||||
func (c *Context) GetModelProvider(model string) (string, api.ChatCompletionProvider, error) {
|
||||
parts := strings.Split(model, "@")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user