mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
feat(ai): add onProgress callback to all AI wrapper functions
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { runPythonScript } from "./bridge.js";
|
||||
import { runPythonWithProgress, type ProgressCallback } from "./bridge.js";
|
||||
import { writeFile, readFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
|
||||
@@ -6,6 +6,7 @@ export async function inpaint(
|
||||
inputBuffer: Buffer,
|
||||
maskBuffer: Buffer,
|
||||
outputDir: string,
|
||||
onProgress?: ProgressCallback,
|
||||
): Promise<Buffer> {
|
||||
const inputPath = join(outputDir, "input_inpaint.png");
|
||||
const maskPath = join(outputDir, "mask_inpaint.png");
|
||||
@@ -14,11 +15,11 @@ export async function inpaint(
|
||||
await writeFile(inputPath, inputBuffer);
|
||||
await writeFile(maskPath, maskBuffer);
|
||||
|
||||
const { stdout } = await runPythonScript("inpaint.py", [
|
||||
const { stdout } = await runPythonWithProgress("inpaint.py", [
|
||||
inputPath,
|
||||
maskPath,
|
||||
outputPath,
|
||||
]);
|
||||
], { onProgress });
|
||||
|
||||
const result = JSON.parse(stdout);
|
||||
if (!result.success) {
|
||||
|
||||
Reference in New Issue
Block a user