feat: add avatar chat and knowledge workflow
This commit is contained in:
46
digital-avatar-app/src/utils/avatar-page-data.js
Normal file
46
digital-avatar-app/src/utils/avatar-page-data.js
Normal file
@@ -0,0 +1,46 @@
|
||||
export function unwrapListData(value) {
|
||||
if (Array.isArray(value)) return value
|
||||
if (Array.isArray(value?.data)) return value.data
|
||||
return []
|
||||
}
|
||||
|
||||
export function pickAvatarId(currentAvatarId, avatars) {
|
||||
return currentAvatarId || avatars?.[0]?.id || null
|
||||
}
|
||||
|
||||
export function normalizeAvatarEditForm(avatar = {}) {
|
||||
const config = avatar.config || {}
|
||||
return {
|
||||
name: avatar.name || '',
|
||||
displayName: avatar.displayName || '',
|
||||
description: avatar.description || '',
|
||||
status: avatar.status || 'active',
|
||||
photoUrl: avatar.photoUrl || '',
|
||||
replyStyle: config.replyStyle || 'professional',
|
||||
creativity: Number.isFinite(config.creativity) ? config.creativity : 50,
|
||||
rigor: Number.isFinite(config.rigor) ? config.rigor : 50,
|
||||
humor: Number.isFinite(config.humor) ? config.humor : 30,
|
||||
responseLength: config.responseLength || 'medium',
|
||||
systemPrompt: config.systemPrompt || '',
|
||||
autoReply: config.autoReply !== false,
|
||||
}
|
||||
}
|
||||
|
||||
export function buildAvatarUpdatePayload(form) {
|
||||
return {
|
||||
name: form.name.trim(),
|
||||
displayName: form.displayName.trim() || form.name.trim(),
|
||||
description: form.description.trim(),
|
||||
status: form.status,
|
||||
photoUrl: form.photoUrl.trim(),
|
||||
config: {
|
||||
replyStyle: form.replyStyle,
|
||||
creativity: Number(form.creativity),
|
||||
rigor: Number(form.rigor),
|
||||
humor: Number(form.humor),
|
||||
responseLength: form.responseLength,
|
||||
systemPrompt: form.systemPrompt.trim(),
|
||||
autoReply: !!form.autoReply,
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user