Skip to content

Commit 78a8d90

Browse files
committed
Fix input processing
1 parent 90efb90 commit 78a8d90

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

common/toolcall/handler.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ std::shared_ptr<toolcall::handler> toolcall::create_handler(const toolcall::para
1515

1616
auto tools = params.tools();
1717
auto choice = params.choice();
18-
if (params.has_uri()) {
18+
if (params) {
19+
if (params.has_uri()) {
1920
#ifdef LLAMA_USE_CURL
20-
handler.reset(new toolcall::handler(std::make_unique<toolcall::mcp_impl>(tools, choice)));
21+
handler.reset(new toolcall::handler(std::make_unique<toolcall::mcp_impl>(tools, choice)));
2122
#endif
22-
} else {
23-
handler.reset(new toolcall::handler(std::make_unique<toolcall::loopback_impl>(tools, choice)));
23+
} else {
24+
handler.reset(new toolcall::handler(std::make_unique<toolcall::loopback_impl>(tools, choice)));
25+
}
2426
}
25-
2627
return handler;
2728
}
2829

@@ -65,7 +66,7 @@ toolcall::mcp_impl::mcp_impl(std::vector<std::string> argv, std::string tool_cho
6566

6667
std::string toolcall::mcp_impl::tool_list() {
6768
// Construct tools/list call and send to transport
68-
return json{};// TODO
69+
return "[]";// TODO
6970
}
7071

7172
toolcall::action toolcall::mcp_impl::call(const std::string & /*request*/, std::string & /*response*/) {

examples/main/main.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -277,19 +277,8 @@ int main(int argc, char ** argv) {
277277

278278
common_chat_templates_inputs cinputs;
279279
if (handler != nullptr) {
280-
auto choice = handler->tool_choice();
281-
if (choice == "auto") {
282-
cinputs.tool_choice = COMMON_CHAT_TOOL_CHOICE_AUTO;
283-
284-
} else if (choice == "required") {
285-
cinputs.tool_choice = COMMON_CHAT_TOOL_CHOICE_REQUIRED;
286-
287-
} else if (choice == "none") {
288-
cinputs.tool_choice = COMMON_CHAT_TOOL_CHOICE_NONE;
289-
}
290-
291-
// TODO
292-
//cinputs.tools = handler->tool_list();
280+
cinputs.tool_choice = common_chat_tool_choice_parse_oaicompat(handler->tool_choice());
281+
cinputs.tools = common_chat_tools_parse_oaicompat(handler->tool_list());
293282
}
294283

295284
common_chat_params cparams;

0 commit comments

Comments
 (0)