feat: implement length parameter handling in stream_item_content_by_id
Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) <aider@aider.chat>
This commit is contained in:
@@ -57,7 +57,7 @@ impl AsyncItemService {
|
||||
item_id: i64,
|
||||
allow_binary: bool,
|
||||
_offset: u64,
|
||||
_length: u64,
|
||||
length: u64,
|
||||
) -> Result<(std::pin::Pin<Box<dyn tokio_stream::Stream<Item = Result<tokio_util::bytes::Bytes, std::io::Error>> + Send>>, String), CoreError> {
|
||||
// Get the item content synchronously
|
||||
let item_with_content = self.get_item_content(item_id).await?;
|
||||
@@ -82,8 +82,11 @@ impl AsyncItemService {
|
||||
.map(|s| s.to_string())
|
||||
.unwrap_or_else(|| "application/octet-stream".to_string());
|
||||
|
||||
// Convert content to stream
|
||||
let content = item_with_content.content;
|
||||
// Convert content to stream with length limit
|
||||
let mut content = item_with_content.content;
|
||||
if length > 0 && length < content.len() as u64 {
|
||||
content.truncate(length as usize);
|
||||
}
|
||||
let stream = Box::pin(tokio_stream::iter(vec![Ok(tokio_util::bytes::Bytes::from(content))]));
|
||||
|
||||
Ok((stream, mime_type))
|
||||
|
||||
Reference in New Issue
Block a user