diff --git a/src/toOpenAIMessages.ts b/src/toOpenAIMessages.ts index e148363..7d61456 100644 --- a/src/toOpenAIMessages.ts +++ b/src/toOpenAIMessages.ts @@ -40,12 +40,12 @@ function formatName(name: string): string { return FoldToAscii.foldReplacing(name) // White spaces are not allowed .replace(" ", "_") + // replace characters that are not accepted by api with '_' + .replace(/[^a-zA-Z0-9_-]/g, "_") // remove trailing '-_' characters .replace(/^[-_]+|[-_]+$/g, "") // remove duplicated '-_' characters - .replace(/([-_])*/g, "") - // replace characters that are not accepted by api with '?' - .replace(/[^a-zA-Z0-9_-]/g, "?"); + .replace(/([-_])*/g, "$1"); } /**