Skip to content
This repository was archived by the owner on Oct 6, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions commands/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bufio"
"errors"
"fmt"
"io"
"os"
"strings"

Expand Down Expand Up @@ -101,13 +102,29 @@ func newRunCmd() *cobra.Command {

model := args[0]
prompt := ""
if len(args) == 1 {
if debug {
cmd.Printf("Running model %s\n", model)
args_len := len(args)
if args_len > 1 {
prompt = strings.Join(args[1:], " ")
}

fi, err := os.Stdin.Stat()
if err == nil && (fi.Mode()&os.ModeCharDevice) == 0 {
// Read all from stdin
reader := bufio.NewReader(os.Stdin)
input, err := io.ReadAll(reader)
if err == nil {
if prompt != "" {
prompt += "\n\n"
}

prompt += string(input)
}
} else {
prompt = args[1]
if debug {
}

if debug {
if prompt == "" {
cmd.Printf("Running model %s\n", model)
} else {
cmd.Printf("Running model %s with prompt %s\n", model, prompt)
}
}
Expand Down Expand Up @@ -179,9 +196,7 @@ func newRunCmd() *cobra.Command {
"See 'docker model run --help' for more information",
)
}
if len(args) > 2 {
return fmt.Errorf("too many arguments, expected " + cmdArgs)
}

return nil
}

Expand Down
Loading