mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-07 02:21:23 +00:00
success / error alerts and sounds
This commit is contained in:
1 parent
67007d0e25
commit
ca4f4632ab
5 files changed
+84
-23
No files matched your search
@@ -46,6 +46,8 @@ import Queue from "~/pages/PageEnigma/Queue/Queue";
|
||||
import { toEngineActions } from "~/pages/PageEnigma/Queue/toEngineActions";
|
||||
import { PromptsApi } from "@storyteller/api";
|
||||
import { SoundRegistry } from "@storyteller/soundboard";
|
||||
import { GetAppPreferences, SoraImageRemix } from "@storyteller/tauri-api";
|
||||
import { CommandSuccessStatus } from "@storyteller/tauri-api";
|
||||
|
||||
import {
|
||||
cameras,
|
||||
@@ -522,19 +524,54 @@ export const PromptBox = () => {
|
||||
//sceneMediaToken: "",
|
||||
});
|
||||
|
||||
const generateResponse = await invoke("sora_image_remix_command", {
|
||||
request: {
|
||||
snapshot_media_token: snapshotResult.data!,
|
||||
disable_system_prompt: !useSystemPrompt,
|
||||
prompt: prompt,
|
||||
maybe_additional_images: referenceImages.map(
|
||||
(image) => image.mediaToken,
|
||||
),
|
||||
maybe_number_of_samples: 1,
|
||||
},
|
||||
console.log("snapshotResult", snapshotResult)
|
||||
|
||||
const generateResponse = await SoraImageRemix({
|
||||
snapshot_media_token: snapshotResult.data!,
|
||||
disable_system_prompt: !useSystemPrompt,
|
||||
prompt: prompt,
|
||||
maybe_additional_images: referenceImages.map(
|
||||
(image) => image.mediaToken,
|
||||
),
|
||||
maybe_number_of_samples: 1,
|
||||
});
|
||||
|
||||
console.log("response", generateResponse);
|
||||
console.log("generateResponse", generateResponse)
|
||||
|
||||
if (generateResponse.status === CommandSuccessStatus.Success) {
|
||||
const prefs = await GetAppPreferences();
|
||||
const soundName = prefs.preferences?.enqueue_success_sound;
|
||||
if (soundName !== undefined) {
|
||||
const registry = SoundRegistry.getInstance();
|
||||
registry.playSound(soundName);
|
||||
}
|
||||
toast.success("Image added to queue");
|
||||
setisEnqueueing(false);
|
||||
return;
|
||||
|
||||
} else {
|
||||
const prefs = await GetAppPreferences();
|
||||
const soundName = prefs.preferences?.enqueue_failure_sound;
|
||||
if (soundName !== undefined) {
|
||||
const registry = SoundRegistry.getInstance();
|
||||
registry.playSound(soundName);
|
||||
}
|
||||
toast.error("Failed to enqueue image");
|
||||
setisEnqueueing(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// const generateResponse = await invoke("sora_image_remix_command", {
|
||||
// request: {
|
||||
// snapshot_media_token: snapshotResult.data!,
|
||||
// disable_system_prompt: !useSystemPrompt,
|
||||
// prompt: prompt,
|
||||
// maybe_additional_images: referenceImages.map(
|
||||
// (image) => image.mediaToken,
|
||||
// ),
|
||||
// maybe_number_of_samples: 1,
|
||||
// },
|
||||
// });
|
||||
|
||||
//if (generateResponse.errorMessage) {
|
||||
// handleError(response.errorMessage);
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
"files": [],
|
||||
"include": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../api"
|
||||
},
|
||||
{
|
||||
"path": "../../tauri-api"
|
||||
},
|
||||
@@ -11,6 +14,9 @@
|
||||
{
|
||||
"path": "../button"
|
||||
},
|
||||
{
|
||||
"path": "../input"
|
||||
},
|
||||
{
|
||||
"path": "./tsconfig.lib.json"
|
||||
},
|
||||
|
||||
@@ -43,6 +43,9 @@
|
||||
"src/**/*.tsx"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../api/tsconfig.lib.json"
|
||||
},
|
||||
{
|
||||
"path": "../../tauri-api/tsconfig.lib.json"
|
||||
},
|
||||
@@ -51,6 +54,9 @@
|
||||
},
|
||||
{
|
||||
"path": "../button/tsconfig.lib.json"
|
||||
},
|
||||
{
|
||||
"path": "../input/tsconfig.lib.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
export * from "./lib/common/CommandStatus.js";
|
||||
export * from "./lib/settings/GetAppPreferences.js";
|
||||
export * from "./lib/settings/UpdateAppPreference.js";
|
||||
export * from "./lib/sora/CheckSoraSession.js";
|
||||
export * from "./lib/sora/useSoraLoginListener.js";
|
||||
export * from "./lib/sora/LogoutSoraSession.js";
|
||||
export * from "./lib/sora/SoraImageRemix.js";
|
||||
export * from "./lib/sora/useSoraLoginListener.js";
|
||||
@@ -23,16 +23,26 @@ export interface SoraImageRemixResult extends CommandResult {
|
||||
// TODO: Status fields (they're not on the backend yet)
|
||||
}
|
||||
|
||||
// Returns the Success and Error variants directly.
|
||||
// Throws on Network/Tauri errors.
|
||||
export const SoraImageRemix = async (request: SoraImageRemixRequest) : Promise<SoraImageRemixResult> => {
|
||||
const result = await invoke("sora_image_remix_command", {
|
||||
request: {
|
||||
snapshot_media_token: request.snapshot_media_token,
|
||||
disable_system_prompt: request.disable_system_prompt,
|
||||
prompt: request.prompt,
|
||||
maybe_additional_images: request.maybe_additional_images,
|
||||
maybe_number_of_samples: request.maybe_number_of_samples,
|
||||
},
|
||||
});
|
||||
|
||||
return (result as SoraImageRemixResult);
|
||||
try {
|
||||
return await invoke("sora_image_remix_command", {
|
||||
request: {
|
||||
snapshot_media_token: request.snapshot_media_token,
|
||||
disable_system_prompt: request.disable_system_prompt,
|
||||
prompt: request.prompt,
|
||||
maybe_additional_images: request.maybe_additional_images,
|
||||
maybe_number_of_samples: request.maybe_number_of_samples,
|
||||
},
|
||||
}) as SoraImageRemixResult;
|
||||
} catch (error) {
|
||||
let maybeTypedError = error as CommandResult;
|
||||
if ("status" in maybeTypedError) {
|
||||
return maybeTypedError
|
||||
} else {
|
||||
// Something else with Tauri, network, etc.
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user