mirror of
https://github.com/ollama/ollama.git
synced 2025-04-02 09:00:28 +02:00
Merge 15225bd99ddd98d69514cff88e9bbbac548abba8 into e27e4a3c1b9cb3a34178d5476debf805910e990a
This commit is contained in:
commit
a4441cbf0b
24
cmd/cmd.go
24
cmd/cmd.go
@ -241,6 +241,7 @@ func loadOrUnloadModel(cmd *cobra.Command, opts *runOptions) error {
|
||||
|
||||
req := &api.GenerateRequest{
|
||||
Model: opts.Model,
|
||||
Options: opts.Options,
|
||||
KeepAlive: opts.KeepAlive,
|
||||
}
|
||||
|
||||
@ -264,10 +265,23 @@ func StopHandler(cmd *cobra.Command, args []string) error {
|
||||
func RunHandler(cmd *cobra.Command, args []string) error {
|
||||
interactive := true
|
||||
|
||||
rawParams, err := cmd.Flags().GetStringToString("parameter")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
paramSingletons := make(map[string][]string)
|
||||
for key, rawParam := range rawParams {
|
||||
paramSingletons[key] = []string{rawParam}
|
||||
}
|
||||
parameters, err := api.FormatParams(paramSingletons)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
opts := runOptions{
|
||||
Model: args[0],
|
||||
WordWrap: os.Getenv("TERM") == "xterm-256color",
|
||||
Options: map[string]interface{}{},
|
||||
Options: parameters,
|
||||
}
|
||||
|
||||
format, err := cmd.Flags().GetString("format")
|
||||
@ -276,6 +290,12 @@ func RunHandler(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
opts.Format = format
|
||||
|
||||
system, err := cmd.Flags().GetString("system")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts.System = system
|
||||
|
||||
keepAlive, err := cmd.Flags().GetString("keepalive")
|
||||
if err != nil {
|
||||
return err
|
||||
@ -1252,6 +1272,8 @@ func NewCLI() *cobra.Command {
|
||||
runCmd.Flags().Bool("insecure", false, "Use an insecure registry")
|
||||
runCmd.Flags().Bool("nowordwrap", false, "Don't wrap words to the next line automatically")
|
||||
runCmd.Flags().String("format", "", "Response format (e.g. json)")
|
||||
runCmd.Flags().String("system", "", "Set system message")
|
||||
runCmd.Flags().StringToString("parameter", map[string]string{}, "Set a parameter (e.g. num_ctx:4096)")
|
||||
|
||||
stopCmd := &cobra.Command{
|
||||
Use: "stop MODEL",
|
||||
|
@ -123,6 +123,11 @@ func generateInteractive(cmd *cobra.Command, opts runOptions) error {
|
||||
scanner.HistoryDisable()
|
||||
}
|
||||
|
||||
if opts.System != "" {
|
||||
newMessage := api.Message{Role: "system", Content: opts.System}
|
||||
opts.Messages = append(opts.Messages, newMessage)
|
||||
}
|
||||
|
||||
fmt.Print(readline.StartBracketedPaste)
|
||||
defer fmt.Printf(readline.EndBracketedPaste)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user