@salesforce/agents
Version:
Client side APIs for working with Salesforce agents
61 lines • 1.74 kB
JavaScript
;
/*
* Copyright (c) 2025, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.decodeHtmlEntities = exports.metric = void 0;
exports.metric = [
'completeness',
'coherence',
'conciseness',
'output_latency_milliseconds',
'instruction_following',
'factuality',
];
/**
* Clean a string by replacing HTML entities with their respective characters.
*
* @param str - The string to clean.
* @returns The cleaned string with all HTML entities replaced with their respective characters.
*/
const decodeHtmlEntities = (str = '') => {
const entities = {
'"': '"',
'\': '\\',
''': "'",
'&': '&',
'<': '<',
'>': '>',
''': "'",
'°': '°',
' ': ' ',
'–': '–',
'—': '—',
'’': '’',
'‘': '‘',
'“': '“',
'”': '”',
'…': '…',
'™': '™',
'©': '©',
'®': '®',
'€': '€',
'£': '£',
'¥': '¥',
'¢': '¢',
'×': '×',
'÷': '÷',
'±': '±',
'µ': 'µ',
'¶': '¶',
'§': '§',
'•': '•',
'·': '·',
};
return str.replace(/&[a-zA-Z0-9#]+;/g, (entity) => entities[entity] || entity);
};
exports.decodeHtmlEntities = decodeHtmlEntities;
//# sourceMappingURL=utils.js.map