Skip to content

Commit 104a4dd

Browse files
dm4hydai
authored andcommitted
[Example] Use arguments for non-interactive mode
- If only the preload model name is given, then it defaults to interactive mode. - If another argument is provided after the preload model name, then it will be considered as a prompt, and it will enter non-interactive mode (just like the previous wasmedge-ggml-llama example)." Signed-off-by: dm4 <dm4@secondstate.io>
1 parent 8a84177 commit 104a4dd

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

‎.github/workflows/llama.yml‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ jobs:
5353
wasmedge --dir .:. \
5454
--env enable_log=false \
5555
--env stream_stdout=false \
56-
--env is_interactive=false \
57-
--nn-preload default:GGML:AUTO:orca-mini-3b.q4_0.gguf \
58-
wasmedge-ggml-llama.wasm default \
56+
--nn-preload default:GGML:CPU:orca-mini-3b.q4_0.gguf \
57+
wasmedge-ggml-llama-interactive.wasm default \
5958
'### System:\nYou are an AI assistant\n\n### User:\nWhere is the capital of Japan?\n\n### Response:\n'

‎wasmedge-ggml-llama-interactive/src/main.rs‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ fn main() {
4444
.trim()
4545
.parse()
4646
.unwrap();
47-
let is_interactive: bool = env::var("is_interactive")
48-
.unwrap_or("true".to_string())
49-
.trim()
50-
.parse()
51-
.unwrap();
5247

5348
let model_name: &str = &args[1];
5449

@@ -78,7 +73,9 @@ fn main() {
7873
)
7974
.unwrap();
8075

81-
if !is_interactive {
76+
// If there is a third argument, use it as the prompt and enter non-interactive mode.
77+
// Otherwise, enter interactive mode.
78+
if args.len() >= 3 {
8279
let prompt = &args[2];
8380
println!("Prompt:\n{}", prompt);
8481
let tensor_data = prompt.as_bytes().to_vec();
-391 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)