🔧 refactor(preview): remove default placeholder message from empty conversation preview

- Remove automatic insertion of "你好" placeholder message in preview payload
- Keep messages array empty when no user messages exist in conversation
- Only process image handling logic when user messages are present
- Ensure preview request body accurately reflects current conversation state

Previously, the preview panel would automatically inject a default "你好"
user message when the conversation was empty, which could be misleading.
This change ensures the preview payload shows exactly what would be sent
based on the current conversation state, improving accuracy and user
understanding of the actual API request structure.
This commit is contained in:
Apple\Apple
2025-06-03 01:25:21 +08:00
parent 5894e18f4f
commit 3269926283

View File

@@ -166,12 +166,8 @@ const Playground = () => {
// 默认预览逻辑
let messages = [...message];
// 如果没有用户消息,添加默认消息
if (messages.length === 0 || messages.every(msg => msg.role !== MESSAGE_ROLES.USER)) {
const validImageUrls = inputs.imageUrls ? inputs.imageUrls.filter(url => url.trim() !== '') : [];
const content = buildMessageContent('你好', validImageUrls, inputs.imageEnabled);
messages = [createMessage(MESSAGE_ROLES.USER, content)];
} else {
// 如果存在用户消息
if (!(messages.length === 0 || messages.every(msg => msg.role !== MESSAGE_ROLES.USER))) {
// 处理最后一个用户消息的图片
for (let i = messages.length - 1; i >= 0; i--) {
if (messages[i].role === MESSAGE_ROLES.USER) {