summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/main.c b/main.c
index 414a463..266bc34 100644
--- a/main.c
+++ b/main.c
@@ -7,8 +7,6 @@
#include "mem.h"
#include "llama.h"
-#define MODEL_PATH "Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf"
-
#define SYSTEM_PROMPT \
"You are a lexicographer. Define the target word strictly in the context provided.\n\n" \
"Output format strictly as follows:\n" \
@@ -192,8 +190,13 @@ int main(int argc , char *argv[])
struct llama_model *model;
struct llama_model_params mparams;
- if (unveil(MODEL_PATH, "r") == -1)
- err(1, "unveil %s failed", MODEL_PATH);
+ if (argc < 3)
+ errx(1, "usage: %s [model] [prompt]", argv[0]);
+
+ const char *model_path = argv[1];
+
+ if (unveil(model_path, "r") == -1)
+ err(1, "unveil %s failed", model_path);
if (unveil(NULL, NULL) == -1)
err(1, "unveil lock failed");
@@ -201,23 +204,20 @@ int main(int argc , char *argv[])
if (pledge("stdio rpath", NULL) == -1)
err(1, "initial pledge failed");
- if (argc < 2)
- errx(1, "usage: %s [prompt]", argv[0]);
-
llama_backend_init();
mparams = llama_model_default_params();
mparams.n_gpu_layers = 0; /* force all layers onto CPU */
mparams.load_mode = LLAMA_LOAD_MODE_MMAP;
- model = llama_model_load_from_file(MODEL_PATH, mparams);
+ model = llama_model_load_from_file(model_path, mparams);
if (!model)
- errx(1, "failed to load model from file %s", MODEL_PATH);
+ errx(1, "failed to load model from file %s", model_path);
if (pledge("stdio", NULL) == -1)
err(1, "secondary pledge failed");
- const char *prompt = argv[1];
+ const char *prompt = argv[2];
process_request(model, prompt);
llama_model_free(model);