Skip to content

Commit abcc6e6

Browse files
author
Anivar A Aravind
committed
Fix llava-cli to work when running as llamafile
- Detect when running as ./llava.llamafile executable - Set model path to executable when embedded - Allow mmproj auto-detection even when model path is empty
1 parent 46ce18d commit abcc6e6

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

llama.cpp/llava/llava-cli.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "llamafile/version.h"
1111
#include "llamafile/llamafile.h"
1212

13+
#include <cosmo.h>
1314
#include <cstdio>
1415
#include <cstdlib>
1516
#include <vector>
@@ -372,8 +373,20 @@ int llava_cli(int argc, char ** argv, gpt_params & params) {
372373
llama_log_set(llama_log_callback_logTee, nullptr);
373374
#endif // LOG_DISABLE_LOGS
374375

376+
// Handle running as llamafile executable
377+
if (params.model.empty()) {
378+
// Check if we're running as a llamafile with embedded model
379+
const char* prog = GetProgramExecutableName();
380+
struct llamafile* test = llamafile_open_gguf(prog, "rb");
381+
if (test) {
382+
llamafile_close(test);
383+
params.model = prog;
384+
LOG_TEE("Running as llamafile, using embedded model: %s\n", prog);
385+
}
386+
}
387+
375388
// Auto-detect mmproj if not provided
376-
if (params.mmproj.empty() && !params.model.empty()) {
389+
if (params.mmproj.empty()) {
377390
params.mmproj = auto_detect_mmproj(params.model);
378391
}
379392

0 commit comments

Comments
 (0)