mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 01:10:14 +01:00
fix(formatMessages): Conform Name Property to OpenAI Expected Regex (#1076)
* fix(formatMessages): conform name property to OpenAI expected regex * fix(ci): prior test was expecting non-sanitized name input
This commit is contained in:
parent
fd99bac121
commit
abbc57a49a
3 changed files with 41 additions and 1 deletions
|
|
@ -44,6 +44,16 @@ const formatMessage = ({ message, userName, assistantName, langChain = false })
|
|||
formattedMessage.name = assistantName;
|
||||
}
|
||||
|
||||
if (formattedMessage.name) {
|
||||
// Conform to API regex: ^[a-zA-Z0-9_-]{1,64}$
|
||||
// https://community.openai.com/t/the-format-of-the-name-field-in-the-documentation-is-incorrect/175684/2
|
||||
formattedMessage.name = formattedMessage.name.replace(/[^a-zA-Z0-9_-]/g, '_');
|
||||
|
||||
if (formattedMessage.name.length > 64) {
|
||||
formattedMessage.name = formattedMessage.name.substring(0, 64);
|
||||
}
|
||||
}
|
||||
|
||||
if (!langChain) {
|
||||
return formattedMessage;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue