Skip to content

Commit

Permalink
Merge pull request #162 from rhatdan/run
Browse files Browse the repository at this point in the history
Fix handling of ramalama run MODEL CMD
  • Loading branch information
ericcurtin authored Sep 20, 2024
2 parents c57c9e3 + a62f929 commit b3a2b24
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
20 changes: 18 additions & 2 deletions docs/ramalama-run.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
ramalama\-run - Run specified AI Model as a chatbot

## SYNOPSIS
**ramalama run** [*options*] *model*
**ramalama run** [*options*] *model* [arg ...]

## OPTIONS

Expand All @@ -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)**
Expand Down
12 changes: 9 additions & 3 deletions ramalama/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
7 changes: 7 additions & 0 deletions test/system/030-run.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b3a2b24

Please sign in to comment.