Exclusive llama-server load/unload on the 5080, queued Describe UI with resultText, Copy, and Use as prompt. Co-authored-by: Cursor <cursoragent@cursor.com>
75 lines
2.2 KiB
TypeScript
75 lines
2.2 KiB
TypeScript
import { validateCaptionRequest } from '~/shared/studio2/caption.mjs'
|
|
import { saveRecord, readRecord } from '../../utils/studio2/store'
|
|
import { addStudioJob, kickStudioQueue, type StudioJobPayload } from '../../utils/studioQueue'
|
|
import { getStill } from '../../utils/library'
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const { owner } = assertLibraryOwner(event)
|
|
const raw = await readBody(event)
|
|
let request: ReturnType<typeof validateCaptionRequest>
|
|
try {
|
|
request = validateCaptionRequest(raw)
|
|
} catch (e: any) {
|
|
throw createError({ statusCode: e.statusCode || 400, statusMessage: e.message })
|
|
}
|
|
assertFolderAccess(event, request.folderId)
|
|
let stillId = request.stillId
|
|
if (!stillId && request.sourcePath) {
|
|
// sourcePath may be a still id when the client already resolved a library asset.
|
|
stillId = String(request.sourcePath)
|
|
}
|
|
const still = getStill(owner, stillId)
|
|
assertFolderAccess(event, still.folderId)
|
|
request.stillId = still.id
|
|
request.imageAId = still.id
|
|
request.sourcePath = still.id
|
|
|
|
const id = crypto.randomUUID()
|
|
const record = {
|
|
id,
|
|
owner,
|
|
request,
|
|
state: 'waiting',
|
|
queuedAt: Date.now(),
|
|
familyId: crypto.randomUUID(),
|
|
outputs: [],
|
|
resultText: '',
|
|
purgeResult: 'Not yet saved'
|
|
}
|
|
saveRecord(record)
|
|
const row = await addStudioJob({
|
|
ownerKey: owner,
|
|
kind: 'caption',
|
|
familyId: record.familyId,
|
|
payload: {
|
|
studio2Id: id,
|
|
prompt: request.compiledPrompt,
|
|
name: `Describe · ${request.captionStyle}`,
|
|
folderId: request.folderId,
|
|
stillId: still.id,
|
|
captionStyle: request.captionStyle,
|
|
aspect: 'auto',
|
|
width: 0,
|
|
height: 0,
|
|
steps: 1,
|
|
turbo: true,
|
|
seed: 0,
|
|
cfg: 0,
|
|
fps: 24,
|
|
samplerName: 'euler',
|
|
scheduler: 'simple',
|
|
duration: 0,
|
|
sound: false,
|
|
workflow: 'minimax',
|
|
useIdentityRefs: false,
|
|
hideThumbnail: false,
|
|
referenceStillIds: [],
|
|
extensions: [],
|
|
queueAutoRun: true
|
|
} as StudioJobPayload
|
|
})
|
|
saveRecord({ ...readRecord(owner, id), queueId: row.id })
|
|
kickStudioQueue()
|
|
return { id, captionStyle: request.captionStyle, stillId: still.id }
|
|
})
|