You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if ( json_data.contains("error") ) error_string =json_data["error"].get<std::string>();
306
308
}
307
-
catch(...) { if (ollama::use_exceptions) thrownewollama::exception("Unable to parse JSON string:"+this->json_string); valid = false; }
309
+
catch(...) { if (ollama::use_exceptions) throwollama::invalid_json_exception("Unable to parse JSON string:"+this->json_string); valid = false; }
308
310
}
309
311
310
312
response() {json_string = ""; valid = false;}
@@ -437,7 +439,7 @@ class Ollama
437
439
partial_responses->clear();
438
440
on_receive_token(response);
439
441
}
440
-
catch (...) { /* Partial response was received. Will do nothing and attempt to concatenate with the next response. */ }
442
+
catch (const ollama::invalid_json_exception& e) { /* Partial response was received. Will do nothing and attempt to concatenate with the next response. */ }
441
443
442
444
returntrue;
443
445
};
@@ -493,13 +495,23 @@ class Ollama
493
495
std::string request_string = request.dump();
494
496
if (ollama::log_requests) std::cout << request_string << std::endl;
495
497
496
-
auto stream_callback = [on_receive_token](constchar *data, size_t data_length)->bool{
if ( response.has_error() ) { if (ollama::use_exceptions) throwollama::exception("Ollama response returned error: "+response.get_error() ); }
512
+
on_receive_token(response);
513
+
}
514
+
catch (const ollama::invalid_json_exception& e) { /* Partial response was received. Will do nothing and attempt to concatenate with the next response. */ }
if ( json_data.contains("error") ) error_string =json_data["error"].get<std::string>();
35096
35098
}
35097
-
catch(...) { if (ollama::use_exceptions) throw new ollama::exception("Unable to parse JSON string:"+this->json_string); valid = false; }
35099
+
catch(...) { if (ollama::use_exceptions) throw ollama::invalid_json_exception("Unable to parse JSON string:"+this->json_string); valid = false; }
35098
35100
}
35099
35101
35100
35102
response() {json_string = ""; valid = false;}
@@ -35227,7 +35229,7 @@ class Ollama
35227
35229
partial_responses->clear();
35228
35230
on_receive_token(response);
35229
35231
}
35230
-
catch (...) { /* Partial response was received. Will do nothing and attempt to concatenate with the next response. */ }
35232
+
catch (const ollama::invalid_json_exception& e) { /* Partial response was received. Will do nothing and attempt to concatenate with the next response. */ }
35231
35233
35232
35234
return true;
35233
35235
};
@@ -35283,13 +35285,23 @@ class Ollama
35283
35285
std::string request_string = request.dump();
35284
35286
if (ollama::log_requests) std::cout << request_string << std::endl;
35285
35287
35286
-
auto stream_callback = [on_receive_token](const char *data, size_t data_length)->bool{
if ( response.has_error() ) { if (ollama::use_exceptions) throw ollama::exception("Ollama response returned error: "+response.get_error() ); }
35302
+
on_receive_token(response);
35303
+
}
35304
+
catch (const ollama::invalid_json_exception& e) { /* Partial response was received. Will do nothing and attempt to concatenate with the next response. */ }
0 commit comments