Skip to content

Commit b404a20

Browse files
authored
[ggma] Add prompt option to ggma_run tool (Samsung#16276)
- Add -p/--prompt argument - Update README ONE-DCO-1.0-Signed-off-by: Sanggyu Lee <sg5.lee@samsung.com>
1 parent af14f55 commit b404a20

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

runtime/tests/tools/ggma_run/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,19 @@
44

55
It takes GGMA package as input. It uses **GGMA API** internally.
66

7+
## Options
8+
9+
- `-p, --prompt`: Specify the input prompt text (default: "Lily picked up a flower.")
10+
711
## Usage
812

913
```
1014
$ ./ggma_run path_to_ggma_package
15+
$ ./ggma_run path_to_ggma_package -p "Your custom prompt here"
16+
$ ./ggma_run path_to_ggma_package --prompt "What is the weather today?"
1117
```
1218

13-
It will run a GGML package to generate the output using the default prompt.
19+
It will run a GGMA package to generate the output.
1420

1521
## Example
1622

runtime/tests/tools/ggma_run/src/args.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ Args::Args(const int argc, char **argv)
5050
void Args::initialize(void)
5151
{
5252
_arser.add_argument("path").type(arser::DataType::STR).help("nnpackage path");
53+
_arser.add_argument("-p", "--prompt")
54+
.type(arser::DataType::STR)
55+
.default_value("Lily picked up a flower.")
56+
.help("input prompt text");
5357
arser::Helper::add_version(_arser, print_version);
5458
}
5559

@@ -80,6 +84,11 @@ void Args::parse(const int argc, char **argv)
8084
exit(1);
8185
}
8286
}
87+
88+
if (_arser["--prompt"])
89+
{
90+
_prompt = _arser.get<std::string>("--prompt");
91+
}
8392
}
8493
catch (const std::bad_cast &e)
8594
{

runtime/tests/tools/ggma_run/src/args.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class Args
3333
void print(void);
3434

3535
const std::string &packagePath() const { return _package_path; }
36+
const std::string &prompt() const { return _prompt; }
3637
bool printVersion() const { return _print_version; }
3738

3839
private:
@@ -43,6 +44,7 @@ class Args
4344
arser::Arser _arser;
4445

4546
std::string _package_path;
47+
std::string _prompt;
4648
bool _print_version = false;
4749
};
4850

runtime/tests/tools/ggma_run/src/ggma_run.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ int main(const int argc, char **argv)
3838
{
3939
Args args(argc, argv);
4040

41-
std::string prompt = "Lily picked up a flower.";
41+
std::string prompt = args.prompt();
4242
constexpr size_t n_tokens_max = 32;
4343
ggma_token tokens[n_tokens_max];
4444
size_t n_tokens;

0 commit comments

Comments
 (0)