mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-18 15:44:36 +00:00
new video enums
This commit is contained in:
1 parent
f38098e629
commit
1a10c21f34
4 files changed
+41
-3
No files matched your search
@@ -8,6 +8,9 @@ pub enum CommonVideoModel {
|
||||
#[serde(rename = "grok_video")]
|
||||
GrokVideo,
|
||||
|
||||
#[serde(rename = "grok_imagine_video")]
|
||||
GrokImagineVideo,
|
||||
|
||||
#[serde(rename = "kling_1p6_pro")]
|
||||
Kling16Pro,
|
||||
|
||||
|
||||
@@ -143,6 +143,8 @@ pub enum InferenceModelType {
|
||||
// Video models
|
||||
#[serde(rename = "grok_video")]
|
||||
GrokVideo,
|
||||
#[serde(rename = "grok_imagine_video")]
|
||||
GrokImagineVideo,
|
||||
#[serde(rename = "kling_1p6_pro")]
|
||||
Kling16Pro,
|
||||
#[serde(rename = "kling_2p1_pro")]
|
||||
@@ -273,6 +275,7 @@ impl InferenceModelType {
|
||||
|
||||
// Video models
|
||||
Self::GrokVideo => "grok_video",
|
||||
Self::GrokImagineVideo => "grok_imagine_video",
|
||||
Self::Kling16Pro => "kling_1p6_pro",
|
||||
Self::Kling21Pro => "kling_2p1_pro",
|
||||
Self::Kling21Master => "kling_2p1_master",
|
||||
@@ -366,6 +369,7 @@ impl InferenceModelType {
|
||||
|
||||
// Video models
|
||||
"grok_video" => Ok(Self::GrokVideo),
|
||||
"grok_imagine_video" => Ok(Self::GrokImagineVideo),
|
||||
"kling_1p6_pro" => Ok(Self::Kling16Pro),
|
||||
"kling_2p1_pro" => Ok(Self::Kling21Pro),
|
||||
"kling_2p1_master" => Ok(Self::Kling21Master),
|
||||
@@ -463,6 +467,7 @@ impl InferenceModelType {
|
||||
|
||||
// Video models
|
||||
Self::GrokVideo,
|
||||
Self::GrokImagineVideo,
|
||||
Self::Kling16Pro,
|
||||
Self::Kling21Pro,
|
||||
Self::Kling21Master,
|
||||
@@ -543,6 +548,7 @@ impl InferenceModelType {
|
||||
|
||||
// Video models
|
||||
CommonModelType::GrokVideo => Self::GrokVideo,
|
||||
CommonModelType::GrokImagineVideo => Self::GrokImagineVideo,
|
||||
CommonModelType::Kling16Pro => Self::Kling16Pro,
|
||||
CommonModelType::Kling21Pro => Self::Kling21Pro,
|
||||
CommonModelType::Kling21Master => Self::Kling21Master,
|
||||
@@ -646,6 +652,7 @@ mod tests {
|
||||
|
||||
// Video models
|
||||
assert_serialization(InferenceModelType::GrokVideo, "grok_video");
|
||||
assert_serialization(InferenceModelType::GrokImagineVideo, "grok_imagine_video");
|
||||
assert_serialization(InferenceModelType::Kling16Pro, "kling_1p6_pro");
|
||||
assert_serialization(InferenceModelType::Kling21Pro, "kling_2p1_pro");
|
||||
assert_serialization(InferenceModelType::Kling21Master, "kling_2p1_master");
|
||||
@@ -738,6 +745,7 @@ mod tests {
|
||||
|
||||
// Video models
|
||||
assert_eq!(InferenceModelType::GrokVideo.to_str(), "grok_video");
|
||||
assert_eq!(InferenceModelType::GrokImagineVideo.to_str(), "grok_imagine_video");
|
||||
assert_eq!(InferenceModelType::Kling16Pro.to_str(), "kling_1p6_pro");
|
||||
assert_eq!(InferenceModelType::Kling21Pro.to_str(), "kling_2p1_pro");
|
||||
assert_eq!(InferenceModelType::Kling21Master.to_str(), "kling_2p1_master");
|
||||
@@ -830,6 +838,7 @@ mod tests {
|
||||
|
||||
// Video models
|
||||
assert_eq!(InferenceModelType::from_str("grok_video").unwrap(), InferenceModelType::GrokVideo);
|
||||
assert_eq!(InferenceModelType::from_str("grok_imagine_video").unwrap(), InferenceModelType::GrokImagineVideo);
|
||||
assert_eq!(InferenceModelType::from_str("kling_1p6_pro").unwrap(), InferenceModelType::Kling16Pro);
|
||||
assert_eq!(InferenceModelType::from_str("kling_2p1_pro").unwrap(), InferenceModelType::Kling21Pro);
|
||||
assert_eq!(InferenceModelType::from_str("kling_2p1_master").unwrap(), InferenceModelType::Kling21Master);
|
||||
|
||||
@@ -101,9 +101,16 @@ pub enum CommonModelType {
|
||||
|
||||
// Video models
|
||||
|
||||
// Generic grok video model without a version
|
||||
/// Generic grok video model without a version
|
||||
/// NB: This was for the consumer web login API
|
||||
#[deprecated(note = "use GrokImagineVideo instead")]
|
||||
#[serde(rename = "grok_video")]
|
||||
GrokVideo,
|
||||
GrokVideo,
|
||||
/// xAI's Grok Imagine video model (grok-imagine-video).
|
||||
/// This is for the API-based version.
|
||||
/// No version is specified.
|
||||
#[serde(rename = "grok_imagine_video")]
|
||||
GrokImagineVideo,
|
||||
#[serde(rename = "kling_1p6_pro")]
|
||||
Kling16Pro,
|
||||
#[serde(rename = "kling_2p1_pro")]
|
||||
@@ -218,6 +225,7 @@ impl CommonModelType {
|
||||
|
||||
// Video models
|
||||
Self::GrokVideo => "grok_video",
|
||||
Self::GrokImagineVideo => "grok_imagine_video",
|
||||
Self::Kling16Pro => "kling_1p6_pro",
|
||||
Self::Kling21Pro => "kling_2p1_pro",
|
||||
Self::Kling21Master => "kling_2p1_master",
|
||||
@@ -294,6 +302,7 @@ impl CommonModelType {
|
||||
|
||||
// Video models
|
||||
"grok_video" => Ok(Self::GrokVideo),
|
||||
"grok_imagine_video" => Ok(Self::GrokImagineVideo),
|
||||
"kling_1p6_pro" => Ok(Self::Kling16Pro),
|
||||
"kling_2p1_pro" => Ok(Self::Kling21Pro),
|
||||
"kling_2p1_master" => Ok(Self::Kling21Master),
|
||||
@@ -374,6 +383,7 @@ impl CommonModelType {
|
||||
|
||||
// Video models
|
||||
Self::GrokVideo,
|
||||
Self::GrokImagineVideo,
|
||||
Self::Kling16Pro,
|
||||
Self::Kling21Pro,
|
||||
Self::Kling21Master,
|
||||
@@ -451,6 +461,7 @@ impl CommonModelType {
|
||||
|
||||
// Video models
|
||||
Self::GrokVideo => CommonModelClass::Video,
|
||||
Self::GrokImagineVideo => CommonModelClass::Video,
|
||||
Self::Kling16Pro => CommonModelClass::Video,
|
||||
Self::Kling21Pro => CommonModelClass::Video,
|
||||
Self::Kling21Master => CommonModelClass::Video,
|
||||
@@ -537,6 +548,7 @@ mod tests {
|
||||
assert_serialization(CommonModelType::MidjourneyV7Raw, "midjourney_v7_raw");
|
||||
// Video models
|
||||
assert_serialization(CommonModelType::GrokVideo, "grok_video");
|
||||
assert_serialization(CommonModelType::GrokImagineVideo, "grok_imagine_video");
|
||||
assert_serialization(CommonModelType::Kling16Pro, "kling_1p6_pro");
|
||||
assert_serialization(CommonModelType::Kling21Pro, "kling_2p1_pro");
|
||||
assert_serialization(CommonModelType::Kling21Master, "kling_2p1_master");
|
||||
@@ -610,6 +622,7 @@ mod tests {
|
||||
|
||||
// Video models
|
||||
assert_eq!(CommonModelType::GrokVideo.to_str(), "grok_video");
|
||||
assert_eq!(CommonModelType::GrokImagineVideo.to_str(), "grok_imagine_video");
|
||||
assert_eq!(CommonModelType::Kling16Pro.to_str(), "kling_1p6_pro");
|
||||
assert_eq!(CommonModelType::Kling21Pro.to_str(), "kling_2p1_pro");
|
||||
assert_eq!(CommonModelType::Kling21Master.to_str(), "kling_2p1_master");
|
||||
@@ -683,6 +696,7 @@ mod tests {
|
||||
assert_eq!(CommonModelType::from_str("midjourney_v7_raw").unwrap(), CommonModelType::MidjourneyV7Raw);
|
||||
// Video models
|
||||
assert_eq!(CommonModelType::from_str("grok_video").unwrap(), CommonModelType::GrokVideo);
|
||||
assert_eq!(CommonModelType::from_str("grok_imagine_video").unwrap(), CommonModelType::GrokImagineVideo);
|
||||
assert_eq!(CommonModelType::from_str("kling_1p6_pro").unwrap(), CommonModelType::Kling16Pro);
|
||||
assert_eq!(CommonModelType::from_str("kling_2p1_pro").unwrap(), CommonModelType::Kling21Pro);
|
||||
assert_eq!(CommonModelType::from_str("kling_2p1_master").unwrap(), CommonModelType::Kling21Master);
|
||||
@@ -723,7 +737,7 @@ mod tests {
|
||||
#[test]
|
||||
fn all_variants() {
|
||||
let mut variants = CommonModelType::all_variants();
|
||||
assert_eq!(variants.len(), 64);
|
||||
assert_eq!(variants.len(), 65);
|
||||
// Image models
|
||||
assert_eq!(variants.pop_first(), Some(CommonModelType::Flux1Dev));
|
||||
assert_eq!(variants.pop_first(), Some(CommonModelType::Flux1Schnell));
|
||||
@@ -758,6 +772,7 @@ mod tests {
|
||||
assert_eq!(variants.pop_first(), Some(CommonModelType::MidjourneyV7Raw));
|
||||
// Video models
|
||||
assert_eq!(variants.pop_first(), Some(CommonModelType::GrokVideo));
|
||||
assert_eq!(variants.pop_first(), Some(CommonModelType::GrokImagineVideo));
|
||||
assert_eq!(variants.pop_first(), Some(CommonModelType::Kling16Pro));
|
||||
assert_eq!(variants.pop_first(), Some(CommonModelType::Kling21Pro));
|
||||
assert_eq!(variants.pop_first(), Some(CommonModelType::Kling21Master));
|
||||
|
||||
@@ -5,9 +5,15 @@ use utoipa::ToSchema;
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Serialize, Deserialize, ToSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum CommonVideoModel {
|
||||
/// NB: This was for the web login version
|
||||
#[deprecated = "Use `GrokImagineVideo` instead."]
|
||||
#[serde(rename = "grok_video")]
|
||||
GrokVideo,
|
||||
|
||||
/// NB: This is for the API version
|
||||
#[serde(rename = "grok_imagine_video")]
|
||||
GrokImagineVideo,
|
||||
|
||||
#[serde(rename = "kling_1p6_pro")]
|
||||
Kling16Pro,
|
||||
|
||||
@@ -93,6 +99,7 @@ impl CommonVideoModel {
|
||||
use crate::common::generation::common_model_type::CommonModelType;
|
||||
match self {
|
||||
Self::GrokVideo => CommonModelType::GrokVideo,
|
||||
Self::GrokImagineVideo => CommonModelType::GrokImagineVideo,
|
||||
Self::Kling16Pro => CommonModelType::Kling16Pro,
|
||||
Self::Kling21Pro => CommonModelType::Kling21Pro,
|
||||
Self::Kling21Master => CommonModelType::Kling21Master,
|
||||
@@ -131,6 +138,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
assert_serialization(CommonVideoModel::GrokVideo, "grok_video");
|
||||
assert_serialization(CommonVideoModel::GrokImagineVideo, "grok_imagine_video");
|
||||
assert_serialization(CommonVideoModel::Kling16Pro, "kling_1p6_pro");
|
||||
assert_serialization(CommonVideoModel::Kling21Pro, "kling_2p1_pro");
|
||||
assert_serialization(CommonVideoModel::Kling21Master, "kling_2p1_master");
|
||||
@@ -162,6 +170,7 @@ mod tests {
|
||||
fn test_deserialization() {
|
||||
let cases = [
|
||||
("grok_video", CommonVideoModel::GrokVideo),
|
||||
("grok_imagine_video", CommonVideoModel::GrokImagineVideo),
|
||||
("kling_1p6_pro", CommonVideoModel::Kling16Pro),
|
||||
("kling_2p1_pro", CommonVideoModel::Kling21Pro),
|
||||
("kling_2p1_master", CommonVideoModel::Kling21Master),
|
||||
@@ -200,6 +209,7 @@ mod tests {
|
||||
fn test_round_trip() {
|
||||
let all = [
|
||||
CommonVideoModel::GrokVideo,
|
||||
CommonVideoModel::GrokImagineVideo,
|
||||
CommonVideoModel::Kling16Pro,
|
||||
CommonVideoModel::Kling21Pro,
|
||||
CommonVideoModel::Kling21Master,
|
||||
@@ -237,6 +247,7 @@ mod tests {
|
||||
fn all_video_models_convert_to_common_model_type() {
|
||||
let models = [
|
||||
(CommonVideoModel::GrokVideo, CommonModelType::GrokVideo),
|
||||
(CommonVideoModel::GrokImagineVideo, CommonModelType::GrokImagineVideo),
|
||||
(CommonVideoModel::Kling16Pro, CommonModelType::Kling16Pro),
|
||||
(CommonVideoModel::Kling21Pro, CommonModelType::Kling21Pro),
|
||||
(CommonVideoModel::Kling21Master, CommonModelType::Kling21Master),
|
||||
|
||||
Reference in new issue
Block a user