MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / try_consume_json

Method try_consume_json

smallthinker/common/chat-parser.cpp:224–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222}
223
224std::optional<common_json> common_chat_msg_parser::try_consume_json() {
225 auto it = input_.cbegin() + pos_;
226 const auto end = input_.cend();
227 common_json result;
228 if (!common_json_parse(it, end, healing_marker_, result)) {
229 return std::nullopt;
230 }
231 pos_ = std::distance(input_.cbegin(), it);
232 if (result.healing_marker.marker.empty()) {
233 // No healing marker, just return the parsed json
234 return result;
235 }
236 if (!is_partial()) {
237 throw common_chat_msg_partial_exception("JSON");
238 }
239 return result;
240}
241
242common_json common_chat_msg_parser::consume_json() {
243 if (auto result = try_consume_json()) {

Callers

nothing calls this directly

Calls 3

common_json_parseFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected