Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions src/areas/workflows/workflowRunStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,29 +163,39 @@ async function executeExtensionNode(
if (src.outputType === 'mesh') nodeInputMeshPath = src.filePath
else if (src.outputType === 'image') nodeInputPath = src.filePath
else if (src.filePath !== undefined) nodeInputPath = src.filePath
if (src.text !== undefined) nodeInputText = src.text
if (src.text !== undefined && src.text.trim().length > 0) nodeInputText = src.text
}
} else {
for (const edge of incomingEdges) {
const src = resolveSource(edge.source)
if (src?.filePath !== undefined) nodeInputPath = src.filePath
if (src?.text !== undefined) nodeInputText = src.text
if (src?.text !== undefined && src.text.trim().length > 0) nodeInputText = src.text
}
}

const isModelNode = ext?.type === 'model'

if (isModelNode) {
const activeImagePath = nodeInputPath ?? selectedImagePath
if (!selectedImageData && (!activeImagePath || activeImagePath.trim().length === 0)) {
const isTextInput = ext?.inputs ? ext.inputs.every((i) => i === 'text') : ext?.input === 'text'
const activeImagePath = isTextInput ? undefined : (nodeInputPath ?? selectedImagePath)
if (!isTextInput && !selectedImageData && (!activeImagePath || activeImagePath.trim().length === 0)) {
throw new Error('No input image selected for model node')
}
const base64 = selectedImageData && nodeInputPath === undefined
? selectedImageData
: await window.electron.fs.readFileBase64(activeImagePath as string)
const bytes = Uint8Array.from(atob(base64), (c) => c.charCodeAt(0))
const blob = new Blob([bytes], { type: 'image/png' })
const fname = activeImagePath?.split(/[\\/]/).pop() ?? 'image.png'

let blob: Blob
let fname: string
if (isTextInput || (!activeImagePath && selectedImageData)) {
const base64 = selectedImageData && nodeInputPath === undefined
? selectedImageData
: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==' // 1x1 transparent PNG
fname = 'placeholder.png'
blob = new Blob([Uint8Array.from(atob(base64), (c) => c.charCodeAt(0))], { type: 'image/png' })
} else {
const base64 = await window.electron.fs.readFileBase64(activeImagePath as string)
const bytes = Uint8Array.from(atob(base64), (c) => c.charCodeAt(0))
blob = new Blob([bytes], { type: 'image/png' })
fname = activeImagePath?.split(/[\\/]/).pop() ?? 'image.png'
}

const extraParams: Record<string, unknown> = {}
if (nodeInputMeshPath) {
Expand All @@ -194,6 +204,10 @@ async function executeExtensionNode(
? norm.slice(workspaceDir.length).replace(/^\//, '')
: norm
}
if (nodeInputText !== undefined && nodeInputText.trim().length > 0) {
extraParams.prompt = nodeInputText
extraParams.text = nodeInputText
}

const schemaDefaults = Object.fromEntries(
(ext.params ?? []).map((p) => [p.id, p.default]),
Expand Down