mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 01:18:34 +00:00
remove unused code
This commit is contained in:
1 parent
13a5dad3a5
commit
39d2945e5e
5 files changed
-105
No files matched your search
@@ -2,7 +2,6 @@
|
||||
|
||||
pub mod creds;
|
||||
pub mod error;
|
||||
pub mod model;
|
||||
pub mod requests;
|
||||
pub mod utils;
|
||||
pub mod webhook_api;
|
||||
@@ -1,42 +0,0 @@
|
||||
use crate::creds::fal_api_key::FalApiKey;
|
||||
use crate::model::fal_endpoint::FalEndpoint;
|
||||
use crate::model::fal_request_id::FalRequestId;
|
||||
use crate::requests::api::queue::Queue;
|
||||
use crate::requests::api::queue_response::QueueResponse;
|
||||
use errors::AnyhowResult;
|
||||
use reqwest::Client;
|
||||
use serde::de::DeserializeOwned;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct EnqueuedRequest {
|
||||
pub fal_endpoint: FalEndpoint,
|
||||
pub request_id: FalRequestId,
|
||||
pub response_url: String,
|
||||
pub status_url: String,
|
||||
pub cancel_url: String,
|
||||
}
|
||||
|
||||
impl EnqueuedRequest {
|
||||
pub fn from_queue_response<R: DeserializeOwned>(queue: &Queue<R>) -> AnyhowResult<Self> {
|
||||
let endpoint = FalEndpoint::from_queue_response(queue);
|
||||
Ok(Self {
|
||||
fal_endpoint: endpoint.clone(),
|
||||
request_id: FalRequestId(queue.payload.request_id.clone()),
|
||||
response_url: queue.payload.response_url.clone(),
|
||||
status_url: queue.payload.status_url.clone(),
|
||||
cancel_url: queue.payload.cancel_url.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn to_queue_response<R: DeserializeOwned>(&self, api_key: &FalApiKey) -> AnyhowResult<Queue<R>> {
|
||||
let client = Client::new();
|
||||
let endpoint = self.fal_endpoint.url();
|
||||
let payload = QueueResponse {
|
||||
request_id: self.request_id.0.clone(),
|
||||
response_url: self.response_url.clone(),
|
||||
status_url: self.status_url.clone(),
|
||||
cancel_url: self.cancel_url.clone(),
|
||||
};
|
||||
Ok(Queue::new(client, endpoint, api_key.0.clone(), payload))
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
use crate::requests::api::queue::Queue;
|
||||
use serde::de::DeserializeOwned;
|
||||
// TODO(bt,2025-05-26): A macro to define these + tests.
|
||||
|
||||
const FLUX_PRO_ULTRA_TEXT_TO_IMAGE: &str = "fal-ai/flux-pro/v1.1-ultra";
|
||||
|
||||
const HUNYUAN_3D_2_BASE: &str = "fal-ai/hunyuan3d/v2";
|
||||
|
||||
const KLING16_IMAGE_TO_VIDEO: &str = "fal-ai/kling-video/v1.6/pro/image-to-video";
|
||||
|
||||
const MINIMAX_IMAGE_TO_VIDEO: &str = "fal-ai/minimax/image-to-video";
|
||||
|
||||
const RECRAFT_V3_TEXT_TO_IMAGE: &str = "fal-ai/recraft-v3";
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum FalEndpoint {
|
||||
FluxProUltraTextToImage,
|
||||
Hunyuan3d2Base,
|
||||
Kling16ImageToVideo,
|
||||
Minimax01ImageToVideo,
|
||||
RecraftV3TextToImage,
|
||||
Other(String),
|
||||
}
|
||||
|
||||
impl FalEndpoint {
|
||||
pub fn from_queue_response<R: DeserializeOwned>(queue: &Queue<R>) -> Self {
|
||||
match queue.endpoint.as_str() {
|
||||
FLUX_PRO_ULTRA_TEXT_TO_IMAGE => FalEndpoint::FluxProUltraTextToImage,
|
||||
HUNYUAN_3D_2_BASE => FalEndpoint::Hunyuan3d2Base,
|
||||
KLING16_IMAGE_TO_VIDEO => FalEndpoint::Kling16ImageToVideo,
|
||||
MINIMAX_IMAGE_TO_VIDEO => FalEndpoint::Minimax01ImageToVideo,
|
||||
RECRAFT_V3_TEXT_TO_IMAGE => FalEndpoint::RecraftV3TextToImage,
|
||||
_ => FalEndpoint::Other(queue.endpoint.clone()),
|
||||
}
|
||||
}
|
||||
pub fn url(&self) -> &str {
|
||||
match self {
|
||||
Self::FluxProUltraTextToImage => FLUX_PRO_ULTRA_TEXT_TO_IMAGE,
|
||||
Self::Hunyuan3d2Base => HUNYUAN_3D_2_BASE,
|
||||
Self::Kling16ImageToVideo => KLING16_IMAGE_TO_VIDEO,
|
||||
Self::Minimax01ImageToVideo => MINIMAX_IMAGE_TO_VIDEO,
|
||||
Self::RecraftV3TextToImage => RECRAFT_V3_TEXT_TO_IMAGE,
|
||||
Self::Other(url) => url,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
use std::fmt::Display;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use crate::model::fal_endpoint::FalEndpoint;
|
||||
|
||||
/// A strongly typed request ID for the Fal API.
|
||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Serialize, Deserialize)]
|
||||
pub struct FalRequestId(pub String);
|
||||
|
||||
impl Display for FalRequestId {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
Display::fmt(&self.0, f)
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
pub mod enqueued_request;
|
||||
pub mod fal_endpoint;
|
||||
pub mod fal_request_id;
|
||||
Reference in new issue
Block a user