diff options
| author | Ren Kararou <[email protected]> | 2025-11-29 20:17:15 -0600 |
|---|---|---|
| committer | Ren Kararou <[email protected]> | 2025-11-29 20:19:28 -0600 |
| commit | f2558babd9cd64764730a832f837cad3d920fdd7 (patch) | |
| tree | c7f5c0ccf851a312ef67bd7a092d50e3de840d97 | |
| parent | 36a706b7d17bfa332f07ab18b1d3ff30f0aaf6d3 (diff) | |
| download | violet-f2558babd9cd64764730a832f837cad3d920fdd7.tar.gz violet-f2558babd9cd64764730a832f837cad3d920fdd7.tar.bz2 violet-f2558babd9cd64764730a832f837cad3d920fdd7.zip | |
start routing to actually do something useful
| -rw-r--r-- | Cargo.lock | 589 | ||||
| -rw-r--r-- | Cargo.toml | 2 | ||||
| -rw-r--r-- | src/main.rs | 197 |
3 files changed, 744 insertions, 44 deletions
diff --git a/Cargo.lock b/Cargo.lock index 362e32c..e818a4c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,6 +20,24 @@ dependencies = [ ] [[package]] +name = "aligned" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "377e4c0ba83e4431b10df45c1d4666f178ea9c552cac93e60c3a88bf32785923" +dependencies = [ + "as-slice", +] + +[[package]] +name = "aligned-vec" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc890384c8602f339876ded803c97ad529f3842aba97f6392b3dba0dd171769b" +dependencies = [ + "equator", +] + +[[package]] name = "alsa" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -51,6 +69,29 @@ dependencies = [ ] [[package]] +name = "anyhow" +version = "1.0.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" + +[[package]] +name = "arbitrary" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1" + +[[package]] +name = "arg_enum_proc_macro" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] name = "arrayvec" version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -63,6 +104,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b0f477b951e452a0b6b4a10b53ccd569042d1d01729b519e02074a9c0958a063" [[package]] +name = "as-slice" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "516b6b4f0e40d50dcda9365d53964ec74560ad4284da2e7fc97122cd83174516" +dependencies = [ + "stable_deref_trait", +] + +[[package]] name = "async-stream" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -97,12 +147,61 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] +name = "av-scenechange" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f321d77c20e19b92c39e7471cf986812cbb46659d2af674adc4331ef3f18394" +dependencies = [ + "aligned", + "anyhow", + "arg_enum_proc_macro", + "arrayvec", + "log", + "num-rational", + "num-traits", + "pastey", + "rayon", + "thiserror 2.0.17", + "v_frame", + "y4m", +] + +[[package]] +name = "av1-grain" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cfddb07216410377231960af4fcab838eaa12e013417781b78bd95ee22077f8" +dependencies = [ + "anyhow", + "arrayvec", + "log", + "nom 8.0.0", + "num-rational", + "v_frame", +] + +[[package]] +name = "avif-serialize" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47c8fbc0f831f4519fe8b810b6a7a91410ec83031b8233f730a0480029f6a23f" +dependencies = [ + "arrayvec", +] + +[[package]] name = "base64" version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] +name = "bit_field" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e4b40c7323adcfc0a41c4b88143ed58346ff65a288fc144329c5c45e05d70c6" + +[[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -115,6 +214,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" [[package]] +name = "bitstream-io" +version = "4.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60d4bd9d1db2c6bdf285e223a7fa369d5ce98ec767dec949c6ca62863ce61757" +dependencies = [ + "core2", +] + +[[package]] name = "block-buffer" version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -133,6 +241,12 @@ dependencies = [ ] [[package]] +name = "built" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4ad8f11f288f48ca24471bbd51ac257aaeaaa07adae295591266b792902ae64" + +[[package]] name = "bumpalo" version = "3.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -151,6 +265,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fbdf580320f38b612e485521afda1ee26d10cc9884efaaa750d383e13e3c5f4" [[package]] +name = "byteorder-lite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" + +[[package]] name = "bytes" version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -172,6 +292,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd405d82c84ff7f35739f175f67d8b9fb7687a0e84ccdc78bd3568839827cf07" dependencies = [ "find-msvc-tools", + "jobserver", + "libc", "shlex", ] @@ -188,6 +310,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + +[[package]] name = "chrono" version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -211,6 +339,12 @@ dependencies = [ ] [[package]] +name = "color_quant" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" + +[[package]] name = "combine" version = "4.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -259,6 +393,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] +name = "core2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505" +dependencies = [ + "memchr", +] + +[[package]] name = "coreaudio-rs" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -342,6 +485,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] +name = "crunchy" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" + +[[package]] name = "crypto-common" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -352,6 +501,17 @@ dependencies = [ ] [[package]] +name = "daemonize-me" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d7e7dc0363f9af1531fb2d20d257551c971d2da608d37b785901163ca20985f" +dependencies = [ + "libc", + "nix", + "thiserror 2.0.17", +] + +[[package]] name = "dasp_sample" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -469,6 +629,26 @@ dependencies = [ ] [[package]] +name = "equator" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4711b213838dfee0117e3be6ac926007d7f433d7bbe33595975d4190cb07e6fc" +dependencies = [ + "equator-macro", +] + +[[package]] +name = "equator-macro" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44f23cf4b44bfce11a86ace86f8a73ffdec849c9fd00a386a53d278bd9e81fb3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] name = "equivalent" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -507,6 +687,21 @@ dependencies = [ ] [[package]] +name = "exr" +version = "1.74.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4300e043a56aa2cb633c01af81ca8f699a321879a7854d3896a0ba89056363be" +dependencies = [ + "bit_field", + "half", + "lebe", + "miniz_oxide", + "rayon-core", + "smallvec", + "zune-inflate", +] + +[[package]] name = "extended" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -519,6 +714,35 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] +name = "fax" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f05de7d48f37cd6730705cbca900770cab77a89f413d23e100ad7fad7795a0ab" +dependencies = [ + "fax_derive", +] + +[[package]] +name = "fax_derive" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0aca10fb742cb43f9e7bb8467c91aa9bcb8e3ffbc6a6f7389bb93ffc920577d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "fdeflate" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c" +dependencies = [ + "simd-adler32", +] + +[[package]] name = "find-msvc-tools" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -693,6 +917,16 @@ dependencies = [ ] [[package]] +name = "gif" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f954a9e9159ec994f73a30a12b96a702dde78f5547bcb561174597924f7d4162" +dependencies = [ + "color_quant", + "weezl", +] + +[[package]] name = "glob" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -718,6 +952,17 @@ dependencies = [ ] [[package]] +name = "half" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" +dependencies = [ + "cfg-if", + "crunchy", + "zerocopy", +] + +[[package]] name = "hashbrown" version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -991,6 +1236,46 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd62e6b5e86ea8eeeb8db1de02880a6abc01a397b2ebb64b5d74ac255318f5cb" [[package]] +name = "image" +version = "0.25.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6506c6c10786659413faa717ceebcb8f70731c0a60cbae39795fdf114519c1a" +dependencies = [ + "bytemuck", + "byteorder-lite", + "color_quant", + "exr", + "gif", + "image-webp", + "moxcms", + "num-traits", + "png", + "qoi", + "ravif", + "rayon", + "rgb", + "tiff", + "zune-core 0.5.0", + "zune-jpeg 0.5.5", +] + +[[package]] +name = "image-webp" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525e9ff3e1a4be2fbea1fdf0e98686a6d98b4d8f937e1bf7402245af1909e8c3" +dependencies = [ + "byteorder-lite", + "quick-error", +] + +[[package]] +name = "imgref" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c5cedc30da3a610cac6b4ba17597bdf7152cf974e8aab3afb3d54455e371c8" + +[[package]] name = "indexmap" version = "2.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1020,6 +1305,17 @@ dependencies = [ ] [[package]] +name = "interpolate_name" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] name = "ipnet" version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1036,6 +1332,15 @@ dependencies = [ ] [[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + +[[package]] name = "itoa" version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1105,6 +1410,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] +name = "jobserver" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" +dependencies = [ + "getrandom 0.3.4", + "libc", +] + +[[package]] name = "js-sys" version = "0.3.82" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1121,12 +1436,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] +name = "lebe" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a79a3332a6609480d7d0c9eab957bca6b455b91bb84e66d19f5ff66294b85b8" + +[[package]] name = "libc" version = "0.2.177" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" [[package]] +name = "libfuzzer-sys" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5037190e1f70cbeef565bd267599242926f724d3b8a9f510fd7e0b540cfa4404" +dependencies = [ + "arbitrary", + "cc", +] + +[[package]] name = "linux-raw-sys" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1154,6 +1485,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" [[package]] +name = "loop9" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fae87c125b03c1d2c0150c90365d7d6bcc53fb73a9acaef207d2d065860f062" +dependencies = [ + "imgref", +] + +[[package]] name = "lopdf" version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1193,6 +1533,16 @@ dependencies = [ ] [[package]] +name = "maybe-rayon" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519" +dependencies = [ + "cfg-if", + "rayon", +] + +[[package]] name = "md-5" version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1252,6 +1602,16 @@ dependencies = [ ] [[package]] +name = "moxcms" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80986bbbcf925ebd3be54c26613d861255284584501595cf418320c078945608" +dependencies = [ + "num-traits", + "pxfm", +] + +[[package]] name = "native-tls" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1298,6 +1658,24 @@ dependencies = [ ] [[package]] +name = "new_debug_unreachable" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" + +[[package]] +name = "nix" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" +dependencies = [ + "bitflags 2.10.0", + "cfg-if", + "cfg_aliases", + "libc", +] + +[[package]] name = "nom" version = "7.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1328,6 +1706,12 @@ dependencies = [ ] [[package]] +name = "noop_proc_macro" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8" + +[[package]] name = "num-bigint" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1560,6 +1944,18 @@ dependencies = [ ] [[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pastey" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35fb2e5f958ec131621fdd531e9fc186ed768cbe395337403ae56c17a74c68ec" + +[[package]] name = "percent-encoding" version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1604,6 +2000,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" [[package]] +name = "png" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97baced388464909d42d89643fe4361939af9b7ce7a31ee32a168f832a70f2a0" +dependencies = [ + "bitflags 2.10.0", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide", +] + +[[package]] name = "portable-atomic" version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1662,6 +2071,49 @@ dependencies = [ ] [[package]] +name = "profiling" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3eb8486b569e12e2c32ad3e204dbaba5e4b5b216e9367044f25f1dba42341773" +dependencies = [ + "profiling-procmacros", +] + +[[package]] +name = "profiling-procmacros" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52717f9a02b6965224f95ca2a81e2e0c5c43baacd28ca057577988930b6c3d5b" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "pxfm" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3502d6155304a4173a5f2c34b52b7ed0dd085890326cb50fd625fdf39e86b3b" +dependencies = [ + "num-traits", +] + +[[package]] +name = "qoi" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + +[[package]] name = "quote" version = "1.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1712,6 +2164,56 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbbbbea733ec66275512d0b9694f34102e7d5406fdbe2ad8d21b28dce92887c" [[package]] +name = "rav1e" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43b6dd56e85d9483277cde964fd1bdb0428de4fec5ebba7540995639a21cb32b" +dependencies = [ + "aligned-vec", + "arbitrary", + "arg_enum_proc_macro", + "arrayvec", + "av-scenechange", + "av1-grain", + "bitstream-io", + "built", + "cfg-if", + "interpolate_name", + "itertools", + "libc", + "libfuzzer-sys", + "log", + "maybe-rayon", + "new_debug_unreachable", + "noop_proc_macro", + "num-derive", + "num-traits", + "paste", + "profiling", + "rand", + "rand_chacha", + "simd_helpers", + "thiserror 2.0.17", + "v_frame", + "wasm-bindgen", +] + +[[package]] +name = "ravif" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef69c1990ceef18a116855938e74793a5f7496ee907562bd0857b6ac734ab285" +dependencies = [ + "avif-serialize", + "imgref", + "loop9", + "quick-error", + "rav1e", + "rayon", + "rgb", +] + +[[package]] name = "rayon" version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1805,6 +2307,12 @@ dependencies = [ ] [[package]] +name = "rgb" +version = "0.8.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c6a884d2998352bb4daf0183589aec883f16a6da1f4dde84d8e2e9a5409a1ce" + +[[package]] name = "rig-core" version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2115,6 +2623,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" [[package]] +name = "simd_helpers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95890f873bec569a0362c235787f3aca6e1e887302ba4840839bcc6459c42da6" +dependencies = [ + "quote", +] + +[[package]] name = "slab" version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2418,6 +2935,20 @@ dependencies = [ ] [[package]] +name = "tiff" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af9605de7fee8d9551863fd692cce7637f548dbd9db9180fcc07ccc6d26c336f" +dependencies = [ + "fax", + "flate2", + "half", + "quick-error", + "weezl", + "zune-jpeg 0.4.21", +] + +[[package]] name = "time" version = "0.3.44" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2754,6 +3285,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" [[package]] +name = "v_frame" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "666b7727c8875d6ab5db9533418d7c764233ac9c0cff1d469aec8fa127597be2" +dependencies = [ + "aligned-vec", + "num-traits", + "wasm-bindgen", +] + +[[package]] name = "vcpkg" version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2772,6 +3314,8 @@ dependencies = [ "base64", "chrono", "confy", + "daemonize-me", + "image", "reqwest", "rig-core", "rodio", @@ -3268,6 +3812,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" [[package]] +name = "y4m" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5a4b21e1a62b67a2970e6831bc091d7b87e119e7f9791aef9702e3bef04448" + +[[package]] name = "yoke" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3369,3 +3919,42 @@ dependencies = [ "quote", "syn", ] + +[[package]] +name = "zune-core" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f423a2c17029964870cfaabb1f13dfab7d092a62a29a89264f4d36990ca414a" + +[[package]] +name = "zune-core" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "111f7d9820f05fd715df3144e254d6fc02ee4088b0644c0ffd0efc9e6d9d2773" + +[[package]] +name = "zune-inflate" +version = "0.2.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02" +dependencies = [ + "simd-adler32", +] + +[[package]] +name = "zune-jpeg" +version = "0.4.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29ce2c8a9384ad323cf564b67da86e21d3cfdff87908bc1223ed5c99bc792713" +dependencies = [ + "zune-core 0.4.12", +] + +[[package]] +name = "zune-jpeg" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc6fb7703e32e9a07fb3f757360338b3a567a5054f21b5f52a666752e333d58e" +dependencies = [ + "zune-core 0.5.0", +] diff --git a/Cargo.toml b/Cargo.toml index b62bd62..ab46252 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,8 @@ publish = ["crates-io"] base64 = "0.22.1" chrono = "0.4.42" confy = "2.0.0" +daemonize-me = "2.0.2" +image = "0.25.9" reqwest = "0.12.24" rig-core = { version = "0.24.0", features = ["all", "audio"] } rodio = "0.21.1" diff --git a/src/main.rs b/src/main.rs index 7a436e7..4dbb9cf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,16 +1,20 @@ -//use base64::{Engine, engine::general_purpose::STANDARD}; +use base64::{Engine, engine::general_purpose::STANDARD}; use chrono::Utc; -use reqwest::ClientBuilder; +use reqwest::{Client, ClientBuilder}; use rig::{ - agent::stream_to_stdout, + agent::{Agent, stream_to_stdout}, audio_generation::AudioGenerationModel, client::audio_generation::AudioGenerationClient, - message::{DocumentSourceKind, Image, ImageDetail, ImageMediaType, Message}, + completion::Chat, + message::{ + AssistantContent, DocumentSourceKind, Image, ImageDetail, ImageMediaType, + Message, UserContent, + }, prelude::*, providers::openai, + providers::openai::CompletionModel, streaming::StreamingChat, }; -use rodio::Decoder; use serde::{Deserialize, Serialize}; use serde_json::json; use std::io::{Cursor, Write}; @@ -20,28 +24,40 @@ use std::time::Duration; struct Config { base_url: String, key: String, - model: String, + timeout: u64, + #[serde(skip_serializing_if = "Option::is_none")] + vision_model: Option<String>, + #[serde(skip_serializing_if = "Option::is_none")] + vision_prompt: Option<String>, + #[serde(skip_serializing_if = "Option::is_none")] + summary_model: Option<String>, + #[serde(skip_serializing_if = "Option::is_none")] + summary_prompt: Option<String>, #[serde(skip_serializing_if = "Option::is_none")] audio_model: Option<String>, #[serde(skip_serializing_if = "Option::is_none")] audio_voice: Option<String>, - system_prompt: String, - timeout: u64, - max_tokens: u64, - temp: f64, + vision_tokens: u64, + vision_temp: f64, + summary_tokens: u64, + summary_temp: f64, } impl std::default::Default for Config { fn default() -> Self { Self { base_url: String::from("https://api.openai.com/v1"), key: String::from("sk-..."), - model: String::from("gpt-4o"), + vision_model: None, + vision_prompt: None, + summary_prompt: None, + summary_model: None, audio_model: None, audio_voice: None, - system_prompt: String::from("You are a helpful assistant!"), timeout: 30, - max_tokens: 4096, - temp: 0.4, + vision_tokens: 4096, + vision_temp: 0.4, + summary_tokens: 8192, + summary_temp: 0.9, } } } @@ -53,7 +69,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { let config: Config = confy::load("violet", Some("violet"))?; println!( "Config file location: {}", - confy::get_configuration_file_path("violet", None)? + confy::get_configuration_file_path("violet", Some("violet"))? .as_path() .to_str() .unwrap_or("path does not exist") @@ -72,19 +88,50 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { .connect_timeout(Duration::from_secs(conn_timeout)) .build()?; let date: String = Utc::now().date_naive().to_string(); - let system_prompt: String = - format!("The current date is {date}.\n\n{}", &config.system_prompt); - eprintln!("System Prompt is: {system_prompt}"); + let vision_prompt: String = if let Some(prompt) = config.vision_prompt { + prompt + } else { + "You will describe the images attached".into() + }; + let summary_prompt: String = format!( + "The current date is {date}.\n\n{}", + if let Some(prompt) = config.summary_prompt { + prompt + } else { + String::from("You will create a narrative for the image ") + + "descriptions given as if you were telling a story." + } + ); + eprintln!("Vision System Prompt is: {vision_prompt}"); + eprintln!("Summary System Prompt is: {summary_prompt}"); let api = openai::ClientBuilder::new_with_client(&config.key, http_client) .base_url(&config.base_url) .build(); - let violet = api - .completion_model(&config.model) + let vision_model: String = if let Some(vmodel) = config.vision_model { + vmodel + } else { + "gpt-image-1".into() + }; + let vision = api + .completion_model(&vision_model) + .completions_api() + .into_agent_builder() + .preamble(&vision_prompt) + .max_tokens(config.vision_tokens) + .temperature(config.vision_temp) + .build(); + let summary_model: String = if let Some(smodel) = config.summary_model { + smodel + } else { + "gpt-4o".into() + }; + let summary = api + .completion_model(&summary_model) .completions_api() .into_agent_builder() - .preamble(&system_prompt) - .max_tokens(config.max_tokens) - .temperature(config.temp) + .preamble(&summary_prompt) + .max_tokens(config.summary_tokens) + .temperature(config.summary_temp) .build(); let audio_model = if let Some(model) = &config.audio_model { model @@ -96,13 +143,16 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { } else { "alloy" }; - let violet_voice = api.audio_generation_model(audio_model); - eprintln!("Base Request Setup"); - let mut history: Vec<Message> = Vec::new(); - eprintln!("Getting Audio Device"); - let stream_handle = rodio::OutputStreamBuilder::open_default_stream()?; - let _sink = rodio::Sink::connect_new(&stream_handle.mixer()); + let audio = api.audio_generation_model(audio_model); eprintln!("Setup Finished"); + routing(vision, summary, audio, audio_voice).await?; + Ok(()) +} + +async fn chat( + agent: Agent<CompletionModel<Client>>, +) -> Result<Vec<Message>, Box<dyn std::error::Error>> { + let mut history: Vec<Message> = Vec::new(); let mut s = String::new(); print!("> "); let _ = std::io::stdout().flush(); @@ -114,22 +164,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { uwu = false; } while uwu { - let mut stream = violet.stream_chat(&s, history.clone()).await; + let mut stream = agent.stream_chat(&s, history.clone()).await; let res = stream_to_stdout(&mut stream).await?; print!("\n"); - let vres = violet_voice - .audio_generation_request() - .text(res.response()) - .voice(&audio_voice) - .additional_params(json!( - { - "response_format": "mp3", - } - )) - .send() - .await?; - let vdata = Decoder::new(Cursor::new(vres.audio.clone()))?; - stream_handle.mixer().add(vdata); history.push(Message::user(s.clone())); history.push(Message::assistant(res.response())); print!("> "); @@ -139,8 +176,80 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { eprintln!("Error reading stdin: {e}"); } if s.as_str().to_lowercase().trim() == "stop" { - break; + uwu = false; } } + Ok(history) +} + +async fn prompt_model( + agent: Agent<CompletionModel<Client>>, + prompt: Message, + history: Vec<Message>, +) -> Result<Message, Box<dyn std::error::Error>> { + let res = agent.chat(prompt, history).await?; + Ok(rig::message::AssistantContent::text(&res).into()) +} + +async fn get_audio( + audio: openai::audio_generation::AudioGenerationModel, + voice: &str, + text: &str, +) -> Result<Vec<u8>, Box<dyn std::error::Error>> { + let vres = audio + .audio_generation_request() + .text(text) + .voice(voice) + .additional_params(json!( + { + "response_format": "mp3", + } + )) + .send() + .await?; + Ok(vres.audio.clone()) +} + +async fn routing( + vision: Agent<CompletionModel<Client>>, + summary: Agent<CompletionModel<Client>>, + audio: openai::audio_generation::AudioGenerationModel, + audio_voice: &str, +) -> Result<(), Box<dyn std::error::Error>> { + let _vision = vision; + let mut s: String = String::new(); + for m in chat(summary).await? { + let text: String = match m { + Message::User { content } => { + let mut e: String = "User: ".into(); + for c in content { + if let UserContent::Text(content) = c { + e = e + content.text().into(); + e = e + "\n".into(); + } + } + e + }, + Message::Assistant { id, content } => { + let _id = id; + let mut e: String = "Assistant: ".into(); + for c in content { + if let AssistantContent::Text(content) = c { + e = e + content.text().into(); + e = e + "\n".into(); + } + } + e + }, + }; + s = s + &text; + } + let e = get_audio(audio, audio_voice, &s).await?; + let mut fiel = std::fs::OpenOptions::new() + .create(true) + .write(true) + .truncate(true) + .open("chat.mp3")?; + fiel.write_all(&e.as_slice())?; Ok(()) } |
