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

Function string_diff

smallthinker/common/chat.cpp:29–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27}
28
29static std::string string_diff(const std::string & last, const std::string & current) {
30 if (last.empty()) {
31 return current;
32 }
33 if (!string_starts_with(current, last)) {
34 if (string_starts_with(last, current)) {
35 // This happens if the last generation ended on a partial stop word (not erased),
36 // and the current ended on a stop word (erased).
37 return "";
38 }
39 throw std::runtime_error("Invalid diff: '" + last + "' not found at start of '" + current + "'");
40 }
41 return current.substr(last.size());
42}
43
44static bool has_content_or_tool_calls(const common_chat_msg & msg) {
45 return !msg.content.empty() || !msg.tool_calls.empty();

Callers 1

compute_diffsMethod · 0.85

Calls 4

substrMethod · 0.80
string_starts_withFunction · 0.70
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected