mirror of
https://github.com/huggingface/text-generation-inference.git
synced 2025-04-25 03:52:08 +00:00
adopting video url
This commit is contained in:
parent
7c679399d5
commit
5ced960f6e
@ -79,6 +79,9 @@ 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(url)) => {
|
||||||
|
output.push_str(&format!("<video>({})", url))
|
||||||
|
}
|
||||||
// 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"),
|
||||||
});
|
});
|
||||||
|
@ -15,7 +15,7 @@ pub use grpc_client::Client;
|
|||||||
pub use pb::generate::v3::{
|
pub use pb::generate::v3::{
|
||||||
input_chunk::Chunk, Batch, CachedBatch, FinishReason, GeneratedText, Generation, GrammarType,
|
input_chunk::Chunk, Batch, CachedBatch, FinishReason, GeneratedText, Generation, GrammarType,
|
||||||
HealthResponse, Image, InfoResponse, Input, InputChunk, NextTokenChooserParameters, Request,
|
HealthResponse, Image, InfoResponse, Input, InputChunk, NextTokenChooserParameters, Request,
|
||||||
StoppingCriteriaParameters,
|
StoppingCriteriaParameters,
|
||||||
};
|
};
|
||||||
pub use sharded_client::ShardedClient;
|
pub use sharded_client::ShardedClient;
|
||||||
|
|
||||||
|
@ -439,6 +439,7 @@ impl State {
|
|||||||
data: image.data,
|
data: image.data,
|
||||||
mimetype: image.mimetype,
|
mimetype: image.mimetype,
|
||||||
}),
|
}),
|
||||||
|
Chunk::Video(url) => client::Chunk::Video(url),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
|
@ -70,6 +70,9 @@ message InputChunk {
|
|||||||
string text = 1;
|
string text = 1;
|
||||||
/// Image data
|
/// Image data
|
||||||
Image image = 2;
|
Image image = 2;
|
||||||
|
/// Video URLs
|
||||||
|
string video = 3;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1173,7 +1173,7 @@ pub struct Url {
|
|||||||
pub enum MessageChunk {
|
pub enum MessageChunk {
|
||||||
Text { text: String },
|
Text { text: String },
|
||||||
ImageUrl { image_url: Url },
|
ImageUrl { image_url: Url },
|
||||||
Video { video_url: Url },
|
VideoUrl { video_url: Url },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Deserialize, ToSchema, Serialize, Debug, PartialEq)]
|
#[derive(Clone, Deserialize, ToSchema, Serialize, Debug, PartialEq)]
|
||||||
@ -1230,6 +1230,7 @@ impl From<Message> for TextMessage {
|
|||||||
.map(|chunk| match chunk {
|
.map(|chunk| match chunk {
|
||||||
MessageChunk::Text { text } => text,
|
MessageChunk::Text { text } => text,
|
||||||
MessageChunk::ImageUrl { image_url } => format!("", image_url.url),
|
MessageChunk::ImageUrl { image_url } => format!("", image_url.url),
|
||||||
|
MessageChunk::VideoUrl { video_url } => format!("", video_url.url),
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join(""),
|
.join(""),
|
||||||
|
@ -580,14 +580,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(
|
fn image_tokens(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
preprocessor_config: Option<&HubPreprocessorConfig>,
|
preprocessor_config: Option<&HubPreprocessorConfig>,
|
||||||
|
Loading…
Reference in New Issue
Block a user