Currently when a model generates output which looks like a tool call,
but is invalid an exception is thrown and not handled, causing the cli
or llama-server to bail. Instead, handle the chat parser exception and
simply return the generated text in such cases.
Signed-off-by: Piotr Stankiewicz <redacted>
// LOG_DBG("Tool call arguments:\n\traw: %s\n\tresult: %s\n", arguments.c_str(), tool_call.arguments.c_str());
result_.tool_calls.emplace_back(tool_call);
+
return true;
}
bool common_chat_msg_parser::add_tool_call(const json & tool_call) {
/* .is_partial = */ found_healing_marker,
};
}
+
+void common_chat_msg_parser::clear_tools() {
+ result_.tool_calls.clear();
+}
const std::vector<std::vector<std::string>> & args_paths = {},
const std::vector<std::vector<std::string>> & content_paths = {}
);
+
+ void clear_tools();
};
} catch (const common_chat_msg_partial_exception & ex) {
LOG_DBG("Partial parse: %s\n", ex.what());
if (!is_partial) {
- throw std::runtime_error(ex.what());
+ builder.clear_tools();
+ builder.move_to(0);
+ common_chat_parse_content_only(builder);
}
}
auto msg = builder.result();