ref: 09836b88b3d499cc89fa7d22e8ff4bf4b5913cac
dir: /tools/summarize.tool/
static char*
summarize(OToolcall tc, void*)
{
JSON *j, *jc;
char *content;
j = jsonparse(tc.arguments);
jc = jsonbyname(j, "content");
if (!jc)
goto Err;
content = jsonstr(jc);
if (!content)
goto Err;
resetprompts();
if (sysprompt)
addstrprompt(&req, "system", "%s", sysprompt);
addstrprompt(&req, "user", "Summarize the previous conversation");
addstrprompt(&req, "assistant", "%s", content);
fprint(2, "summary: %s\n", content);
reprompt = 1;
return nil;
Err:
jsonfree(j);
return strdup("no content");
}
static char *sumdesc = "Save a summary of the whole conversation to compress the context.";
static char *sumargs = ""
%%json
{
"type": "object",
"properties": {
"content": { "type": "string" }
},
"required": [ "content" ]
}
%/json
;