feat: add unified generation entrypoint
This commit is contained in:
@@ -134,33 +134,31 @@ async function generateStory() {
|
||||
}
|
||||
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
|
||||
try {
|
||||
const payload: Record<string, unknown> = {
|
||||
type: inputType.value,
|
||||
data: inputData.value,
|
||||
education_theme: educationTheme.value || undefined,
|
||||
}
|
||||
if (selectedProfileId.value) payload.child_profile_id = selectedProfileId.value
|
||||
if (selectedUniverseId.value) payload.universe_id = selectedUniverseId.value
|
||||
|
||||
if (outputMode.value === 'storybook') {
|
||||
const response = await api.post<any>('/api/storybook/generate', {
|
||||
keywords: inputData.value,
|
||||
education_theme: educationTheme.value || undefined,
|
||||
generate_images: true,
|
||||
page_count: 6,
|
||||
child_profile_id: selectedProfileId.value || undefined,
|
||||
universe_id: selectedUniverseId.value || undefined
|
||||
})
|
||||
|
||||
error.value = ''
|
||||
|
||||
try {
|
||||
const requestedOutputMode =
|
||||
inputType.value === 'full_story' ? 'story' : outputMode.value === 'storybook' ? 'storybook' : 'story'
|
||||
const payload: Record<string, unknown> = {
|
||||
output_mode: requestedOutputMode,
|
||||
type: inputType.value,
|
||||
data: inputData.value,
|
||||
education_theme: educationTheme.value || undefined,
|
||||
generate_images: true,
|
||||
page_count: 6,
|
||||
}
|
||||
if (selectedProfileId.value) payload.child_profile_id = selectedProfileId.value
|
||||
if (selectedUniverseId.value) payload.universe_id = selectedUniverseId.value
|
||||
|
||||
if (requestedOutputMode === 'storybook') {
|
||||
const response = await api.post<any>('/api/generations', payload)
|
||||
|
||||
storybookStore.setStorybook(response)
|
||||
close()
|
||||
const storybookPath = response.id ? `/storybook/view/${response.id}` : '/storybook/view'
|
||||
router.push(storybookPath)
|
||||
} else {
|
||||
const result = await api.post<any>('/api/stories/generate/full', payload)
|
||||
const result = await api.post<any>('/api/generations', payload)
|
||||
close()
|
||||
router.push(`/story/${result.id}`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user