diff --git a/docs/ramalama-run.1.md b/docs/ramalama-run.1.md index 66063be5..0631660c 100644 --- a/docs/ramalama-run.1.md +++ b/docs/ramalama-run.1.md @@ -4,7 +4,7 @@ ramalama\-run - Run specified AI Model as a chatbot ## SYNOPSIS -**ramalama run** [*options*] *model* +**ramalama run** [*options*] *model* [arg ...] ## OPTIONS @@ -20,7 +20,23 @@ Modify the prompt in the AI Chatbot ## DESCRIPTION Run specified AI Model as a chat bot. Ramalama pulls specified AI Model from -registry if it does not exist in local storage. +registry if it does not exist in local storage. By default a prompt for a chat +bot will be started. When arguments are specified, the arguments will be given +to the AI Model and the output returned without entering the chatbot. + +## EXAMPLES + +Run command without arguments starts a chatbot +``` +ramalama run granite + +> +``` + +``` +ramalama run merlinite "when is the summer solstice" +The summer solstice, which is the longest day of the year, will happen on June ... +``` ## SEE ALSO **[ramalama(1)](ramalama.1.md)** diff --git a/ramalama/model.py b/ramalama/model.py index 96319fb9..92a2d228 100644 --- a/ramalama/model.py +++ b/ramalama/model.py @@ -77,21 +77,27 @@ def get_symlink_path(self, args): raise NotImplementedError(f"get_symlink_path for {self.type} not implemented") def run(self, args): + prompt = "You are a helpful assistant" + if args.ARGS: + prompt = " ".join(args.ARGS) + symlink_path = self.pull(args) exec_args = [ "llama-cli", "-m", symlink_path, "--log-disable", - "-cnv", - "-p", - "You are a helpful assistant", "--in-prefix", "", "--in-suffix", "", "--no-display-prompt", + "-p", + prompt, ] + self.common_params + if not args.ARGS: + exec_args.append("-cnv") + exec_cmd(exec_args) def serve(self, args): diff --git a/test/system/030-run.bats b/test/system/030-run.bats index c1ce8fb0..8f4d70b5 100644 --- a/test/system/030-run.bats +++ b/test/system/030-run.bats @@ -22,4 +22,11 @@ load helpers is "${lines[0]}" "--nocontainer and --name options conflict. --name requires a container." "conflict between nocontainer and --name line" } +@test "ramalama run granite with prompt" { + run_ramalama run --name foobar granite "How often to full moons happen" + is "$output" ".*Moon" "should include some info about the Moon" + run_ramalama list + is "$output" ".*granite" "granite model should have been pulled" +} + # vim: filetype=sh