mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 01:18:34 +00:00
quality in cost estimate
This commit is contained in:
1 parent
f0291c55a2
commit
8e9da04fd3
6 files changed
+37
-2
No files matched your search
@@ -0,0 +1,9 @@
|
||||
|
||||
// NOTE: These are defined in Rust (as the source of truth) and duplicated in the frontend.
|
||||
// In the future, we should use code gen (protobufs or similar) to keep the two sides in sync.
|
||||
|
||||
export enum CommonQuality {
|
||||
High = "high",
|
||||
Medium = "medium",
|
||||
Low = "low",
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
export * from "./CommonImageModel.js";
|
||||
export * from "./CommonVideoModel.js";
|
||||
export * from "./CommonAspectRatio.js";
|
||||
export * from "./CommonQuality.js";
|
||||
export * from "./CommonVideoResolution.js";
|
||||
export * from "./GenerationMode.js";
|
||||
export * from "./ImageGenerationMode.js";
|
||||
@@ -0,0 +1,21 @@
|
||||
import { CommonQuality } from "@storyteller/api-enums";
|
||||
|
||||
/**
|
||||
* Convert a quality value to CommonQuality for the image cost estimate API.
|
||||
*
|
||||
* Accepts a CommonQuality string value from @storyteller/model-list ("high", "medium", "low").
|
||||
*/
|
||||
export function imageQualityToCommonQuality(
|
||||
quality: string | undefined,
|
||||
): CommonQuality | null {
|
||||
switch (quality) {
|
||||
case "high":
|
||||
return CommonQuality.High;
|
||||
case "medium":
|
||||
return CommonQuality.Medium;
|
||||
case "low":
|
||||
return CommonQuality.Low;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -3,5 +3,6 @@ export * from "./videoAspectRatioToCommonAspectRatio.js";
|
||||
export * from "./videoStoreToGenerationMode.js";
|
||||
export * from "./imageModelToCommonImageModel.js";
|
||||
export * from "./imageAspectRatioToCommonAspectRatio.js";
|
||||
export * from "./imageQualityToCommonQuality.js";
|
||||
export * from "./imageResolutionToCommonVideoResolution.js";
|
||||
export * from "./imageStoreToGenerationMode.js";
|
||||
@@ -16,6 +16,7 @@ import { useCostBreakdownModalStore } from "./cost-breakdown-modal-store";
|
||||
import {
|
||||
imageModelToCommonImageModel,
|
||||
imageAspectRatioToCommonAspectRatio,
|
||||
imageQualityToCommonQuality,
|
||||
imageResolutionToCommonVideoResolution,
|
||||
} from "./convert/index.js";
|
||||
|
||||
@@ -117,6 +118,7 @@ export function useImageCostEstimate(
|
||||
);
|
||||
const commonResolution =
|
||||
imageResolutionToCommonVideoResolution(resolutionStr);
|
||||
const commonQuality = imageQualityToCommonQuality(qualityStr);
|
||||
const generationMode =
|
||||
referenceImageCount > 0
|
||||
? { type: "image_edit" as const, count: referenceImageCount }
|
||||
@@ -134,7 +136,7 @@ export function useImageCostEstimate(
|
||||
generation_mode: generationMode,
|
||||
aspect_ratio: commonAspectRatio ?? undefined,
|
||||
resolution: commonResolution ?? undefined,
|
||||
quality: qualityStr ?? undefined,
|
||||
quality: commonQuality ?? undefined,
|
||||
})
|
||||
.then((result) => {
|
||||
if (isEstimateImageCostSuccess(result)) {
|
||||
|
||||
@@ -3,6 +3,7 @@ import { CommandResult, CommandSuccessStatus } from "../common/CommandStatus";
|
||||
import {
|
||||
CommonImageModel,
|
||||
CommonAspectRatio,
|
||||
CommonQuality,
|
||||
CommonVideoResolution,
|
||||
ImageGenerationMode,
|
||||
GenerationProvider,
|
||||
@@ -14,7 +15,7 @@ export interface EstimateImageCostRequest {
|
||||
generation_mode: ImageGenerationMode;
|
||||
aspect_ratio?: CommonAspectRatio;
|
||||
resolution?: CommonVideoResolution;
|
||||
quality?: string;
|
||||
quality?: CommonQuality;
|
||||
image_batch_count?: number;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user