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";
|
||||
|
||||
@@ -17,16 +17,17 @@ export async function upscale(
|
||||
inputBuffer: Buffer,
|
||||
outputDir: string,
|
||||
options: UpscaleOptions = {},
|
||||
onProgress?: ProgressCallback,
|
||||
): Promise<UpscaleResult> {
|
||||
const inputPath = join(outputDir, "input_upscale.png");
|
||||
const outputPath = join(outputDir, "output_upscale.png");
|
||||
|
||||
await writeFile(inputPath, inputBuffer);
|
||||
const { stdout } = await runPythonScript("upscale.py", [
|
||||
const { stdout } = await runPythonWithProgress("upscale.py", [
|
||||
inputPath,
|
||||
outputPath,
|
||||
JSON.stringify(options),
|
||||
]);
|
||||
], { onProgress });
|
||||
|
||||
const result = JSON.parse(stdout);
|
||||
if (!result.success) {
|
||||
|
||||
Reference in New Issue
Block a user