diff --git a/Cargo.lock b/Cargo.lock index 89eb0def..11f353a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -204,9 +204,9 @@ checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" [[package]] name = "chacha20" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d524456ba66e72eb8b115ff89e01e497f8e6d11d78b70b1aa13c0fbd97540a81" +checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" dependencies = [ "cfg-if", "cpufeatures 0.3.0", @@ -1436,9 +1436,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.43" +version = "0.23.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0283386ce02abc0151e1761d08802dfe86c173b0b494af5cbc086574e453da06" +checksum = "0d41d731c7d2f962d1ccc364cec258de3c0e93b38c2fb3ba97ac74513048d634" dependencies = [ "once_cell", "ring", @@ -1460,9 +1460,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.103.13" +version = "0.103.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e" +checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2" dependencies = [ "ring", "rustls-pki-types", @@ -1740,7 +1740,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", - "getrandom 0.3.4", + "getrandom 0.4.3", "once_cell", "rustix", "windows-sys 0.61.2", @@ -1793,7 +1793,8 @@ dependencies = [ "sha2 0.10.9", "thiserror", "tinycortex-api", - "tinyinference", + "tinyinference-embeddings", + "tinyinference-llm", "tokio", "toml", "tracing", @@ -1809,19 +1810,45 @@ dependencies = [ ] [[package]] -name = "tinyinference" +name = "tinyinference-core" +version = "0.2.1" +dependencies = [ + "anyhow", + "httpdate", + "url", +] + +[[package]] +name = "tinyinference-embeddings" +version = "0.2.1" +dependencies = [ + "async-trait", + "reqwest", + "serde", + "serde_json", + "thiserror", + "tinyinference-core", + "tokio", + "tracing", + "url", +] + +[[package]] +name = "tinyinference-llm" version = "0.2.1" dependencies = [ "async-trait", "bytes", "futures", - "httpdate", "reqwest", "serde", "serde_json", "sha2 0.11.0", "thiserror", + "tinyinference-core", "tokio", + "tracing", + "url", ] [[package]] @@ -1906,7 +1933,8 @@ dependencies = [ "thiserror", "tinycortex", "tinycortex-api", - "tinyinference", + "tinyinference-embeddings", + "tinyinference-llm", "tinymemory", "tinymemory-api", "tinymemory-conformance", diff --git a/Cargo.toml b/Cargo.toml index 64aee772..eef04fb2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -78,7 +78,9 @@ tinymemory-api = { path = "crates/tinymemory-api" } # source onto the same checkout `tinymemory-core` resolves through crates.io so # both crates share one trait identity. [patch."https://github.com/tinyhumansai/tinyinference"] -tinyinference = { path = "vendor/tinyinference/crates/tinyinference" } +tinyinference-core = { path = "vendor/tinyinference/crates/tinyinference-core" } +tinyinference-embeddings = { path = "vendor/tinyinference/crates/tinyinference-embeddings" } +tinyinference-llm = { path = "vendor/tinyinference/crates/tinyinference-llm" } [patch.crates-io] tinycortex = { path = "vendor/tinycortex" } @@ -86,7 +88,9 @@ tinycortex-api = { path = "vendor/tinycortex/api" } # `tinymemory-core` names the provider-neutral chat and embedding contracts # from TinyInference. It is not published, so standalone builds resolve the # version requirement to the pinned checkout here. -tinyinference = { path = "vendor/tinyinference/crates/tinyinference" } +tinyinference-core = { path = "vendor/tinyinference/crates/tinyinference-core" } +tinyinference-embeddings = { path = "vendor/tinyinference/crates/tinyinference-embeddings" } +tinyinference-llm = { path = "vendor/tinyinference/crates/tinyinference-llm" } [profile.release] # Cross-crate optimization and smaller, faster binaries for release builds. diff --git a/crates/tinymemory-core/Cargo.toml b/crates/tinymemory-core/Cargo.toml index d9840c09..3f399d93 100644 --- a/crates/tinymemory-core/Cargo.toml +++ b/crates/tinymemory-core/Cargo.toml @@ -40,7 +40,8 @@ tinycortex-api = { version = "0.1" } # Provider-neutral chat-model and embedding primitives used by the tree # summarizer and embedding factory. Agent runtime and session behavior do not # belong in the memory layer. -tinyinference = "0.2" +tinyinference-embeddings = "0.2" +tinyinference-llm = "0.2" anyhow = "1.0" async-trait = "0.1" # NO `git2` HERE, DELIBERATELY — do not add it back. `diff/` holds the ops and diff --git a/crates/tinymemory-core/src/chat.rs b/crates/tinymemory-core/src/chat.rs index ae3137ce..bb20ee7f 100644 --- a/crates/tinymemory-core/src/chat.rs +++ b/crates/tinymemory-core/src/chat.rs @@ -13,8 +13,8 @@ use async_trait::async_trait; use crate::chat_host::{create_chat_model_with_model_id, provider_for_role, UsageInfo}; use crate::Config; -use tinyinference::message::Message; -use tinyinference::model::{ChatModel, ModelRequest}; +use tinyinference_llm::message::Message; +use tinyinference_llm::model::{ChatModel, ModelRequest}; /// One pair of prompt messages handed to the memory LLM backend. #[derive(Debug, Clone)] diff --git a/crates/tinymemory-core/src/chat_host.rs b/crates/tinymemory-core/src/chat_host.rs index 076779f4..f82912b3 100644 --- a/crates/tinymemory-core/src/chat_host.rs +++ b/crates/tinymemory-core/src/chat_host.rs @@ -8,7 +8,7 @@ //! //! # Why this trait is here and not in `tinymemory-api` //! -//! It names [`tinyinference::model::ChatModel`], and the contract crate is +//! It names [`tinyinference_llm::model::ChatModel`], and the contract crate is //! deliberately dependency-light — it must not pull in an inference SDK. This //! crate already depends on TinyInference, so it is the one place that can name //! both the model trait and the config seam. The host implements it here. @@ -20,7 +20,7 @@ use std::sync::Arc; use parking_lot::RwLock; -use tinyinference::model::{ChatModel, ModelResponse}; +use tinyinference_llm::model::{ChatModel, ModelResponse}; use crate::Config; diff --git a/crates/tinymemory-core/src/embedding_adapter.rs b/crates/tinymemory-core/src/embedding_adapter.rs index 037f33c2..a9497a80 100644 --- a/crates/tinymemory-core/src/embedding_adapter.rs +++ b/crates/tinymemory-core/src/embedding_adapter.rs @@ -2,14 +2,14 @@ //! model trait onto the seam's [`EmbeddingProvider`]. //! //! It lives in this crate rather than in `tinymemory-api` because the contract -//! crate must stay dependency-light and cannot name `tinyinference`; and rather +//! crate must stay dependency-light and cannot name `tinyinference-llm`; and rather //! than in the host because the tree's embedder factory — which is core code — //! builds Ollama models directly and needs to wrap them. The host re-exports it //! from `inference::embeddings`, so every existing path there keeps resolving //! and keeps naming this one type. use async_trait::async_trait; -use tinyinference::embeddings::EmbeddingModel; +use tinyinference_embeddings::EmbeddingModel; pub use tinymemory_api::host::{format_embedding_signature, EmbeddingProvider}; diff --git a/crates/tinymemory-core/src/store/factories.rs b/crates/tinymemory-core/src/store/factories.rs index 9272bde3..827447aa 100644 --- a/crates/tinymemory-core/src/store/factories.rs +++ b/crates/tinymemory-core/src/store/factories.rs @@ -18,7 +18,7 @@ use rusqlite::Connection; use crate::embedding_host::require_embedding_host; use crate::store::namespace_store::UnifiedMemory; use crate::traits::Memory; -use tinyinference::embeddings::{DEFAULT_OLLAMA_DIMENSIONS, DEFAULT_OLLAMA_MODEL}; +use tinyinference_embeddings::{DEFAULT_OLLAMA_DIMENSIONS, DEFAULT_OLLAMA_MODEL}; use tinymemory_api::host::MemoryConfig; use tinymemory_api::host::{format_embedding_signature, EmbeddingProvider}; use tinymemory_api::host::{EmbeddingRouteConfig, StorageProviderConfig}; diff --git a/crates/tinymemory-core/src/store/factories_tests.rs b/crates/tinymemory-core/src/store/factories_tests.rs index f3a993aa..44fa0940 100644 --- a/crates/tinymemory-core/src/store/factories_tests.rs +++ b/crates/tinymemory-core/src/store/factories_tests.rs @@ -91,7 +91,7 @@ fn embedding_settings_local_overrides_memory_config() { assert_eq!(model, "nomic-embed-text:latest"); assert_eq!( dims, - tinyinference::embeddings::DEFAULT_OLLAMA_DIMENSIONS, + tinyinference_embeddings::DEFAULT_OLLAMA_DIMENSIONS, "dimensions must default to Ollama default" ); } @@ -105,10 +105,10 @@ fn embedding_settings_local_with_empty_model_uses_default() { assert_eq!(provider, "ollama"); assert_eq!( model, - tinyinference::embeddings::DEFAULT_OLLAMA_MODEL, + tinyinference_embeddings::DEFAULT_OLLAMA_MODEL, "empty model ID must fall back to default Ollama model" ); - assert_eq!(dims, tinyinference::embeddings::DEFAULT_OLLAMA_DIMENSIONS); + assert_eq!(dims, tinyinference_embeddings::DEFAULT_OLLAMA_DIMENSIONS); } #[test] @@ -223,7 +223,7 @@ async fn start_mock_ollama() -> String { /// the legacy `local_ai.usage.embeddings = true` flag was set. Used so /// the existing test scenarios continue to drive the local code path. fn local_embedding_for_test() -> &'static str { - tinyinference::embeddings::DEFAULT_OLLAMA_MODEL + tinyinference_embeddings::DEFAULT_OLLAMA_MODEL } #[tokio::test] diff --git a/crates/tinymemory-core/src/test_seams.rs b/crates/tinymemory-core/src/test_seams.rs index 6f6defad..8d9ace53 100644 --- a/crates/tinymemory-core/src/test_seams.rs +++ b/crates/tinymemory-core/src/test_seams.rs @@ -72,13 +72,13 @@ impl crate::chat_host::ChatHost for TestChatHost { _role: &str, _config: &Config, _temperature: f64, - ) -> Result<(Arc>, String), String> { + ) -> Result<(Arc>, String), String> { Err("TestChatHost does not build models — model routing is host behaviour".to_string()) } fn usage_from_response( &self, - _response: &tinyinference::model::ModelResponse, + _response: &tinyinference_llm::model::ModelResponse, ) -> Option { None } diff --git a/crates/tinymemory-core/src/tree/score/embed/factory.rs b/crates/tinymemory-core/src/tree/score/embed/factory.rs index 72aa74e5..87e52119 100644 --- a/crates/tinymemory-core/src/tree/score/embed/factory.rs +++ b/crates/tinymemory-core/src/tree/score/embed/factory.rs @@ -39,7 +39,7 @@ use tinymemory_api::host::test_support::TestHostConfig; use super::{Embedder, InertEmbedder, ProviderEmbedder, EMBEDDING_DIM}; use crate::embedding_host::require_embedding_host; use crate::Config; -use tinyinference::embeddings::{OllamaEmbeddingModel, RECOMMENDED_OLLAMA_CONTEXT_TOKENS}; +use tinyinference_embeddings::{OllamaEmbeddingModel, RECOMMENDED_OLLAMA_CONTEXT_TOKENS}; /// Cheap heuristic for "is a backend session reachable?" — the cloud /// embedder needs one and bails on first embed call without it. We use diff --git a/crates/tinymemory-core/src/tree/score/embed/mod.rs b/crates/tinymemory-core/src/tree/score/embed/mod.rs index 56cc6b75..3e5b2061 100644 --- a/crates/tinymemory-core/src/tree/score/embed/mod.rs +++ b/crates/tinymemory-core/src/tree/score/embed/mod.rs @@ -87,7 +87,7 @@ pub trait Embedder: Send + Sync { /// Adapts the canonical host embedding-provider contract to the legacy /// memory-tree embedder shape. Concrete network implementations live in -/// `tinyinference::embeddings`; this bridge owns only dimension checks +/// `tinyinference_llm::embeddings`; this bridge owns only dimension checks /// and the memory tree's per-position batch fallback contract. pub struct ProviderEmbedder { inner: Box, diff --git a/crates/tinymemory-core/src/tree/tree_runtime/engine.rs b/crates/tinymemory-core/src/tree/tree_runtime/engine.rs index 6d00d3f2..1c4c0b37 100644 --- a/crates/tinymemory-core/src/tree/tree_runtime/engine.rs +++ b/crates/tinymemory-core/src/tree/tree_runtime/engine.rs @@ -8,8 +8,8 @@ use crate::engine::backend::tree::runtime::{ use anyhow::{Context, Result}; use async_trait::async_trait; use chrono::{DateTime, Timelike, Utc}; -use tinyinference::message::Message; -use tinyinference::model::{ChatModel, ModelRequest}; +use tinyinference_llm::message::Message; +use tinyinference_llm::model::{ChatModel, ModelRequest}; use crate::engine::engine_config; use crate::Config; diff --git a/crates/tinymemory-core/src/tree/tree_runtime/engine_tests.rs b/crates/tinymemory-core/src/tree/tree_runtime/engine_tests.rs index 54691fe6..3853f002 100644 --- a/crates/tinymemory-core/src/tree/tree_runtime/engine_tests.rs +++ b/crates/tinymemory-core/src/tree/tree_runtime/engine_tests.rs @@ -5,7 +5,7 @@ use crate::tree::tree_runtime::store; use chrono::TimeZone; use std::sync::Mutex; use tempfile::TempDir; -use tinyinference::model::ModelResponse; +use tinyinference_llm::model::ModelResponse; use tinymemory_api::host::test_support::TestHostConfig; struct RecordingModel { @@ -28,11 +28,11 @@ impl ChatModel<()> for RecordingModel { &self, _state: &(), request: ModelRequest, - ) -> tinyinference::Result { + ) -> tinyinference_llm::Result { self.requests.lock().unwrap().push(request); match &self.reply { Ok(reply) => Ok(ModelResponse::assistant(reply.clone())), - Err(message) => Err(tinyinference::Error::Model(message.clone())), + Err(message) => Err(tinyinference_llm::Error::Model(message.clone())), } } } diff --git a/crates/tinymemory-module/Cargo.lock b/crates/tinymemory-module/Cargo.lock index d8f83c79..3ef19b21 100644 --- a/crates/tinymemory-module/Cargo.lock +++ b/crates/tinymemory-module/Cargo.lock @@ -1762,7 +1762,8 @@ dependencies = [ "sha2 0.10.9", "thiserror", "tinycortex-api", - "tinyinference", + "tinyinference-embeddings", + "tinyinference-llm", "tokio", "toml 1.1.4+spec-1.1.0", "tracing", @@ -1778,19 +1779,45 @@ dependencies = [ ] [[package]] -name = "tinyinference" +name = "tinyinference-core" +version = "0.2.1" +dependencies = [ + "anyhow", + "httpdate", + "url", +] + +[[package]] +name = "tinyinference-embeddings" +version = "0.2.1" +dependencies = [ + "async-trait", + "reqwest", + "serde", + "serde_json", + "thiserror", + "tinyinference-core", + "tokio", + "tracing", + "url", +] + +[[package]] +name = "tinyinference-llm" version = "0.2.1" dependencies = [ "async-trait", "bytes", "futures", - "httpdate", "reqwest", "serde", "serde_json", "sha2 0.11.0", "thiserror", + "tinyinference-core", "tokio", + "tracing", + "url", ] [[package]] @@ -1852,7 +1879,8 @@ dependencies = [ "thiserror", "tinycortex", "tinycortex-api", - "tinyinference", + "tinyinference-embeddings", + "tinyinference-llm", "tinymemory-api", "tinymemory-sources", "tinymemory-sync", @@ -1877,7 +1905,7 @@ dependencies = [ "tinybus", "tinybus-module", "tinycortex", - "tinyinference", + "tinyinference-llm", "tinymemory", "tinymemory-api", "tinymemory-bus", diff --git a/crates/tinymemory-module/Cargo.toml b/crates/tinymemory-module/Cargo.toml index 6a017b1b..e324b780 100644 --- a/crates/tinymemory-module/Cargo.toml +++ b/crates/tinymemory-module/Cargo.toml @@ -53,7 +53,7 @@ tinymemory-tinycortex = { path = "../tinymemory-tinycortex", features = ["memory # upstream, so a Linux or Windows artifact still compiles none of them. tinycortex = { version = "0.1", features = ["contacts"] } # Provider-neutral chat request and response types carried over TinyBus. -tinyinference = "0.2" +tinyinference-llm = "0.2" # TinyBus provides the typed service interface and the dynamic module host ABI. # Reached by path now that this crate is its own workspace root: the nested # checkout's `[workspace.package]` resolves correctly from here. @@ -112,12 +112,16 @@ tempfile = "3" tinymemory-api = { path = "../tinymemory-api" } [patch."https://github.com/tinyhumansai/tinyinference"] -tinyinference = { path = "../../vendor/tinyinference/crates/tinyinference" } +tinyinference-core = { path = "../../vendor/tinyinference/crates/tinyinference-core" } +tinyinference-embeddings = { path = "../../vendor/tinyinference/crates/tinyinference-embeddings" } +tinyinference-llm = { path = "../../vendor/tinyinference/crates/tinyinference-llm" } [patch.crates-io] tinycortex = { path = "../../vendor/tinycortex" } tinycortex-api = { path = "../../vendor/tinycortex/api" } -tinyinference = { path = "../../vendor/tinyinference/crates/tinyinference" } +tinyinference-core = { path = "../../vendor/tinyinference/crates/tinyinference-core" } +tinyinference-embeddings = { path = "../../vendor/tinyinference/crates/tinyinference-embeddings" } +tinyinference-llm = { path = "../../vendor/tinyinference/crates/tinyinference-llm" } # Mirrors the root package's set. `unsafe_code = "forbid"` holds even though # `module_export!` emits `unsafe extern "C"` symbols: the macro's expansion diff --git a/crates/tinymemory-module/src/chat.rs b/crates/tinymemory-module/src/chat.rs index eb3509b2..d6cfea88 100644 --- a/crates/tinymemory-module/src/chat.rs +++ b/crates/tinymemory-module/src/chat.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use async_trait::async_trait; use tinybus::Connection; -use tinyinference::model::{ChatModel, ModelRequest, ModelResponse}; +use tinyinference_llm::model::{ChatModel, ModelRequest, ModelResponse}; use crate::ModuleConfig; @@ -97,7 +97,7 @@ impl ChatModel<()> for BusChatModel { &self, _state: &(), request: ModelRequest, - ) -> tinyinference::Result { + ) -> tinyinference_llm::Result { let proxy = self .connection .proxy( @@ -105,11 +105,11 @@ impl ChatModel<()> for BusChatModel { CHAT_HOST_OBJECT_PATH, CHAT_HOST_INTERFACE, ) - .map_err(|error| tinyinference::Error::Model(error.to_string()))?; + .map_err(|error| tinyinference_llm::Error::Model(error.to_string()))?; proxy .call("Complete", (self.role.clone(), request)) .await - .map_err(|error| tinyinference::Error::Model(error.to_string())) + .map_err(|error| tinyinference_llm::Error::Model(error.to_string())) } } diff --git a/crates/tinymemory-module/src/chat_test.rs b/crates/tinymemory-module/src/chat_test.rs index 6fd9910d..cf85fb77 100644 --- a/crates/tinymemory-module/src/chat_test.rs +++ b/crates/tinymemory-module/src/chat_test.rs @@ -3,9 +3,9 @@ use tinybus::broker::Broker; use tinybus::transport::memory::MemoryBus; use tinybus::{Connection, Result as BusResult}; -use tinyinference::message::{AssistantMessage, ContentBlock, Message}; -use tinyinference::model::{ModelRequest, ModelResponse}; -use tinyinference::usage::Usage; +use tinyinference_llm::message::{AssistantMessage, ContentBlock, Message}; +use tinyinference_llm::model::{ModelRequest, ModelResponse}; +use tinyinference_llm::usage::Usage; use super::{BusChatHost, CHAT_HOST_BUS_NAME, CHAT_HOST_OBJECT_PATH}; use crate::config::ModuleConfig; diff --git a/crates/tinymemory-module/tests/module_e2e.rs b/crates/tinymemory-module/tests/module_e2e.rs index 574e8e36..ff2960b5 100644 --- a/crates/tinymemory-module/tests/module_e2e.rs +++ b/crates/tinymemory-module/tests/module_e2e.rs @@ -123,13 +123,13 @@ impl HostChat { async fn complete( &self, _role: String, - _request: tinyinference::model::ModelRequest, - ) -> BusResult { - use tinyinference::message::{AssistantMessage, ContentBlock}; - use tinyinference::usage::Usage; + _request: tinyinference_llm::model::ModelRequest, + ) -> BusResult { + use tinyinference_llm::message::{AssistantMessage, ContentBlock}; + use tinyinference_llm::usage::Usage; std::future::ready(()).await; - Ok(tinyinference::model::ModelResponse { + Ok(tinyinference_llm::model::ModelResponse { message: AssistantMessage { id: None, content: vec![ContentBlock::Text("deterministic summary".into())], diff --git a/vendor/tinycortex b/vendor/tinycortex index 79131f27..1ce63400 160000 --- a/vendor/tinycortex +++ b/vendor/tinycortex @@ -1 +1 @@ -Subproject commit 79131f275cf98f06421fefd9dc812c5a63a5a182 +Subproject commit 1ce634005c3f9315bf8e2b1faf0ea3f5404d356a diff --git a/vendor/tinyinference b/vendor/tinyinference index cc8aca48..bb0f820a 160000 --- a/vendor/tinyinference +++ b/vendor/tinyinference @@ -1 +1 @@ -Subproject commit cc8aca484bb995fbab3b7358f0d72ab5056b587c +Subproject commit bb0f820a246874dff7fff2569d8679303d354fb0