Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 49 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ nvisy-rig = { path = "./crates/nvisy-rig", version = "0.1.0" }
nvisy-server = { path = "./crates/nvisy-server", version = "0.1.0" }

# LLM framework
rig-core = { version = "0.31", features = [] }
rig-core = { version = "0.32", features = [] }

# HTTP client and middleware
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls", "multipart"] }
Expand Down
8 changes: 5 additions & 3 deletions crates/nvisy-codec/src/document/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,16 @@ impl From<Document<DocxHandler>> for AnyDocument {

#[cfg(test)]
mod tests {
use nvisy_core::fs::{AudioFormat, ImageFormat, TextFormat};

use super::*;

#[test]
fn from_txt_handler() {
let doc = Document::new(TxtHandler::new(vec!["hello".into()], false));
let any: AnyDocument = doc.into();
assert!(any.as_text().is_some());
assert_eq!(any.document_type(), DocumentType::Txt);
assert_eq!(any.document_type(), DocumentType::Text(TextFormat::Txt));
}

#[test]
Expand All @@ -186,15 +188,15 @@ mod tests {
let doc = Document::new(PngHandler::new(img));
let any: AnyDocument = doc.into();
assert!(any.as_image().is_some());
assert_eq!(any.document_type(), DocumentType::Png);
assert_eq!(any.document_type(), DocumentType::Image(ImageFormat::Png));
}

#[test]
fn from_wav_handler() {
let doc = Document::new(WavHandler::new(bytes::Bytes::from_static(b"wav")));
let any: AnyDocument = doc.into();
assert!(any.as_audio().is_some());
assert_eq!(any.document_type(), DocumentType::Wav);
assert_eq!(any.document_type(), DocumentType::Audio(AudioFormat::Wav));
}

#[test]
Expand Down
5 changes: 4 additions & 1 deletion crates/nvisy-codec/src/document/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,10 @@ mod tests {
fn document_type_delegates() {
let handler = TxtHandler::new(vec![], false);
let doc = Document::new(handler);
assert_eq!(doc.document_type(), DocumentType::Txt);
assert_eq!(
doc.document_type(),
DocumentType::Text(nvisy_core::fs::TextFormat::Txt),
);
}

#[test]
Expand Down
10 changes: 8 additions & 2 deletions crates/nvisy-codec/src/handler/audio/audio_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ mod tests {
#[tokio::test]
async fn wav_variant_delegates() {
let h = AnyAudio::Wav(WavHandler::new(bytes::Bytes::from_static(b"wav-data")));
assert_eq!(h.document_type(), DocumentType::Wav);
assert_eq!(
h.document_type(),
DocumentType::Audio(nvisy_core::fs::AudioFormat::Wav),
);
let spans: Vec<_> = h.audio_spans().await.collect().await;
assert_eq!(spans.len(), 1);
assert_eq!(spans[0].data.as_bytes().as_ref(), b"wav-data");
Expand All @@ -113,7 +116,10 @@ mod tests {
#[tokio::test]
async fn mp3_variant_delegates() {
let h = AnyAudio::Mp3(Mp3Handler::new(bytes::Bytes::from_static(b"mp3-data")));
assert_eq!(h.document_type(), DocumentType::Mp3);
assert_eq!(
h.document_type(),
DocumentType::Audio(nvisy_core::fs::AudioFormat::Mp3),
);
assert_eq!(h.encode().unwrap().as_bytes(), b"mp3-data");
}

Expand Down
4 changes: 2 additions & 2 deletions crates/nvisy-codec/src/handler/audio/mp3_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use bytes::Bytes;
use futures::StreamExt;
use nvisy_core::Error;
use nvisy_core::fs::DocumentType;
use nvisy_core::fs::{AudioFormat, DocumentType};
use nvisy_core::io::ContentData;
use nvisy_core::path::ContentSource;

Expand Down Expand Up @@ -45,7 +45,7 @@ impl Mp3Handler {

impl Handler for Mp3Handler {
fn document_type(&self) -> DocumentType {
DocumentType::Mp3
DocumentType::Audio(AudioFormat::Mp3)
}

#[tracing::instrument(name = "mp3.encode", skip_all, fields(output_bytes))]
Expand Down
4 changes: 2 additions & 2 deletions crates/nvisy-codec/src/handler/audio/wav_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use bytes::Bytes;
use futures::StreamExt;
use nvisy_core::Error;
use nvisy_core::fs::DocumentType;
use nvisy_core::fs::{AudioFormat, DocumentType};
use nvisy_core::io::ContentData;
use nvisy_core::path::ContentSource;

Expand Down Expand Up @@ -45,7 +45,7 @@ impl WavHandler {

impl Handler for WavHandler {
fn document_type(&self) -> DocumentType {
DocumentType::Wav
DocumentType::Audio(AudioFormat::Wav)
}

#[tracing::instrument(name = "wav.encode", skip_all, fields(output_bytes))]
Expand Down
10 changes: 8 additions & 2 deletions crates/nvisy-codec/src/handler/image/image_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,19 @@ mod tests {
#[test]
fn png_variant_document_type() {
let h = AnyImage::Png(make_png());
assert_eq!(h.document_type(), DocumentType::Png);
assert_eq!(
h.document_type(),
DocumentType::Image(nvisy_core::fs::ImageFormat::Png),
);
}

#[test]
fn jpeg_variant_document_type() {
let h = AnyImage::Jpeg(make_jpeg());
assert_eq!(h.document_type(), DocumentType::Jpeg);
assert_eq!(
h.document_type(),
DocumentType::Image(nvisy_core::fs::ImageFormat::Jpeg),
);
}

#[tokio::test]
Expand Down
2 changes: 1 addition & 1 deletion crates/nvisy-codec/src/handler/image/jpeg_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct JpegHandler {

impl_image_handler!(
JpegHandler,
nvisy_core::fs::DocumentType::Jpeg,
nvisy_core::fs::DocumentType::Image(nvisy_core::fs::ImageFormat::Jpeg),
image::ImageFormat::Jpeg,
"jpeg-handler",
"jpeg.encode"
Expand Down
2 changes: 1 addition & 1 deletion crates/nvisy-codec/src/handler/image/png_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct PngHandler {

impl_image_handler!(
PngHandler,
nvisy_core::fs::DocumentType::Png,
nvisy_core::fs::DocumentType::Image(nvisy_core::fs::ImageFormat::Png),
image::ImageFormat::Png,
"png-handler",
"png.encode"
Expand Down
4 changes: 2 additions & 2 deletions crates/nvisy-codec/src/handler/rich/docx_handler.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! DOCX handler (stub: awaiting migration to full Loader/Handler pattern).

use nvisy_core::Error;
use nvisy_core::fs::DocumentType;
use nvisy_core::fs::{DocumentType, WordFormat};
use nvisy_core::io::ContentData;

use crate::document::{SpanEditStream, SpanStream};
Expand All @@ -14,7 +14,7 @@ pub struct DocxHandler;

impl Handler for DocxHandler {
fn document_type(&self) -> DocumentType {
DocumentType::Docx
DocumentType::Word(WordFormat::Docx)
}

#[tracing::instrument(name = "docx.encode", skip_all)]
Expand Down
4 changes: 2 additions & 2 deletions crates/nvisy-codec/src/handler/text/csv_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

use futures::StreamExt;
use nvisy_core::Error;
use nvisy_core::fs::DocumentType;
use nvisy_core::fs::{DocumentType, SpreadsheetFormat};
use nvisy_core::io::ContentData;
use nvisy_core::path::ContentSource;

Expand Down Expand Up @@ -84,7 +84,7 @@ pub struct CsvHandler {

impl Handler for CsvHandler {
fn document_type(&self) -> DocumentType {
DocumentType::Csv
DocumentType::Spreadsheet(SpreadsheetFormat::Csv)
}

#[tracing::instrument(name = "csv.encode", skip_all, fields(output_bytes))]
Expand Down
4 changes: 2 additions & 2 deletions crates/nvisy-codec/src/handler/text/csv_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ mod tests {
use bytes::Bytes;
use futures::StreamExt;
use nvisy_core::Error;
use nvisy_core::fs::DocumentType;
use nvisy_core::fs::{DocumentType, SpreadsheetFormat};
use nvisy_core::path::ContentSource;

use super::*;
Expand All @@ -151,7 +151,7 @@ mod tests {
let content = content_from_str("name,age\nAlice,30\nBob,25\n");
let doc = CsvLoader.decode(&content, &CsvParams::default()).await?;

assert_eq!(doc.document_type(), DocumentType::Csv);
assert_eq!(doc.document_type(), DocumentType::Spreadsheet(SpreadsheetFormat::Csv));
assert_eq!(
doc.headers(),
Some(["name", "age"].map(String::from).as_slice())
Expand Down
4 changes: 2 additions & 2 deletions crates/nvisy-codec/src/handler/text/json_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use std::num::NonZeroU32;

use futures::StreamExt;
use nvisy_core::Error;
use nvisy_core::fs::DocumentType;
use nvisy_core::fs::{DocumentType, TextFormat};
use nvisy_core::io::ContentData;
use nvisy_core::path::ContentSource;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -127,7 +127,7 @@ pub struct JsonHandler {

impl Handler for JsonHandler {
fn document_type(&self) -> DocumentType {
DocumentType::Json
DocumentType::Text(TextFormat::Json)
}

#[tracing::instrument(name = "json.encode", skip_all, fields(output_bytes))]
Expand Down
4 changes: 2 additions & 2 deletions crates/nvisy-codec/src/handler/text/json_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ fn detect_formatting(source: &str) -> (JsonIndent, bool) {
mod tests {
use bytes::Bytes;
use nvisy_core::Error;
use nvisy_core::fs::DocumentType;
use nvisy_core::fs::{DocumentType, TextFormat};
use nvisy_core::path::ContentSource;
use serde_json::json;

Expand All @@ -109,7 +109,7 @@ mod tests {
let content = content_from_str(r#"{"name": "Alice", "age": 30}"#);
let doc = JsonLoader.decode(&content, &JsonParams::default()).await?;

assert_eq!(doc.document_type(), DocumentType::Json);
assert_eq!(doc.document_type(), DocumentType::Text(TextFormat::Json));
assert_eq!(doc.value(), &json!({"name": "Alice", "age": 30}));
Ok(())
}
Expand Down
Loading