mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-19 03:42:23 -06:00
correction in message formatting when generated by AI as markdown in typebot
This commit is contained in:
@@ -519,18 +519,32 @@ export class TypebotService {
|
||||
text += element.text;
|
||||
}
|
||||
|
||||
if (
|
||||
element.children &&
|
||||
(element.type === 'p' ||
|
||||
element.type === 'a' ||
|
||||
element.type === 'inline-variable' ||
|
||||
element.type === 'variable')
|
||||
) {
|
||||
if (element.children && element.type !== 'a') {
|
||||
for (const child of element.children) {
|
||||
text += applyFormatting(child);
|
||||
}
|
||||
}
|
||||
|
||||
if (element.type === 'p') {
|
||||
text = text.trim() + '\n';
|
||||
}
|
||||
|
||||
if (element.type === 'ol') {
|
||||
text =
|
||||
'\n' +
|
||||
text
|
||||
.split('\n')
|
||||
.map((line, index) => (line ? `${index + 1}. ${line}` : ''))
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
if (element.type === 'li') {
|
||||
text = text
|
||||
.split('\n')
|
||||
.map((line) => (line ? ` ${line}` : ''))
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
let formats = '';
|
||||
|
||||
if (element.bold) {
|
||||
@@ -558,6 +572,7 @@ export class TypebotService {
|
||||
for (const message of messages) {
|
||||
if (message.type === 'text') {
|
||||
let formattedText = '';
|
||||
console.log('message.content', message.content);
|
||||
|
||||
for (const richText of message.content.richText) {
|
||||
for (const element of richText.children) {
|
||||
|
||||
Reference in New Issue
Block a user