Commit 4d8b0414 authored by Bruce MacDonald's avatar Bruce MacDonald
Browse files

take all args as one prompt

- parse all run arguments into one prompt
- do not echo prompt back on one-shot
- example of summarizing a document
parent 049295d9
...@@ -48,6 +48,14 @@ Ask questions. Get answers. ...@@ -48,6 +48,14 @@ Ask questions. Get answers.
ollama run orca "Write an email to my boss." ollama run orca "Write an email to my boss."
``` ```
### 🔎 Ask questions about documents
Send the contents of a document and ask questions about it.
```
ollama run nous-hermes "$(cat input.txt)", please summarize this story
```
### 📖 Storytelling ### 📖 Storytelling
Venture into the unknown. Venture into the unknown.
......
...@@ -64,8 +64,10 @@ func pull(model string) error { ...@@ -64,8 +64,10 @@ func pull(model string) error {
} }
func RunGenerate(_ *cobra.Command, args []string) error { func RunGenerate(_ *cobra.Command, args []string) error {
// join all args into a single prompt
prompt := strings.Join(args[1:], " ")
if len(args) > 1 { if len(args) > 1 {
return generateOneshot(args[0], args[1:]...) return generate(args[0], prompt)
} }
if term.IsTerminal(int(os.Stdin.Fd())) { if term.IsTerminal(int(os.Stdin.Fd())) {
...@@ -114,17 +116,6 @@ func generate(model, prompt string) error { ...@@ -114,17 +116,6 @@ func generate(model, prompt string) error {
return nil return nil
} }
func generateOneshot(model string, prompts ...string) error {
for _, prompt := range prompts {
fmt.Printf(">>> %s\n", prompt)
if err := generate(model, prompt); err != nil {
return err
}
}
return nil
}
func generateInteractive(model string) error { func generateInteractive(model string) error {
fmt.Print(">>> ") fmt.Print(">>> ")
scanner := bufio.NewScanner(os.Stdin) scanner := bufio.NewScanner(os.Stdin)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment