Only add name to prompts when conforming to oai api standards
This commit is contained in:
parent
670119e143
commit
0660016a10
|
@ -546,11 +546,24 @@ PromptManagerModule.prototype.preparePrompt = function (prompt, original = null)
|
||||||
else preparedPrompt.content = substituteParams(prompt.content);
|
else preparedPrompt.content = substituteParams(prompt.content);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prompt.name) preparedPrompt.name = prompt.name;
|
if (prompt.name && this.isValidName(prompt.name)) preparedPrompt.name = prompt.name;
|
||||||
|
|
||||||
return preparedPrompt;
|
return preparedPrompt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a given name is accepted by OpenAi API
|
||||||
|
* @link https://platform.openai.com/docs/api-reference/chat/create
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
PromptManagerModule.prototype.isValidName = function(name) {
|
||||||
|
const regex = /^[a-zA-Z0-9_]{1,64}$/;
|
||||||
|
|
||||||
|
return regex.test(name);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a given prompt into the edit form fields.
|
* Loads a given prompt into the edit form fields.
|
||||||
* @param {Object} prompt - Prompt object with properties 'name', 'role', 'content', and 'system_prompt'
|
* @param {Object} prompt - Prompt object with properties 'name', 'role', 'content', and 'system_prompt'
|
||||||
|
|
Loading…
Reference in New Issue