Skip to content

Commit 8bdb9fd

Browse files
committed
Opt class for positional argument handling
Added support for positional arguments `MODEL` and `PROMPT`. Added model path resolution, just `file://` for now. Added functionality to download via strings like: llama-run llama3 llama-run ollama://granite-code llama-run ollama://granite-code:8b llama-run hf://QuantFactory/SmolLM-135M-GGUF/SmolLM-135M.Q2_K.gguf llama-run huggingface://bartowski/SmolLM-1.7B-Instruct-v0.2-GGUF/SmolLM-1.7B-Instruct-v0.2-IQ3_M.gguf llama-run https://example.com/some-file1.gguf llama-run some-file2.gguf llama-run file://some-file3.gguf Signed-off-by: Eric Curtin <[email protected]>
1 parent 26a8406 commit 8bdb9fd

File tree

4 files changed

+422
-162
lines changed

4 files changed

+422
-162
lines changed

common/common.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,12 +1108,6 @@ struct ggml_threadpool_params ggml_threadpool_params_from_cpu_params(const cpu_p
11081108
#define CURL_MAX_RETRY 3
11091109
#define CURL_RETRY_DELAY_SECONDS 2
11101110

1111-
1112-
static bool starts_with(const std::string & str, const std::string & prefix) {
1113-
// While we wait for C++20's std::string::starts_with...
1114-
return str.rfind(prefix, 0) == 0;
1115-
}
1116-
11171111
static bool curl_perform_with_retry(const std::string& url, CURL* curl, int max_attempts, int retry_delay_seconds) {
11181112
int remaining_attempts = max_attempts;
11191113

common/common.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ using llama_tokens = std::vector<llama_token>;
3737

3838
// build info
3939
extern int LLAMA_BUILD_NUMBER;
40-
extern char const * LLAMA_COMMIT;
41-
extern char const * LLAMA_COMPILER;
42-
extern char const * LLAMA_BUILD_TARGET;
40+
extern const char * LLAMA_COMMIT;
41+
extern const char * LLAMA_COMPILER;
42+
extern const char * LLAMA_BUILD_TARGET;
4343

4444
struct common_control_vector_load_info;
4545

@@ -437,6 +437,11 @@ std::vector<std::string> string_split<std::string>(const std::string & input, ch
437437
return parts;
438438
}
439439

440+
static bool starts_with(const std::string & str,
441+
const std::string & prefix) { // While we wait for C++20's std::string::starts_with...
442+
return str.rfind(prefix, 0) == 0;
443+
}
444+
440445
bool string_parse_kv_override(const char * data, std::vector<llama_model_kv_override> & overrides);
441446
void string_process_escapes(std::string & input);
442447

examples/run/CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
set(TARGET llama-run)
22
add_executable(${TARGET} run.cpp)
33
install(TARGETS ${TARGET} RUNTIME)
4-
target_link_libraries(${TARGET} PRIVATE llama ${CMAKE_THREAD_LIBS_INIT})
4+
5+
# Use curl to download model url
6+
if (LLAMA_CURL)
7+
find_package(CURL REQUIRED)
8+
add_definitions(-DLLAMA_USE_CURL)
9+
include_directories(${CURL_INCLUDE_DIRS})
10+
find_library(CURL_LIBRARY curl REQUIRED)
11+
set(LLAMA_COMMON_EXTRA_LIBS ${LLAMA_COMMON_EXTRA_LIBS} ${CURL_LIBRARY})
12+
endif ()
13+
14+
target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT})
15+
target_include_directories(${TARGET} PUBLIC ../../common)
516
target_compile_features(${TARGET} PRIVATE cxx_std_17)

0 commit comments

Comments
 (0)