mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-24 03:06:12 +01:00
🎯 feat: Enhance Title Parameter Parsing with new Anthropic Format
This commit is contained in:
parent
0c2a583df8
commit
766643ea1c
2 changed files with 89 additions and 2 deletions
|
|
@ -99,10 +99,24 @@ ONLY include the generated translation without quotations, nor its related key</
|
|||
* @returns {string} The parsed parameter's value or a default value if not found.
|
||||
*/
|
||||
function parseParamFromPrompt(prompt, paramName) {
|
||||
const paramRegex = new RegExp(`<${paramName}>([\\s\\S]+?)</${paramName}>`);
|
||||
// Handle null/undefined prompt
|
||||
if (!prompt) {
|
||||
return `No ${paramName} provided`;
|
||||
}
|
||||
|
||||
// Try original format first: <title>value</title>
|
||||
const simpleRegex = new RegExp(`<${paramName}>(.*?)</${paramName}>`, 's');
|
||||
const simpleMatch = prompt.match(simpleRegex);
|
||||
|
||||
if (simpleMatch) {
|
||||
return simpleMatch[1].trim();
|
||||
}
|
||||
|
||||
// Try parameter format: <parameter name="title">value</parameter>
|
||||
const paramRegex = new RegExp(`<parameter name="${paramName}">(.*?)</parameter>`, 's');
|
||||
const paramMatch = prompt.match(paramRegex);
|
||||
|
||||
if (paramMatch && paramMatch[1]) {
|
||||
if (paramMatch) {
|
||||
return paramMatch[1].trim();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue