adopting video url
This commit is contained in:
parent
fc5b0ac1fd
commit
da644c21e5
|
@ -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"),
|
||||
});
|
||||
|
|
|
@ -439,6 +439,7 @@ impl State {
|
|||
data: image.data,
|
||||
mimetype: image.mimetype,
|
||||
}),
|
||||
Chunk::Video(url) => client::Chunk::Video(url),
|
||||
}),
|
||||
})
|
||||
.collect(),
|
||||
|
|
|
@ -70,6 +70,9 @@ message InputChunk {
|
|||
string text = 1;
|
||||
/// Image data
|
||||
Image image = 2;
|
||||
/// Video URLs
|
||||
string video = 3;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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(""),
|
||||
|
|
|
@ -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>,
|
||||
|
|
Loading…
Reference in New Issue