Small AI response header striping fix.
This commit is contained in:
parent
c4d9011bdb
commit
319d49d439
1 changed files with 16 additions and 1 deletions
17
zynk.c
17
zynk.c
|
|
@ -29,7 +29,7 @@ int asprintf(char **, const char *, ...);
|
|||
|
||||
/* ---- constants ---- */
|
||||
|
||||
#define VERSION "0.34.3"
|
||||
#define VERSION "0.34.4"
|
||||
#define DEFAULT_SERVER "irc.libera.chat"
|
||||
#define OPENCODE_BIN "/usr/bin/opencode"
|
||||
#define CLR_RESET "\033[0m"
|
||||
|
|
@ -1314,6 +1314,20 @@ static void strip_formatting(char *s) {
|
|||
*dst = 0;
|
||||
}
|
||||
|
||||
static void strip_opencode_header(char *s) {
|
||||
if (!s || s[0] != '>' || s[1] != ' ') return;
|
||||
char *sep = strstr(s, " \xc2\xb7 ");
|
||||
if (!sep) sep = strstr(s, " · ");
|
||||
if (!sep) return;
|
||||
char *nl = strchr(s, '\n');
|
||||
if (nl) {
|
||||
nl++;
|
||||
memmove(s, nl, strlen(nl) + 1);
|
||||
} else {
|
||||
s[0] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* has_crlf - Check if a string contains CR or LF characters.
|
||||
*
|
||||
|
|
@ -1658,6 +1672,7 @@ static void ai_child_task(Session *s, long long id, const char *agent) {
|
|||
} else if (olen == 0) {
|
||||
ai_set_answer(id, "AI returned an empty response");
|
||||
} else {
|
||||
strip_opencode_header(out);
|
||||
strip_formatting(out);
|
||||
strip_ai_phrases(out);
|
||||
ai_set_answer(id, out);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue