char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
acecd5603
char/aliceai-t5-moe
1#include "parsers.h" 2 3#include "log.h" 4 5void foreach_function (const json & tools ,const std::function < void (const json & )> & fn ) { 6for (const auto & tool :tools ) { 7if (!tool .contains ("type" )|| tool .at ("type" )!= "function" || !tool .contains ("function" )) { 8LOG_INF ("Skipping tool without function: %s" ,tool .dump (2 ).c_str ()); 9continue ; 10 } 11fn (tool ); 12 } 13} 14 15void foreach_parameter (const json & function ,const std::function < void (const common_chat_schema_property & ,const common_chat_schema_document_ptr & )> & fn ) { 16auto params = common_chat_tool_parameters (function ); 17auto doc = std::make_shared < const common_chat_schema_document > (common_chat_schema_from_json (params )); 18const auto * object = dynamic_cast < const common_chat_schema_object *> (doc -> root .get ()); 19if (!object ) { 20return ; 21 } 22for (const auto & prop :object -> properties ) { 23fn (prop ,doc ); 24 } 25}