MCPcopy Create free account
hub / github.com/antirez/ds4 / openai_tool_start_param

Function openai_tool_start_param

ds4_server.c:5739–5763  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5737 for (;;) {
5738 p = skip_ascii_ws(p);
5739 if (strncmp(p, tool_start, strlen(tool_start)) != 0) break;
5740 p += strlen(tool_start);
5741
5742 const char *close = strstr(p, tool_end);
5743 if (!close) return false;
5744 const char *arg = strstr(p, arg_key_start);
5745 if (arg && arg > close) arg = NULL;
5746
5747 const char *name_start = p;
5748 const char *name_end = arg ? arg : close;
5749 trim_const_span(&name_start, &name_end);
5750 if (name_end <= name_start) return false;
5751 char *name = xstrndup(name_start, (size_t)(name_end - name_start));
5752 p = name_end;
5753
5754 buf args = {0};
5755 for (;;) {
5756 p = skip_ascii_ws(p);
5757 if (!strncmp(p, tool_end, strlen(tool_end))) {
5758 p += strlen(tool_end);
5759 break;
5760 }
5761 if (strncmp(p, arg_key_start, strlen(arg_key_start)) != 0) {
5762 free(name);
5763 buf_free(&args);
5764 return false;
5765 }
5766 p += strlen(arg_key_start);

Callers 1

Calls 4

dsml_attrFunction · 0.85
openai_tool_stream_failFunction · 0.85
xstrndupFunction · 0.70

Tested by

no test coverage detected