adopting video url

This commit is contained in:
Miquel Farre 2024-11-13 13:37:17 +00:00 committed by drbh
parent fc5b0ac1fd
commit da644c21e5
6 changed files with 10 additions and 10 deletions

View File

@ -79,6 +79,9 @@ impl ChunksToString for Vec<InputChunk> {
let encoded = STANDARD.encode(data);
output.push_str(&format!("![](data:{};base64,{})", mimetype, encoded))
}
Some(Chunk::Video(url)) => {
output.push_str(&format!("<video>({})", url))
}
// We don't create empty chunks, so this should be unreachable.
None => unreachable!("Chunks should never be empty"),
});

View File

@ -439,6 +439,7 @@ impl State {
data: image.data,
mimetype: image.mimetype,
}),
Chunk::Video(url) => client::Chunk::Video(url),
}),
})
.collect(),

View File

@ -70,6 +70,9 @@ message InputChunk {
string text = 1;
/// Image data
Image image = 2;
/// Video URLs
string video = 3;
}
}

View File

@ -1134,7 +1134,7 @@ pub struct Url {
pub enum MessageChunk {
Text { text: String },
ImageUrl { image_url: Url },
Video { video_url: Url },
VideoUrl { video_url: Url },
}
#[derive(Clone, Deserialize, ToSchema, Serialize, Debug, PartialEq)]
@ -1191,6 +1191,7 @@ impl From<Message> for TextMessage {
.map(|chunk| match chunk {
MessageChunk::Text { text } => text,
MessageChunk::ImageUrl { image_url } => format!("![]({})", image_url.url),
MessageChunk::VideoUrl { video_url } => format!("![]({})", video_url.url),
})
.collect::<Vec<_>>()
.join(""),

View File

@ -560,14 +560,6 @@ fn fetch_image(input: &str) -> Result<(Vec<u8>, String, usize, usize), Validatio
}
}
fn fetch_video(input: &str) -> Result<String, ValidationError> {
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>,