chore: update playground payload format

This commit is contained in:
jialin
2024-10-24 22:40:38 +08:00
parent 6974ac8e14
commit 8afaf1a60e
7 changed files with 143 additions and 89 deletions
+27
View File
@@ -13,3 +13,30 @@ export const playGroundRoles = [
label: 'playground.assitant'
}
];
export const formatMessageParams = (messageList: any[]) => {
const result: any[] = [];
messageList.forEach((item) => {
const { role, content, title, imgs, uid } = item;
content?.forEach((contentItem: any) => {
if (contentItem.type === 'text') {
result.push({
role,
content: contentItem.text
});
}
if (contentItem.type === 'image_url') {
result.push({
role,
content: [
{
...contentItem
}
]
});
}
});
});
return result;
};