feat: 形态图库接入模型配置与异步回执
This commit is contained in:
1 parent
3014fa1ae6
commit
5e2221ea88
1 file changed
+19
-2
@@ -4,6 +4,7 @@ import { ApiError } from '../../lib/http'
|
|||||||
import { useProjectContext } from '../projects/context'
|
import { useProjectContext } from '../projects/context'
|
||||||
import { getOperation, runOperation } from '../workflows/operations'
|
import { getOperation, runOperation } from '../workflows/operations'
|
||||||
import { workflowCheckpoints } from '../workflows/selectors'
|
import { workflowCheckpoints } from '../workflows/selectors'
|
||||||
|
import { generationConfigApi } from '../generation-config/api'
|
||||||
import { subjectImagesApi } from './api'
|
import { subjectImagesApi } from './api'
|
||||||
import { getImageSession, hasRunningImages } from './model'
|
import { getImageSession, hasRunningImages } from './model'
|
||||||
import type { GenerateFormImageInput, SubjectModule } from './types'
|
import type { GenerateFormImageInput, SubjectModule } from './types'
|
||||||
@@ -18,6 +19,16 @@ export function useSubjectImages() {
|
|||||||
const promptConcurrency = ref(3)
|
const promptConcurrency = ref(3)
|
||||||
const promptForce = ref(false)
|
const promptForce = ref(false)
|
||||||
const batchModule = ref<'all' | SubjectModule>('all')
|
const batchModule = ref<'all' | SubjectModule>('all')
|
||||||
|
const generationModelsQuery = usePolling(
|
||||||
|
id,
|
||||||
|
async (_id, signal) => generationConfigApi.catalog(signal),
|
||||||
|
false
|
||||||
|
)
|
||||||
|
const profileQuery = usePolling(
|
||||||
|
id,
|
||||||
|
async (projectId, signal) => ({ profile: await generationConfigApi.profile(projectId, signal) }),
|
||||||
|
false
|
||||||
|
)
|
||||||
const query = usePolling(
|
const query = usePolling(
|
||||||
id,
|
id,
|
||||||
async (projectId, signal) => {
|
async (projectId, signal) => {
|
||||||
@@ -59,6 +70,10 @@ export function useSubjectImages() {
|
|||||||
!!context.error.value ||
|
!!context.error.value ||
|
||||||
!!query.error.value ||
|
!!query.error.value ||
|
||||||
query.data.value === null ||
|
query.data.value === null ||
|
||||||
|
!!generationModelsQuery.error.value ||
|
||||||
|
!generationModelsQuery.data.value ||
|
||||||
|
!!profileQuery.error.value ||
|
||||||
|
!profileQuery.data.value?.profile ||
|
||||||
running.value ||
|
running.value ||
|
||||||
breakdownRunning.value ||
|
breakdownRunning.value ||
|
||||||
context.project.value?.status !== 'completed'
|
context.project.value?.status !== 'completed'
|
||||||
@@ -116,8 +131,8 @@ export function useSubjectImages() {
|
|||||||
const projectId = id.value
|
const projectId = id.value
|
||||||
await runOperation(projectId, `生成 ${form.subject.name} · ${form.name} 图片`, async () => {
|
await runOperation(projectId, `生成 ${form.subject.name} · ${form.name} 图片`, async () => {
|
||||||
const image = await subjectImagesApi.generate(formId, input)
|
const image = await subjectImagesApi.generate(formId, input)
|
||||||
if (!image || image.subjectFormId !== formId || image.status !== 'completed' || !image.imageUrl)
|
if (!image || image.subjectFormId !== formId || !['pending', 'generating'].includes(image.status))
|
||||||
throw new Error(image?.error || '接口未返回已完成的图片,请先刷新图片记录核对后端状态。')
|
throw new Error(image?.error || '接口未返回有效的形态图片生成任务,请刷新图片记录核对。')
|
||||||
})
|
})
|
||||||
await query.refresh()
|
await query.refresh()
|
||||||
}
|
}
|
||||||
@@ -146,6 +161,8 @@ export function useSubjectImages() {
|
|||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
forms,
|
forms,
|
||||||
|
generationModelsQuery,
|
||||||
|
profileQuery,
|
||||||
query,
|
query,
|
||||||
refreshProject: context.refresh,
|
refreshProject: context.refresh,
|
||||||
operation,
|
operation,
|
||||||
|
|||||||
Reference in new issue
Block a user