mirror of
https://github.com/huggingface/text-generation-inference.git
synced 2025-04-21 14:52:20 +00:00
flatten frames to data block when needed
This commit is contained in:
parent
e65ead12bb
commit
36e095b38d
@ -79,10 +79,14 @@ impl ChunksToString for Vec<InputChunk> {
|
|||||||
let encoded = STANDARD.encode(data);
|
let encoded = STANDARD.encode(data);
|
||||||
output.push_str(&format!("", mimetype, encoded))
|
output.push_str(&format!("", mimetype, encoded))
|
||||||
}
|
}
|
||||||
Some(Chunk::Video(Video { data, mimetype })) => {
|
Some(Chunk::Video(video)) => {
|
||||||
let encoded = STANDARD.encode(data);
|
let encoded = STANDARD.encode(&video.as_bytes());
|
||||||
output.push_str(&format!("<video>(data:{};base64,{})", mimetype, encoded))
|
output.push_str(&format!("<video>(data:{};base64,{})", video.mimetype, encoded))
|
||||||
}
|
}
|
||||||
|
// Some(Chunk::Video(Video { data, mimetype })) => {
|
||||||
|
// let encoded = STANDARD.encode(data);
|
||||||
|
// output.push_str(&format!("<video>(data:{};base64,{})", mimetype, encoded))
|
||||||
|
// }
|
||||||
// We don't create empty chunks, so this should be unreachable.
|
// We don't create empty chunks, so this should be unreachable.
|
||||||
None => unreachable!("Chunks should never be empty"),
|
None => unreachable!("Chunks should never be empty"),
|
||||||
});
|
});
|
||||||
|
@ -816,6 +816,12 @@ pub struct Video {
|
|||||||
pub mimetype: String,
|
pub mimetype: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Video {
|
||||||
|
pub fn as_bytes(&self) -> Vec<u8> {
|
||||||
|
self.frames.iter().flatten().cloned().collect()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
pub enum Chunk {
|
pub enum Chunk {
|
||||||
Text(String),
|
Text(String),
|
||||||
|
Loading…
Reference in New Issue
Block a user