diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3261bb0..375d771 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,10 +15,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - with: - targets: wasm32-unknown-unknown - - uses: Swatinem/rust-cache@v2 + - name: Install Toolchain + run: rustup update stable && rustup default stable + - uses: taiki-e/install-action@sccache - uses: taiki-e/install-action@nextest - name: Run Tests @@ -29,9 +28,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: arduino/setup-protoc@v3 - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 + - name: Install Toolchain + run: | + rustup update stable && rustup default stable + rustup component add clippy rustfmt + - uses: taiki-e/install-action@sccache - name: Format run: cargo fmt --check - name: Clippy diff --git a/Cargo.lock b/Cargo.lock index 87e1539..bdda13c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -303,7 +303,7 @@ dependencies = [ "candle-core", "candle-nn", "candle-transformers", - "cydonia-core", + "cydonia-model", "hf-hub", "rand", "serde", @@ -311,21 +311,12 @@ dependencies = [ "tracing", ] -[[package]] -name = "cydonia-core" -version = "0.0.0" -dependencies = [ - "anyhow", - "serde", - "tracing", -] - [[package]] name = "cydonia-model" version = "0.0.0" dependencies = [ "anyhow", - "cydonia-candle", + "serde", "tracing", ] @@ -900,10 +891,6 @@ version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" -[[package]] -name = "hub" -version = "0.1.0" - [[package]] name = "hyper" version = "1.5.2" diff --git a/Cargo.toml b/Cargo.toml index 5f1146c..a739933 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,25 +1,42 @@ [workspace] -resolver = "2" -members = ["crates/*"] +resolver = "3" +members = ["legacy/*"] + +[workspace.package] +version = "0.0.9" +edition = "2024" +authors = ["clearloop "] +license = "MIT" +repository = "https://github.com/clearloop/cydonia" [workspace.dependencies] -ccore = { path = "crates/core", package = "cydonia-core" } +model = { path = "legacy/model", package = "cydonia-model" } candle = { path = "crates/candle", package = "cydonia-candle" } # crates.io anyhow = "1" +async-stream = "0.3" +bytes = "1.11.0" +clap = { version = "4.5", features = ["derive"] } +derive_more = { version = "2.1", features = ["display", "try_from"] } +dirs = "6" +futures-core = "0.3" +futures-util = "0.3" +reqwest = { version = "0.12", features = ["json", "stream"] } +schemars = "1.1.0" +serde = { version = "1", features = ["derive"] } +serde_json = "1" +tokio = { version = "1", features = ["rt-multi-thread", "macros"] } +toml = "0.9.8" +tracing = "0.1" +tracing-subscriber = { version = "0.3", features = ["env-filter"] } + +# legacy dependencies candle-core = "0.8.1" candle-nn = "0.8.1" candle-transformers = "0.8.1" -clap = "4.5.23" -dirs = "5.0.1" hf-hub = "0.4.1" llamac-sys = { version = "0.1.86", package = "llama-cpp-sys-2" } -once_cell = "1.20.2" +once_cell = "1.21" rand = "0.8.5" -serde = "1.0.217" -serde_json = "1.0.134" tokenizers = "0.21.0" -toml = "0.8.19" -tracing = "0.1.41" -tracing-subscriber = "0.3.19" diff --git a/README.md b/README.md index 062a5b0..210c98f 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,3 @@ # Cydonia -Cydonia is a library based on [candle][candle] for developing modern AI applications in rust. - -```rust -use cydonia::Model; - -fn main() { - let model = Model::new("gemma2").tag("latest"); - let response = model.invoke("Hello, world!"); - println!("{}", response); -} -``` - -We support quantized models only derived from `gemma` and `llama` family. - -## TODOs - -- [x] Support chat interface ( history prompts ) -- [ ] Function encoder for llama3 tools (static) -- [ ] Cydonia as service - - [ ] RPC support for llama3 tools (remote) - - [ ] GraphQL support for llama3 tools (remote) -- [ ] RAG support -- [ ] Agent interface -- [ ] Multi-agent support (single-node) -- [ ] An application based on the tools -- [ ] p2p for the decentralized cydonia network (multi-node) -- [ ] Test gpu - - - -[candle]: https://github.com/huggingface/candle +The Agent framework. diff --git a/crates/model/Cargo.toml b/crates/model/Cargo.toml deleted file mode 100644 index ee3d946..0000000 --- a/crates/model/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "cydonia-model" -version = "0.0.0" -edition = "2021" -description = "Cydonia Models" - -[dependencies] -anyhow.workspace = true -candle.workspace = true -tracing.workspace = true diff --git a/crates/model/src/lib.rs b/crates/model/src/lib.rs deleted file mode 100644 index 1070731..0000000 --- a/crates/model/src/lib.rs +++ /dev/null @@ -1,3 +0,0 @@ -//! LLM interfaces - -pub use candle::Llama; diff --git a/crates/registry/Cargo.toml b/crates/registry/Cargo.toml deleted file mode 100644 index 0f84d6f..0000000 --- a/crates/registry/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "hub" -version = "0.1.0" -edition = "2021" - -[dependencies] diff --git a/crates/registry/models.toml b/crates/registry/models.toml deleted file mode 100644 index 4fe22db..0000000 --- a/crates/registry/models.toml +++ /dev/null @@ -1,29 +0,0 @@ -# Supported Models by Default -# -# Since we currently don't have a way to download models from the internet, -# we only support predefined models in the following. - -family = ["gemma", "llama"] - -[gemma.gemma] -description = "Gemma from Google DeepMind" -family = "gemma" - -[gemma.gemma2] -description = "Gemma2 from Google DeepMind" -tags = ["latest", "2b-instruct-q4_K_S", "2b-instruct-q4_K_S_v2"] - -[llama] -description = "Llama family developed by Meta" - -[llama.llama3] -description = "Llama3 from Llama" - -[llama.llama3.1] -description = "Llama3.1 from Llama" - -[llama.llama3.2] -description = "Llama3.2 from Llama" - -[llama.llama3.3] -description = "Llama3.3 from Llama" diff --git a/crates/registry/src/main.rs b/crates/registry/src/main.rs deleted file mode 100644 index e7a11a9..0000000 --- a/crates/registry/src/main.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - println!("Hello, world!"); -} diff --git a/crates/candle/Cargo.toml b/legacy/candle/Cargo.toml similarity index 97% rename from crates/candle/Cargo.toml rename to legacy/candle/Cargo.toml index 8a93a75..8139948 100644 --- a/crates/candle/Cargo.toml +++ b/legacy/candle/Cargo.toml @@ -9,7 +9,7 @@ anyhow.workspace = true candle-core.workspace = true candle-nn.workspace = true candle-transformers.workspace = true -ccore.workspace = true +model.workspace = true hf-hub.workspace = true rand.workspace = true serde.workspace = true diff --git a/crates/candle/examples/llama.rs b/legacy/candle/examples/llama.rs similarity index 96% rename from crates/candle/examples/llama.rs rename to legacy/candle/examples/llama.rs index 41288fd..1556d77 100644 --- a/crates/candle/examples/llama.rs +++ b/legacy/candle/examples/llama.rs @@ -1,5 +1,5 @@ -use ccore::{Message, Release}; use cydonia_candle::{Llama, ProcessorConfig}; +use model::{Message, Release}; use std::io::Write; fn main() { diff --git a/crates/candle/src/device.rs b/legacy/candle/src/device.rs similarity index 100% rename from crates/candle/src/device.rs rename to legacy/candle/src/device.rs diff --git a/crates/candle/src/inference.rs b/legacy/candle/src/inference.rs similarity index 98% rename from crates/candle/src/inference.rs rename to legacy/candle/src/inference.rs index 9075b32..0e34efd 100644 --- a/crates/candle/src/inference.rs +++ b/legacy/candle/src/inference.rs @@ -2,7 +2,7 @@ use anyhow::Result; use candle_core::{quantized::gguf_file::Content, Device, Tensor}; use candle_transformers::models::quantized_llama; -use ccore::{chat, Message}; +use model::{chat, Message}; use std::fs::File; /// The inference interface for language models diff --git a/crates/candle/src/lib.rs b/legacy/candle/src/lib.rs similarity index 100% rename from crates/candle/src/lib.rs rename to legacy/candle/src/lib.rs diff --git a/crates/candle/src/loader.rs b/legacy/candle/src/loader.rs similarity index 97% rename from crates/candle/src/loader.rs rename to legacy/candle/src/loader.rs index 1903072..7e62f8f 100644 --- a/crates/candle/src/loader.rs +++ b/legacy/candle/src/loader.rs @@ -3,8 +3,8 @@ use crate::{Inference, Tokenizer}; use anyhow::Result; use candle_core::Device; -use ccore::{Release, TOKENIZER}; use hf_hub::api::sync::Api; +use model::{Release, TOKENIZER}; use std::fs::File; /// Huggingface model loader diff --git a/crates/candle/src/model.rs b/legacy/candle/src/model.rs similarity index 97% rename from crates/candle/src/model.rs rename to legacy/candle/src/model.rs index c2d45ba..887de62 100644 --- a/crates/candle/src/model.rs +++ b/legacy/candle/src/model.rs @@ -2,7 +2,7 @@ use crate::{Inference, Loader, Processor, ProcessorConfig, TokenStream, Tokenizer}; use anyhow::Result; -use ccore::{Message, Release}; +use model::{Message, Release}; /// Language Model interface pub struct Model { diff --git a/crates/candle/src/processor/config.rs b/legacy/candle/src/processor/config.rs similarity index 100% rename from crates/candle/src/processor/config.rs rename to legacy/candle/src/processor/config.rs diff --git a/crates/candle/src/processor/mod.rs b/legacy/candle/src/processor/mod.rs similarity index 100% rename from crates/candle/src/processor/mod.rs rename to legacy/candle/src/processor/mod.rs diff --git a/crates/candle/src/processor/sample.rs b/legacy/candle/src/processor/sample.rs similarity index 100% rename from crates/candle/src/processor/sample.rs rename to legacy/candle/src/processor/sample.rs diff --git a/crates/candle/src/token/mod.rs b/legacy/candle/src/token/mod.rs similarity index 100% rename from crates/candle/src/token/mod.rs rename to legacy/candle/src/token/mod.rs diff --git a/crates/candle/src/token/prompt.rs b/legacy/candle/src/token/prompt.rs similarity index 100% rename from crates/candle/src/token/prompt.rs rename to legacy/candle/src/token/prompt.rs diff --git a/crates/candle/src/token/stream.rs b/legacy/candle/src/token/stream.rs similarity index 100% rename from crates/candle/src/token/stream.rs rename to legacy/candle/src/token/stream.rs diff --git a/crates/core/Cargo.toml b/legacy/model/Cargo.toml similarity index 85% rename from crates/core/Cargo.toml rename to legacy/model/Cargo.toml index 3a9a579..fe22c22 100644 --- a/crates/core/Cargo.toml +++ b/legacy/model/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "cydonia-core" +name = "cydonia-model" version = "0.0.0" edition = "2021" diff --git a/legacy/model/README.md b/legacy/model/README.md new file mode 100644 index 0000000..a5b29af --- /dev/null +++ b/legacy/model/README.md @@ -0,0 +1 @@ +This crate is currently outdated. diff --git a/crates/core/src/chat/llama.rs b/legacy/model/src/chat/llama.rs similarity index 100% rename from crates/core/src/chat/llama.rs rename to legacy/model/src/chat/llama.rs diff --git a/crates/core/src/chat/mod.rs b/legacy/model/src/chat/mod.rs similarity index 100% rename from crates/core/src/chat/mod.rs rename to legacy/model/src/chat/mod.rs diff --git a/crates/core/src/lib.rs b/legacy/model/src/lib.rs similarity index 100% rename from crates/core/src/lib.rs rename to legacy/model/src/lib.rs diff --git a/crates/core/src/manifest/family.rs b/legacy/model/src/manifest/family.rs similarity index 100% rename from crates/core/src/manifest/family.rs rename to legacy/model/src/manifest/family.rs diff --git a/crates/core/src/manifest/mod.rs b/legacy/model/src/manifest/mod.rs similarity index 100% rename from crates/core/src/manifest/mod.rs rename to legacy/model/src/manifest/mod.rs diff --git a/crates/core/src/manifest/quant.rs b/legacy/model/src/manifest/quant.rs similarity index 100% rename from crates/core/src/manifest/quant.rs rename to legacy/model/src/manifest/quant.rs diff --git a/crates/core/src/manifest/release.rs b/legacy/model/src/manifest/release.rs similarity index 100% rename from crates/core/src/manifest/release.rs rename to legacy/model/src/manifest/release.rs