MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / string_diff

Function string_diff

subprojects/llama.cpp/common/chat.cpp:37–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

compute_diffsMethod · 0.85

Calls 3

string_starts_withFunction · 0.70
emptyMethod · 0.65
sizeMethod · 0.65

Tested by

no test coverage detected