Update command flag handling
`lmcli chat` now supports common prompt flags (model, length, system prompt, etc)
This commit is contained in:
@@ -10,17 +10,20 @@ import (
|
||||
"git.mlow.ca/mlow/lmcli/pkg/lmcli/provider/anthropic"
|
||||
"git.mlow.ca/mlow/lmcli/pkg/lmcli/provider/openai"
|
||||
"git.mlow.ca/mlow/lmcli/pkg/lmcli/tools"
|
||||
"git.mlow.ca/mlow/lmcli/pkg/util"
|
||||
"git.mlow.ca/mlow/lmcli/pkg/util/tty"
|
||||
"gorm.io/driver/sqlite"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Context struct {
|
||||
Config *Config
|
||||
Config *Config // may be updated at runtime
|
||||
Store ConversationStore
|
||||
|
||||
Chroma *tty.ChromaHighlighter
|
||||
EnabledTools []model.Tool
|
||||
|
||||
SystemPromptFile string
|
||||
}
|
||||
|
||||
func NewContext() (*Context, error) {
|
||||
@@ -50,7 +53,7 @@ func NewContext() (*Context, error) {
|
||||
}
|
||||
}
|
||||
|
||||
return &Context{config, store, chroma, enabledTools}, nil
|
||||
return &Context{config, store, chroma, enabledTools, ""}, nil
|
||||
}
|
||||
|
||||
func (c *Context) GetModels() (models []string) {
|
||||
@@ -96,6 +99,17 @@ func (c *Context) GetCompletionProvider(model string) (provider.ChatCompletionCl
|
||||
return nil, fmt.Errorf("unknown model: %s", model)
|
||||
}
|
||||
|
||||
func (c *Context) GetSystemPrompt() string {
|
||||
if c.SystemPromptFile != "" {
|
||||
content, err := util.ReadFileContents(c.SystemPromptFile)
|
||||
if err != nil {
|
||||
Fatal("Could not read file contents at %s: %v\n", c.SystemPromptFile, err)
|
||||
}
|
||||
return content
|
||||
}
|
||||
return *c.Config.Defaults.SystemPrompt
|
||||
}
|
||||
|
||||
func configDir() string {
|
||||
var configDir string
|
||||
|
||||
|
||||
Reference in New Issue
Block a user