Skip to content

Commit 9db9686

Browse files
committed
Remove toolcall dependency from common
1 parent a097b4f commit 9db9686

File tree

5 files changed

+19
-16
lines changed

5 files changed

+19
-16
lines changed

common/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,3 @@ endif ()
139139
target_include_directories(${TARGET} PUBLIC .)
140140
target_compile_features (${TARGET} PUBLIC cxx_std_17)
141141
target_link_libraries (${TARGET} PRIVATE ${LLAMA_COMMON_EXTRA_LIBS} PUBLIC llama Threads::Threads)
142-
143-
if (LLAMA_TOOLCALL)
144-
target_link_libraries(${TARGET} PUBLIC toolcall)
145-
endif()

common/arg.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2143,24 +2143,22 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
21432143
}
21442144
).set_examples({LLAMA_EXAMPLE_MAIN, LLAMA_EXAMPLE_SERVER}).set_env("LLAMA_ARG_CHAT_TEMPLATE_FILE"));
21452145

2146-
#ifdef LLAMA_USE_TOOLCALL
21472146
add_opt(common_arg(
21482147
{"--tools"}, "JINJA_TOOLS",
21492148
"set to URI of a Model Context Protocol server, or "
21502149
"a JSON array containing tool definitions (requires --jinja)",
21512150
[](common_params &params, const std::string & value) {
2152-
params.jinja_tools.tools(value);
2151+
params.toolcall.tools = value;
21532152

21542153
}).set_examples({LLAMA_EXAMPLE_MAIN}));
21552154

21562155
add_opt(common_arg(
21572156
{"--tool-choice"}, "JINJA_TOOL_CHOICE",
21582157
"set to \"auto\", \"required\", or \"none\" (default: \"auto\")",
21592158
[](common_params &params, const std::string & value) {
2160-
params.jinja_tools.choice(value);
2159+
params.toolcall.choice = value;
21612160

21622161
}).set_examples({LLAMA_EXAMPLE_MAIN}));
2163-
#endif
21642162

21652163
add_opt(common_arg(
21662164
{"-sps", "--slot-prompt-similarity"}, "SIMILARITY",

common/common.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44

55
#include "llama-cpp.h"
66

7-
#ifdef LLAMA_USE_TOOLCALL
8-
# include "toolcall-params.h"
9-
#endif
10-
117
#include <set>
128
#include <string>
139
#include <vector>
@@ -212,6 +208,11 @@ enum common_reasoning_format {
212208
COMMON_REASONING_FORMAT_DEEPSEEK, // Extract thinking tag contents and return as `message.reasoning_content`
213209
};
214210

211+
struct common_toolcall_params {
212+
std::string tools = "";
213+
std::string choice = "auto";
214+
};
215+
215216
struct common_params {
216217
int32_t n_predict = -1; // new tokens to predict
217218
int32_t n_ctx = 4096; // context size
@@ -358,9 +359,7 @@ struct common_params {
358359
bool use_jinja = false; // NOLINT
359360
bool enable_chat_template = true;
360361

361-
#ifdef LLAMA_USE_TOOLCALL
362-
toolcall::params jinja_tools;
363-
#endif
362+
struct common_toolcall_params toolcall;
364363

365364
common_reasoning_format reasoning_format = COMMON_REASONING_FORMAT_DEEPSEEK;
366365

examples/main/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,9 @@ set(TARGET llama-cli)
22
add_executable(${TARGET} main.cpp)
33
install(TARGETS ${TARGET} RUNTIME)
44
target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT})
5+
6+
if (LLAMA_TOOLCALL)
7+
target_link_libraries(${TARGET} PRIVATE toolcall)
8+
endif()
9+
510
target_compile_features(${TARGET} PRIVATE cxx_std_17)

examples/main/main.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ int main(int argc, char ** argv) {
155155

156156
auto & sparams = params.sampling;
157157

158+
#ifdef LLAMA_USE_TOOLCALL
159+
// Ensure parameters are validated before the model loads
160+
toolcall::params tc_params(params.toolcall.tools, params.toolcall.choice);
161+
#endif
162+
158163
// save choice to use color for later
159164
// (note for later: this is a slightly awkward choice)
160165
console::init(params.simple_io, params.use_color);
@@ -323,7 +328,7 @@ int main(int argc, char ** argv) {
323328
std::vector<llama_token> embd_inp;
324329

325330
#ifdef LLAMA_USE_TOOLCALL
326-
auto tc_handler = toolcall::create_handler(params.jinja_tools);
331+
auto tc_handler = toolcall::create_handler(tc_params);
327332
if (tc_handler) {
328333
tc_handler->initialize();
329334
}

0 commit comments

Comments
 (0)