mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-16 12:12:55 -06:00
correction in message formatting when generated by AI as markdown in typebot
This commit is contained in:
parent
f0d40eea15
commit
e4b6f4ff0d
@ -5,6 +5,9 @@
|
|||||||
* Now in the manager, when logging in with the client's apikey, the listing only shows the instance corresponding to the provided apikey (only with MongoDB)
|
* Now in the manager, when logging in with the client's apikey, the listing only shows the instance corresponding to the provided apikey (only with MongoDB)
|
||||||
* New global mode for rabbitmq events
|
* New global mode for rabbitmq events
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
* Correction in message formatting when generated by AI as markdown in typebot
|
||||||
|
|
||||||
# 1.7.5 (2024-05-21 08:50)
|
# 1.7.5 (2024-05-21 08:50)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
@ -519,18 +519,32 @@ export class TypebotService {
|
|||||||
text += element.text;
|
text += element.text;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (element.children && element.type !== 'a') {
|
||||||
element.children &&
|
|
||||||
(element.type === 'p' ||
|
|
||||||
element.type === 'a' ||
|
|
||||||
element.type === 'inline-variable' ||
|
|
||||||
element.type === 'variable')
|
|
||||||
) {
|
|
||||||
for (const child of element.children) {
|
for (const child of element.children) {
|
||||||
text += applyFormatting(child);
|
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 = '';
|
let formats = '';
|
||||||
|
|
||||||
if (element.bold) {
|
if (element.bold) {
|
||||||
@ -558,6 +572,7 @@ export class TypebotService {
|
|||||||
for (const message of messages) {
|
for (const message of messages) {
|
||||||
if (message.type === 'text') {
|
if (message.type === 'text') {
|
||||||
let formattedText = '';
|
let formattedText = '';
|
||||||
|
console.log('message.content', message.content);
|
||||||
|
|
||||||
for (const richText of message.content.richText) {
|
for (const richText of message.content.richText) {
|
||||||
for (const element of richText.children) {
|
for (const element of richText.children) {
|
||||||
|
Loading…
Reference in New Issue
Block a user