@@ -68,7 +68,6 @@ json clean_json_strings(const std::string& input_str) {
68
68
// json repair here
69
69
std::string fixed_str = jsonrepair (input_str);
70
70
json data = json::parse (fixed_str);
71
-
72
71
for (auto & [key, value] : data.items ()) {
73
72
if (value.is_string ()) {
74
73
std::string val = value.get <std::string>();
@@ -82,6 +81,7 @@ json clean_json_strings(const std::string& input_str) {
82
81
if (v.is_string ()) {
83
82
v = clean_command_string (v.get <std::string>());
84
83
}
84
+
85
85
}
86
86
}
87
87
}
@@ -97,7 +97,7 @@ json clean_json_strings(const std::string& input_str) {
97
97
98
98
std::vector<json> rubra_fc_json_tool_extractor (const std::string& output_str) {
99
99
std::vector<json> result;
100
- printf (" OUTPUT STR TO BE PARSED : %s" , output_str.c_str ());
100
+ printf (" OUTPUT STR TO BE PARSED : %s\n " , output_str.c_str ());
101
101
if (output_str.find (" endtoolcall" ) == std::string::npos) {
102
102
return result;
103
103
}
@@ -111,7 +111,8 @@ std::vector<json> rubra_fc_json_tool_extractor(const std::string& output_str) {
111
111
size_t pos = segment.find (" starttoolcall" );
112
112
if (pos != std::string::npos) {
113
113
// Extract substring after "toolcall"
114
- listOfStrToParse.push_back (segment.substr (pos + std::string (" starttoolcall" ).length ()));
114
+ std::string ss = segment.substr (pos + std::string (" starttoolcall" ).length ());
115
+ listOfStrToParse.push_back (ss);
115
116
}
116
117
start = end + std::string (" endtoolcall" ).length (); // Move past the "endtoolcall"
117
118
}
@@ -121,9 +122,10 @@ std::vector<json> rubra_fc_json_tool_extractor(const std::string& output_str) {
121
122
try {
122
123
for (const auto & line : listOfStrToParse) {
123
124
// json fc = json::parse(line);
125
+
124
126
json fc = clean_json_strings (line);
125
- if (fc[" arguments" ].is_string ()) {
126
- fc[" arguments" ] = json::parse ( fc[" arguments" ].get <std::string>() );
127
+ if (! fc[" arguments" ].is_string ()) {
128
+ fc[" arguments" ] = fc[" arguments" ].dump ( );
127
129
}
128
130
if (!fc.is_null ()) {
129
131
function_call_json.push_back (fc);
0 commit comments