Add an AIGen-only generate API for external tools.
Cursor and similar clients can enqueue Studio 2 stills with the same steps and CFG the bench uses, through session or AIGEN_API_KEY. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import { sectionsFrom, compileSections } from './prompt.mjs'
|
||||
import { QWEN21_ASPECT_IDS, resolveQwen21Size } from './qwen21-size.mjs'
|
||||
import { QWEN21_TURBO_CFG, QWEN21_TURBO_LORA, QWEN21_TURBO_SIGMAS, QWEN21_TURBO_STEPS } from './qwen21-turbo.mjs'
|
||||
import { applyPhotosToRequest } from './photos.mjs'
|
||||
import { studio2EngineDefaults } from './engine-defaults.mjs'
|
||||
export { sectionsFrom } from './prompt.mjs'
|
||||
export const cameraFamilies = ['static','dolly in','dolly out','pan left','pan right','tilt up','tilt down','zoom in','zoom out','orbit left','orbit right']
|
||||
export const identityLock = '<Picture 1> / hero is identity for face, hair, glasses, body, and wardrobe. Keep the person and clothes fully preserved. Start frame is composition, pose, place, and camera only. Do not copy facial drift from the start frame.'
|
||||
@@ -56,9 +57,14 @@ export function validateRequest(raw, xaigen = false) {
|
||||
const number=(key, fallback, min, max) => { const n=Number(raw.settings?.[key] ?? fallback); if (!Number.isFinite(n)||n<min||n>max) fail(`Invalid ${key}.`); return n }
|
||||
const qwen = engine === 'qwen21'
|
||||
const moss = engine === 'moss'
|
||||
const defaultSteps = video ? 8 : qwen || moss ? 25 : 24
|
||||
const defaultCfg = video ? 1.5 : qwen ? 1 : moss ? 2.5 : 4
|
||||
const aspect = QWEN21_ASPECT_IDS.has(raw.settings?.aspect) ? raw.settings.aspect : 'auto'
|
||||
const imageDefaults = studio2EngineDefaults(engine)
|
||||
const defaultSteps = video ? 8 : imageDefaults.steps
|
||||
const defaultCfg = video ? 1.5 : imageDefaults.cfg
|
||||
const requestedAspect = raw.settings?.aspect == null || raw.settings?.aspect === ''
|
||||
? imageDefaults.aspect
|
||||
: raw.settings.aspect
|
||||
const aspect = QWEN21_ASPECT_IDS.has(requestedAspect) ? requestedAspect : 'auto'
|
||||
|
||||
const qwenSize = qwen && mode === 'generate' ? resolveQwen21Size(aspect) : null
|
||||
const defaultWidth = qwenSize ? qwenSize.width : qwen || moss ? 1024 : 1344
|
||||
const defaultHeight = qwenSize ? qwenSize.height : qwen || moss ? 1024 : 768
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/** Recommended Studio 2 image Generate steps / CFG / aspect. Bench and /api/aigen share this. */
|
||||
export const STUDIO2_IMAGE_ENGINES = ['flux', 'krea', 'qwen21', 'moss']
|
||||
|
||||
export function studio2EngineDefaults(engine) {
|
||||
const id = String(engine || 'flux').trim().toLowerCase()
|
||||
if (id === 'qwen21') return { steps: 25, cfg: 1, aspect: 'auto' }
|
||||
if (id === 'moss') return { steps: 25, cfg: 2.5, aspect: '1:1' }
|
||||
return { steps: 24, cfg: 4, aspect: 'auto' }
|
||||
}
|
||||
|
||||
export function isStudio2ImageEngine(engine) {
|
||||
return STUDIO2_IMAGE_ENGINES.includes(String(engine || '').trim().toLowerCase())
|
||||
}
|
||||
|
||||
/** Inbox when present, otherwise the first folder. */
|
||||
export function defaultLibraryFolderId(catalog, requested) {
|
||||
const folders = catalog?.folders || []
|
||||
const want = String(requested || '').trim()
|
||||
if (want && folders.some(folder => folder.id === want)) return want
|
||||
const inbox = folders.find(folder => folder.id === 'inbox' || /^inbox$/i.test(String(folder.name || '')))
|
||||
return inbox?.id || folders[0]?.id || ''
|
||||
}
|
||||
Reference in New Issue
Block a user