diff --git a/router/src/lib.rs b/router/src/lib.rs index c0155852..80daadde 100644 --- a/router/src/lib.rs +++ b/router/src/lib.rs @@ -1134,6 +1134,7 @@ pub struct Url { pub enum MessageChunk { Text { text: String }, ImageUrl { image_url: Url }, + Video { video_url: Url }, } #[derive(Clone, Deserialize, ToSchema, Serialize, Debug, PartialEq)] diff --git a/router/src/validation.rs b/router/src/validation.rs index 3cd85a6e..7896f9f8 100644 --- a/router/src/validation.rs +++ b/router/src/validation.rs @@ -560,6 +560,14 @@ fn fetch_image(input: &str) -> Result<(Vec, String, usize, usize), Validatio } } +fn fetch_video(input: &str) -> Result { + if input.starts_with("http://") || input.starts_with("https://") { + Ok(input.to_string()) + } else { + Err(ValidationError::InvalidVideoContent(input.to_string())) + } +} + fn image_tokens( config: &Config, preprocessor_config: Option<&HubPreprocessorConfig>, @@ -625,6 +633,9 @@ fn prepare_input( ) -> Result<(tokenizers::Encoding, Vec), ValidationError> { use Config::*; static RE: Lazy = Lazy::new(|| Regex::new(r"!\[\]\([^\)]*\)").unwrap()); + // Add video regex + static VIDEO_RE: Lazy = Lazy::new(|| Regex::new(r"