fix: increase max length for user profile summary and sanitize function
Deploy to VPS / deploy (push) Successful in 2m19s
Deploy to VPS / deploy (push) Successful in 2m19s
This commit is contained in:
@@ -814,7 +814,7 @@ export async function runSimpleTextFallback(
|
|||||||
try {
|
try {
|
||||||
const profile = await getUserProfile(message.user_id);
|
const profile = await getUserProfile(message.user_id);
|
||||||
if (profile?.profile_summary) {
|
if (profile?.profile_summary) {
|
||||||
userProfileCtx = `\n\nProfil pengirim pesan:\n${sanitizeAiContent(profile.profile_summary, 2000, false)}\n`;
|
userProfileCtx = `\n\nProfil pengirim pesan:\n${sanitizeAiContent(profile.profile_summary, 3000, false)}\n`;
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
/* non-fatal */
|
/* non-fatal */
|
||||||
|
|||||||
@@ -774,11 +774,11 @@ CRITICAL:
|
|||||||
* - Escapes XML special chars (< → <, > → >)
|
* - Escapes XML special chars (< → <, > → >)
|
||||||
* - Strips markdown code-block fences that might confuse the LLM
|
* - Strips markdown code-block fences that might confuse the LLM
|
||||||
* - Wraps in CDATA section so the content is treated as data, not markup
|
* - Wraps in CDATA section so the content is treated as data, not markup
|
||||||
* - Caps at `maxLen` chars (default 2000)
|
* - Caps at `maxLen` chars (default 3000)
|
||||||
*/
|
*/
|
||||||
export function sanitizeAiContent(
|
export function sanitizeAiContent(
|
||||||
raw: string,
|
raw: string,
|
||||||
maxLen = 2000,
|
maxLen = 3000,
|
||||||
wrapInCdata = true,
|
wrapInCdata = true,
|
||||||
): string {
|
): string {
|
||||||
// 1. Strip markdown code fences (``` … ```) — prevents the AI summary
|
// 1. Strip markdown code fences (``` … ```) — prevents the AI summary
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ atau konten SARA, itu akan SANGAT tidak sesuai dengan karakternya dan patut dicu
|
|||||||
try {
|
try {
|
||||||
const completion = await llmChat({
|
const completion = await llmChat({
|
||||||
messages: [{ role: "user", content: prompt }],
|
messages: [{ role: "user", content: prompt }],
|
||||||
max_tokens: 500,
|
max_tokens: 2000,
|
||||||
temperature: 0.7, // Higher temp for summarization
|
temperature: 0.7, // Higher temp for summarization
|
||||||
retries: 2,
|
retries: 2,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user