Add human-led conversation learning loop
This commit is contained in:
1 parent
bc42c55555
commit
687abab82b
52 files changed
+2112
-53
No files matched your search
@@ -0,0 +1,16 @@
|
||||
const URL = /https?:\/\/\S+/gi;
|
||||
const EMAIL = /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi;
|
||||
const PHONE = /(?<!\w)(?:\+?\d[\d ()-]{7,}\d)(?!\w)/g;
|
||||
const USERNAME = /(?:^|\s)(?:u\/|@)[A-Za-z0-9_-]{2,}/g;
|
||||
|
||||
/** Removes direct identifiers before durable example storage or prompt use. */
|
||||
export function redactLearningText(value: string, maxLength = 500): string {
|
||||
return value
|
||||
.replace(URL, '[url]')
|
||||
.replace(EMAIL, '[email]')
|
||||
.replace(PHONE, '[phone]')
|
||||
.replace(USERNAME, (match) => `${match[0] === ' ' ? ' ' : ''}[username]`)
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim()
|
||||
.slice(0, maxLength);
|
||||
}
|
||||
Reference in new issue
Block a user