mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-05 01:38:44 +00:00
tests for flux1 dev
This commit is contained in:
1 parent
1622b68c64
commit
7dfaa3f095
4 files changed
+31
-6
No files matched your search
@@ -36,7 +36,9 @@ pub enum CommonAspectRatio {
|
||||
|
||||
// Auto values that bake in resolution
|
||||
// These are from the Seedream models
|
||||
#[serde(rename = "auto_2k")]
|
||||
Auto2k,
|
||||
#[serde(rename = "auto_4k")]
|
||||
Auto4k,
|
||||
|
||||
// Defined aspect ratios that bake in resolution
|
||||
|
||||
+26
-4
@@ -48,8 +48,10 @@ pub struct DistilledImageRequest {
|
||||
/// The fully-built router request, with `provider = Fal` so it matches the
|
||||
/// plan we actually execute. Private — useful for tests / debugging only.
|
||||
///
|
||||
/// Borrows inside this request point into the `_owned_*` boxes above.
|
||||
#[allow(dead_code)]
|
||||
/// Borrows inside this request point into the `_owned_*` boxes above. Access
|
||||
/// only via [`DistilledImageRequest::request`] (an accessor that ties the
|
||||
/// returned reference to `&self`) — never moved out, otherwise the borrows
|
||||
/// would dangle once the boxes are dropped with `Self`.
|
||||
request: GenerateImageRequest<'static>,
|
||||
|
||||
/// Cost estimate as computed by the Artcraft provider — this is what we bill on.
|
||||
@@ -58,8 +60,28 @@ pub struct DistilledImageRequest {
|
||||
/// Execution plan as computed by the Fal provider — what we hand to the router.
|
||||
///
|
||||
/// Borrows inside this plan point into the `_owned_*` boxes above (and into
|
||||
/// `request`, which itself points into them).
|
||||
pub plan: ImageGenerationPlan<'static>,
|
||||
/// `request`, which itself points into them). Access only via
|
||||
/// [`DistilledImageRequest::plan`] — moving the plan out of `Self` would
|
||||
/// dangle the borrows once the boxes are dropped.
|
||||
plan: ImageGenerationPlan<'static>,
|
||||
}
|
||||
|
||||
impl DistilledImageRequest {
|
||||
/// Borrow the execution plan. The returned reference's lifetime is tied to
|
||||
/// `&self`, so the plan can never outlive the boxes that back its borrows.
|
||||
pub fn plan(&self) -> &ImageGenerationPlan<'_> {
|
||||
// SAFETY: the plan was constructed with `'static` borrows that actually
|
||||
// point into `self._owned_*`. Re-binding the lifetime to `&self` exposes
|
||||
// the true invariant to callers.
|
||||
&self.plan
|
||||
}
|
||||
|
||||
/// Borrow the underlying router request. Useful for tests / debugging.
|
||||
/// (Same lifetime invariant as [`Self::plan`].)
|
||||
#[allow(dead_code)]
|
||||
pub(crate) fn request(&self) -> &GenerateImageRequest<'_> {
|
||||
&self.request
|
||||
}
|
||||
}
|
||||
|
||||
/// Build a [`DistilledImageRequest`] from a raw API request and a pre-computed
|
||||
|
||||
+2
-2
@@ -135,7 +135,7 @@ pub async fn omni_gen_image_generate_handler(
|
||||
let distilled = distill_image_request(&request, media_file_hydration_map.as_ref())?;
|
||||
|
||||
info!(">>> Distilled cost: {:?}", distilled.cost);
|
||||
info!(">>> Distilled plan: {:?}", distilled.plan);
|
||||
info!(">>> Distilled plan: {:?}", distilled.plan());
|
||||
|
||||
// ==================== BILLING ==================== //
|
||||
|
||||
@@ -163,7 +163,7 @@ pub async fn omni_gen_image_generate_handler(
|
||||
|
||||
let router_client = artcraft_router::client::router_client::RouterClient::Fal(fal_client);
|
||||
|
||||
let generation_response = distilled.plan.generate_image(&router_client)
|
||||
let generation_response = distilled.plan().generate_image(&router_client)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
warn!("Image generation failed: {:?}", e);
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
mod test_flux_1_dev;
|
||||
Reference in new issue
Block a user