From b62c9361bced802108a32ac0447992537bed7d7d Mon Sep 17 00:00:00 2001 From: Quang Luong Date: Mon, 30 Jun 2025 21:14:53 +0700 Subject: [PATCH 1/5] Run cargo fix --edition to move to Rust 2024 --- rig-core/rig-core-derive/src/embed.rs | 4 ++-- rig-core/src/one_or_many.rs | 7 +++---- rig-core/src/pipeline/conditional.rs | 4 ++-- rig-core/src/pipeline/parallel.rs | 4 ++-- rig-core/src/providers/anthropic/streaming.rs | 2 +- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/rig-core/rig-core-derive/src/embed.rs b/rig-core/rig-core-derive/src/embed.rs index 73b892053..18e7b94ad 100644 --- a/rig-core/rig-core-derive/src/embed.rs +++ b/rig-core/rig-core-derive/src/embed.rs @@ -41,7 +41,7 @@ pub(crate) fn expand_derive_embedding(input: &mut syn::DeriveInput) -> syn::Resu let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); - let gen = quote! { + let r#gen = quote! { // Note: `Embed` trait is imported with the macro. impl #impl_generics Embed for #name #ty_generics #where_clause { @@ -53,7 +53,7 @@ pub(crate) fn expand_derive_embedding(input: &mut syn::DeriveInput) -> syn::Resu } }; - Ok(gen) + Ok(r#gen) } trait StructParser { diff --git a/rig-core/src/one_or_many.rs b/rig-core/src/one_or_many.rs index 65602d9aa..5b4f290e4 100644 --- a/rig-core/src/one_or_many.rs +++ b/rig-core/src/one_or_many.rs @@ -195,10 +195,9 @@ impl Iterator for IntoIter { type Item = T; fn next(&mut self) -> Option { - if let Some(first) = self.first.take() { - Some(first) - } else { - self.rest.next() + match self.first.take() { + Some(first) => Some(first), + _ => self.rest.next(), } } } diff --git a/rig-core/src/pipeline/conditional.rs b/rig-core/src/pipeline/conditional.rs index 276c9557f..998cc69d1 100644 --- a/rig-core/src/pipeline/conditional.rs +++ b/rig-core/src/pipeline/conditional.rs @@ -46,7 +46,7 @@ /// ``` #[macro_export] macro_rules! conditional { - ($enum:ident, $( $variant:ident => $op:expr ),+ $(,)?) => { + ($enum:ident, $( $variant:ident => $op:expr_2021 ),+ $(,)?) => { { #[allow(non_snake_case)] struct ConditionalOp<$($variant),+> { @@ -125,7 +125,7 @@ macro_rules! conditional { /// ``` #[macro_export] macro_rules! try_conditional { - ($enum:ident, $( $variant:ident => $op:expr ),+ $(,)?) => { + ($enum:ident, $( $variant:ident => $op:expr_2021 ),+ $(,)?) => { { #[allow(non_snake_case)] struct TryConditionalOp<$( $variant ),+> { diff --git a/rig-core/src/pipeline/parallel.rs b/rig-core/src/pipeline/parallel.rs index 19668cf31..f120e08c5 100644 --- a/rig-core/src/pipeline/parallel.rs +++ b/rig-core/src/pipeline/parallel.rs @@ -160,7 +160,7 @@ macro_rules! tuple_pattern { #[macro_export] macro_rules! parallel { - ($($es:expr),+ $(,)?) => { + ($($es:expr_2021),+ $(,)?) => { $crate::parallel_internal! { current_position: [] values_and_positions: [] @@ -260,7 +260,7 @@ macro_rules! try_parallel_internal { #[macro_export] macro_rules! try_parallel { - ($($es:expr),+ $(,)?) => { + ($($es:expr_2021),+ $(,)?) => { $crate::try_parallel_internal! { current_position: [] values_and_positions: [] diff --git a/rig-core/src/providers/anthropic/streaming.rs b/rig-core/src/providers/anthropic/streaming.rs index f9b347a99..a8eb04b68 100644 --- a/rig-core/src/providers/anthropic/streaming.rs +++ b/rig-core/src/providers/anthropic/streaming.rs @@ -222,7 +222,7 @@ fn handle_event( None } ContentDelta::InputJsonDelta { partial_json } => { - if let Some(ref mut tool_call) = current_tool_call { + if let Some(tool_call) = current_tool_call { tool_call.input_json.push_str(partial_json); } None From edcaa452774a066b6e6becfc57b71e2ed71eb1ac Mon Sep 17 00:00:00 2001 From: Quang Luong Date: Mon, 30 Jun 2025 21:17:56 +0700 Subject: [PATCH 2/5] Use Rust edition 2024 for all crates --- rig-bedrock/Cargo.toml | 2 +- rig-core/Cargo.toml | 2 +- rig-core/rig-core-derive/Cargo.toml | 2 +- rig-core/src/client/mod.rs | 4 +--- rig-eternalai/Cargo.toml | 2 +- rig-fastembed/Cargo.toml | 2 +- rig-lancedb/Cargo.toml | 2 +- rig-milvus/Cargo.toml | 2 +- rig-mongodb/Cargo.toml | 2 +- rig-neo4j/Cargo.toml | 2 +- rig-postgres/Cargo.toml | 2 +- rig-qdrant/Cargo.toml | 2 +- rig-sqlite/Cargo.toml | 2 +- rig-surrealdb/Cargo.toml | 2 +- 14 files changed, 14 insertions(+), 16 deletions(-) diff --git a/rig-bedrock/Cargo.toml b/rig-bedrock/Cargo.toml index 17d96f711..41bdf62df 100644 --- a/rig-bedrock/Cargo.toml +++ b/rig-bedrock/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rig-bedrock" version = "0.2.0" -edition = "2021" +edition = "2024" license = "MIT" readme = "README.md" description = "AWS Bedrock model provider for Rig integration." diff --git a/rig-core/Cargo.toml b/rig-core/Cargo.toml index 40c50efd0..0c3457762 100644 --- a/rig-core/Cargo.toml +++ b/rig-core/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rig-core" version = "0.13.0" -edition = "2021" +edition = "2024" license = "MIT" readme = "README.md" description = "An opinionated library for building LLM powered applications." diff --git a/rig-core/rig-core-derive/Cargo.toml b/rig-core/rig-core-derive/Cargo.toml index e63ea3ce8..3148b46ae 100644 --- a/rig-core/rig-core-derive/Cargo.toml +++ b/rig-core/rig-core-derive/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rig-derive" version = "0.1.3" -edition = "2021" +edition = "2024" license = "MIT" description = "Internal crate that implements Rig derive macros." repository = "https://github.com/0xPlaygrounds/rig" diff --git a/rig-core/src/client/mod.rs b/rig-core/src/client/mod.rs index 5bbea1f91..a2e395db8 100644 --- a/rig-core/src/client/mod.rs +++ b/rig-core/src/client/mod.rs @@ -220,9 +220,7 @@ mod tests { } fn factory(&self) -> Box { - let client = self.factory.as_ref()(); - - client + self.factory.as_ref()() } } diff --git a/rig-eternalai/Cargo.toml b/rig-eternalai/Cargo.toml index 1f9eb1d2a..9be800a07 100644 --- a/rig-eternalai/Cargo.toml +++ b/rig-eternalai/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rig-eternalai" version = "0.2.7" -edition = "2021" +edition = "2024" license = "MIT" readme = "README.md" description = "EternalAI model provider Rig integration." diff --git a/rig-fastembed/Cargo.toml b/rig-fastembed/Cargo.toml index 25581d967..72d673948 100644 --- a/rig-fastembed/Cargo.toml +++ b/rig-fastembed/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rig-fastembed" version = "0.2.0" -edition = "2021" +edition = "2024" license = "MIT" readme = "README.md" description = "Rig vector store index integration for Fastembed. https://github.com/Anush008/fastembed-rs" diff --git a/rig-lancedb/Cargo.toml b/rig-lancedb/Cargo.toml index 1377863b4..77d533f1f 100644 --- a/rig-lancedb/Cargo.toml +++ b/rig-lancedb/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rig-lancedb" version = "0.2.11" -edition = "2021" +edition = "2024" license = "MIT" readme = "README.md" description = "Rig vector store index integration for LanceDB." diff --git a/rig-milvus/Cargo.toml b/rig-milvus/Cargo.toml index 01079e14d..55e8d0cce 100644 --- a/rig-milvus/Cargo.toml +++ b/rig-milvus/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rig-milvus" version = "0.1.0" -edition = "2021" +edition = "2024" description = "Milvus vector store implementation for the rig framework" license = "MIT" diff --git a/rig-mongodb/Cargo.toml b/rig-mongodb/Cargo.toml index 6f5893c69..d22373cd6 100644 --- a/rig-mongodb/Cargo.toml +++ b/rig-mongodb/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rig-mongodb" version = "0.2.11" -edition = "2021" +edition = "2024" license = "MIT" readme = "README.md" description = "MongoDB implementation of a Rig vector store." diff --git a/rig-neo4j/Cargo.toml b/rig-neo4j/Cargo.toml index 16efc6aeb..656e134c1 100644 --- a/rig-neo4j/Cargo.toml +++ b/rig-neo4j/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rig-neo4j" version = "0.2.11" -edition = "2021" +edition = "2024" license = "MIT" readme = "README.md" description = "Neo4j implementation of a Rig vector store." diff --git a/rig-postgres/Cargo.toml b/rig-postgres/Cargo.toml index c979fa1b5..c324d2c2f 100644 --- a/rig-postgres/Cargo.toml +++ b/rig-postgres/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rig-postgres" version = "0.1.9" -edition = "2021" +edition = "2024" description = "PostgreSQL-based vector store implementation for the rig framework" license = "MIT" readme = "README.md" diff --git a/rig-qdrant/Cargo.toml b/rig-qdrant/Cargo.toml index 4d180a694..90a43d0cc 100644 --- a/rig-qdrant/Cargo.toml +++ b/rig-qdrant/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rig-qdrant" version = "0.1.14" -edition = "2021" +edition = "2024" license = "MIT" readme = "README.md" description = "Rig vector store index integration for Qdrant. https://qdrant.tech" diff --git a/rig-sqlite/Cargo.toml b/rig-sqlite/Cargo.toml index 9e9a54fc4..3c1cdf045 100644 --- a/rig-sqlite/Cargo.toml +++ b/rig-sqlite/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rig-sqlite" version = "0.1.11" -edition = "2021" +edition = "2024" description = "SQLite-based vector store implementation for the rig framework" license = "MIT" diff --git a/rig-surrealdb/Cargo.toml b/rig-surrealdb/Cargo.toml index 0dc37ec87..9d987c88a 100644 --- a/rig-surrealdb/Cargo.toml +++ b/rig-surrealdb/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rig-surrealdb" version = "0.1.6" -edition = "2021" +edition = "2024" description = "SurrealDB vector store implementation for the rig framework" license = "MIT" From d9351a5d2c8c9d83a8b87bcc24e77651c3265d98 Mon Sep 17 00:00:00 2001 From: Quang Luong Date: Mon, 30 Jun 2025 21:27:21 +0700 Subject: [PATCH 3/5] Use resolver = 3 and move edition to workspace --- Cargo.toml | 5 ++++- rig-bedrock/Cargo.toml | 2 +- rig-core/Cargo.toml | 2 +- rig-core/rig-core-derive/Cargo.toml | 2 +- rig-eternalai/Cargo.toml | 2 +- rig-fastembed/Cargo.toml | 2 +- rig-lancedb/Cargo.toml | 2 +- rig-milvus/Cargo.toml | 2 +- rig-mongodb/Cargo.toml | 2 +- rig-neo4j/Cargo.toml | 2 +- rig-postgres/Cargo.toml | 2 +- rig-qdrant/Cargo.toml | 2 +- rig-sqlite/Cargo.toml | 2 +- rig-surrealdb/Cargo.toml | 2 +- 14 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f68363ed7..aa25eaff4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -resolver = "2" +resolver = "3" members = [ "rig-core", "rig-lancedb", @@ -15,6 +15,9 @@ members = [ "rig-bedrock", "rig-milvus", ] +[workspace.package] +edition = "2024" + [workspace.dependencies] anyhow = "1.0.94" arrow-array = "55.1" diff --git a/rig-bedrock/Cargo.toml b/rig-bedrock/Cargo.toml index 41bdf62df..90ac4dbf3 100644 --- a/rig-bedrock/Cargo.toml +++ b/rig-bedrock/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rig-bedrock" version = "0.2.0" -edition = "2024" +edition = { workspace = true } license = "MIT" readme = "README.md" description = "AWS Bedrock model provider for Rig integration." diff --git a/rig-core/Cargo.toml b/rig-core/Cargo.toml index 0c3457762..7a33f2098 100644 --- a/rig-core/Cargo.toml +++ b/rig-core/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rig-core" version = "0.13.0" -edition = "2024" +edition = { workspace = true } license = "MIT" readme = "README.md" description = "An opinionated library for building LLM powered applications." diff --git a/rig-core/rig-core-derive/Cargo.toml b/rig-core/rig-core-derive/Cargo.toml index 3148b46ae..e27adeba7 100644 --- a/rig-core/rig-core-derive/Cargo.toml +++ b/rig-core/rig-core-derive/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rig-derive" version = "0.1.3" -edition = "2024" +edition = { workspace = true } license = "MIT" description = "Internal crate that implements Rig derive macros." repository = "https://github.com/0xPlaygrounds/rig" diff --git a/rig-eternalai/Cargo.toml b/rig-eternalai/Cargo.toml index 9be800a07..e060ca5b4 100644 --- a/rig-eternalai/Cargo.toml +++ b/rig-eternalai/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rig-eternalai" version = "0.2.7" -edition = "2024" +edition = { workspace = true } license = "MIT" readme = "README.md" description = "EternalAI model provider Rig integration." diff --git a/rig-fastembed/Cargo.toml b/rig-fastembed/Cargo.toml index 72d673948..1a4e5947c 100644 --- a/rig-fastembed/Cargo.toml +++ b/rig-fastembed/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rig-fastembed" version = "0.2.0" -edition = "2024" +edition = { workspace = true } license = "MIT" readme = "README.md" description = "Rig vector store index integration for Fastembed. https://github.com/Anush008/fastembed-rs" diff --git a/rig-lancedb/Cargo.toml b/rig-lancedb/Cargo.toml index 77d533f1f..763afa659 100644 --- a/rig-lancedb/Cargo.toml +++ b/rig-lancedb/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rig-lancedb" version = "0.2.11" -edition = "2024" +edition = { workspace = true } license = "MIT" readme = "README.md" description = "Rig vector store index integration for LanceDB." diff --git a/rig-milvus/Cargo.toml b/rig-milvus/Cargo.toml index 55e8d0cce..f88780b9f 100644 --- a/rig-milvus/Cargo.toml +++ b/rig-milvus/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rig-milvus" version = "0.1.0" -edition = "2024" +edition = { workspace = true } description = "Milvus vector store implementation for the rig framework" license = "MIT" diff --git a/rig-mongodb/Cargo.toml b/rig-mongodb/Cargo.toml index d22373cd6..ec0dfb011 100644 --- a/rig-mongodb/Cargo.toml +++ b/rig-mongodb/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rig-mongodb" version = "0.2.11" -edition = "2024" +edition = { workspace = true } license = "MIT" readme = "README.md" description = "MongoDB implementation of a Rig vector store." diff --git a/rig-neo4j/Cargo.toml b/rig-neo4j/Cargo.toml index 656e134c1..379661db2 100644 --- a/rig-neo4j/Cargo.toml +++ b/rig-neo4j/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rig-neo4j" version = "0.2.11" -edition = "2024" +edition = { workspace = true } license = "MIT" readme = "README.md" description = "Neo4j implementation of a Rig vector store." diff --git a/rig-postgres/Cargo.toml b/rig-postgres/Cargo.toml index c324d2c2f..cb12b33dc 100644 --- a/rig-postgres/Cargo.toml +++ b/rig-postgres/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rig-postgres" version = "0.1.9" -edition = "2024" +edition = { workspace = true } description = "PostgreSQL-based vector store implementation for the rig framework" license = "MIT" readme = "README.md" diff --git a/rig-qdrant/Cargo.toml b/rig-qdrant/Cargo.toml index 90a43d0cc..eb97baf87 100644 --- a/rig-qdrant/Cargo.toml +++ b/rig-qdrant/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rig-qdrant" version = "0.1.14" -edition = "2024" +edition = { workspace = true } license = "MIT" readme = "README.md" description = "Rig vector store index integration for Qdrant. https://qdrant.tech" diff --git a/rig-sqlite/Cargo.toml b/rig-sqlite/Cargo.toml index 3c1cdf045..e0c09aca0 100644 --- a/rig-sqlite/Cargo.toml +++ b/rig-sqlite/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rig-sqlite" version = "0.1.11" -edition = "2024" +edition = { workspace = true } description = "SQLite-based vector store implementation for the rig framework" license = "MIT" diff --git a/rig-surrealdb/Cargo.toml b/rig-surrealdb/Cargo.toml index 9d987c88a..8ff678854 100644 --- a/rig-surrealdb/Cargo.toml +++ b/rig-surrealdb/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rig-surrealdb" version = "0.1.6" -edition = "2024" +edition = { workspace = true } description = "SurrealDB vector store implementation for the rig framework" license = "MIT" From 8911762710a4baf15e58ccdf75e0d3ee48400bb3 Mon Sep 17 00:00:00 2001 From: Quang Luong Date: Mon, 30 Jun 2025 21:29:23 +0700 Subject: [PATCH 4/5] Run cargo fmt on new 2024 edition --- rig-bedrock/examples/document_with_bedrock.rs | 4 +- .../examples/embedding_with_bedrock.rs | 2 +- rig-bedrock/examples/image_with_bedrock.rs | 4 +- rig-bedrock/examples/rag_with_bedrock.rs | 4 +- .../examples/streaming_with_bedrock.rs | 2 +- .../streaming_with_bedrock_and_tools.rs | 2 +- rig-bedrock/src/types/assistant_content.rs | 4 +- rig-bedrock/src/types/completion_request.rs | 2 +- rig-bedrock/src/types/document.rs | 4 +- rig-bedrock/src/types/image.rs | 4 +- rig-bedrock/src/types/message.rs | 4 +- rig-bedrock/src/types/text_to_image.rs | 2 +- rig-bedrock/src/types/tool.rs | 2 +- rig-bedrock/src/types/user_content.rs | 4 +- rig-core/examples/agent_parallelization.rs | 2 +- rig-core/examples/agent_with_echochambers.rs | 2 +- rig-core/examples/agent_with_mira.rs | 5 +- rig-core/examples/anthropic_streaming.rs | 2 +- rig-core/examples/chain.rs | 2 +- rig-core/examples/cohere_streaming.rs | 2 +- rig-core/examples/gemini_embeddings.rs | 2 +- rig-core/examples/gemini_streaming.rs | 2 +- rig-core/examples/huggingface_streaming.rs | 2 +- rig-core/examples/image.rs | 4 +- rig-core/examples/image_ollama.rs | 4 +- rig-core/examples/mistral_embeddings.rs | 4 +- rig-core/examples/multi_extract.rs | 2 +- rig-core/examples/multi_turn_streaming.rs | 2 +- rig-core/examples/ollama_streaming.rs | 2 +- rig-core/examples/openai_streaming.rs | 2 +- .../examples/openai_streaming_with_tools.rs | 6 +-- rig-core/examples/pdf_agent.rs | 4 +- rig-core/examples/rag.rs | 4 +- rig-core/examples/rag_ollama.rs | 4 +- rig-core/examples/together_embeddings.rs | 2 +- rig-core/examples/together_streaming.rs | 2 +- rig-core/examples/vector_search.rs | 4 +- rig-core/examples/vector_search_cohere.rs | 4 +- rig-core/examples/vector_search_ollama.rs | 4 +- rig-core/examples/voyageai_embeddings.rs | 2 +- rig-core/examples/xai_streaming.rs | 2 +- .../rig-core-derive/examples/rig_tool/full.rs | 2 +- rig-core/rig-core-derive/src/basic.rs | 2 +- rig-core/rig-core-derive/src/client.rs | 2 +- rig-core/rig-core-derive/src/custom.rs | 2 +- rig-core/rig-core-derive/src/embed.rs | 2 +- rig-core/rig-core-derive/src/lib.rs | 6 ++- rig-core/src/agent/completion.rs | 2 +- rig-core/src/agent/prompt_request.rs | 4 +- rig-core/src/audio_generation.rs | 2 +- rig-core/src/client/completion.rs | 8 +-- rig-core/src/client/embeddings.rs | 2 +- rig-core/src/client/mod.rs | 2 +- rig-core/src/completion/request.rs | 7 +-- rig-core/src/embeddings/builder.rs | 8 +-- rig-core/src/embeddings/distance.rs | 2 +- rig-core/src/embeddings/mod.rs | 2 +- rig-core/src/embeddings/tool.rs | 2 +- rig-core/src/extractor.rs | 2 +- rig-core/src/image_generation.rs | 2 +- rig-core/src/json_utils.rs | 2 +- rig-core/src/loaders/epub/loader.rs | 2 +- rig-core/src/loaders/epub/text_processors.rs | 2 +- rig-core/src/loaders/file.rs | 6 +-- rig-core/src/pipeline/mod.rs | 2 +- rig-core/src/pipeline/parallel.rs | 2 +- rig-core/src/providers/anthropic/client.rs | 4 +- .../src/providers/anthropic/completion.rs | 14 +++--- .../src/providers/anthropic/decoders/line.rs | 4 +- rig-core/src/providers/azure.rs | 4 +- rig-core/src/providers/cohere/client.rs | 4 +- rig-core/src/providers/cohere/completion.rs | 5 +- rig-core/src/providers/cohere/embeddings.rs | 2 +- rig-core/src/providers/cohere/streaming.rs | 2 +- rig-core/src/providers/deepseek.rs | 3 +- rig-core/src/providers/galadriel.rs | 5 +- rig-core/src/providers/gemini/client.rs | 4 +- rig-core/src/providers/gemini/completion.rs | 16 +++--- rig-core/src/providers/gemini/embedding.rs | 2 +- rig-core/src/providers/gemini/streaming.rs | 2 +- .../src/providers/gemini/transcription.rs | 8 +-- rig-core/src/providers/groq.rs | 8 +-- .../src/providers/huggingface/completion.rs | 4 +- rig-core/src/providers/huggingface/mod.rs | 2 +- .../src/providers/huggingface/streaming.rs | 4 +- .../providers/huggingface/transcription.rs | 4 +- rig-core/src/providers/hyperbolic.rs | 10 ++-- rig-core/src/providers/mira.rs | 10 ++-- rig-core/src/providers/mistral/client.rs | 2 +- rig-core/src/providers/mistral/completion.rs | 4 +- rig-core/src/providers/moonshot.rs | 2 +- rig-core/src/providers/ollama.rs | 17 ++++--- rig-core/src/providers/openai/client.rs | 2 +- rig-core/src/providers/openai/completion.rs | 4 +- .../src/providers/openai/image_generation.rs | 2 +- .../src/providers/openrouter/completion.rs | 4 +- .../src/providers/openrouter/streaming.rs | 2 +- rig-core/src/providers/perplexity.rs | 7 +-- rig-core/src/providers/together/client.rs | 4 +- rig-core/src/providers/together/completion.rs | 2 +- rig-core/src/providers/together/embedding.rs | 2 +- rig-core/src/providers/together/mod.rs | 49 +++++++++---------- rig-core/src/providers/xai/client.rs | 2 +- rig-core/src/providers/xai/completion.rs | 6 +-- rig-core/src/streaming.rs | 2 +- rig-core/src/transcription.rs | 5 +- rig-core/src/vector_store/in_memory_store.rs | 4 +- rig-core/tests/embed_macro.rs | 2 +- rig-eternalai/src/providers/eternalai.rs | 6 +-- rig-fastembed/examples/vector_search.rs | 4 +- rig-fastembed/examples/vector_search_local.rs | 8 +-- rig-fastembed/src/lib.rs | 2 +- rig-lancedb/examples/fixtures/lib.rs | 2 +- .../examples/vector_search_local_ann.rs | 2 +- rig-lancedb/examples/vector_search_s3_ann.rs | 4 +- rig-lancedb/src/lib.rs | 2 +- rig-lancedb/src/utils/deserializer.rs | 22 ++++----- rig-lancedb/tests/fixtures/lib.rs | 2 +- rig-lancedb/tests/integration_tests.rs | 2 +- rig-milvus/examples/vector_search_milvus.rs | 2 +- rig-milvus/src/lib.rs | 2 +- rig-mongodb/examples/vector_search_mongodb.rs | 4 +- rig-mongodb/tests/integration_tests.rs | 8 +-- .../vector_search_movies_add_embeddings.rs | 2 +- .../examples/vector_search_movies_consume.rs | 2 +- rig-neo4j/examples/vector_search_simple.rs | 4 +- rig-neo4j/src/vector_index.rs | 2 +- rig-neo4j/tests/integration_tests.rs | 6 +-- .../examples/vector_search_postgres.rs | 2 +- rig-postgres/src/lib.rs | 4 +- rig-postgres/tests/integration_tests.rs | 6 +-- rig-qdrant/examples/qdrant_vector_search.rs | 4 +- rig-qdrant/src/lib.rs | 6 +-- rig-qdrant/tests/integration_tests.rs | 6 +-- rig-sqlite/examples/vector_search_sqlite.rs | 2 +- rig-sqlite/src/lib.rs | 2 +- rig-sqlite/tests/integration_test.rs | 2 +- .../examples/vector_search_surreal.rs | 2 +- rig-surrealdb/src/lib.rs | 6 +-- 139 files changed, 293 insertions(+), 282 deletions(-) diff --git a/rig-bedrock/examples/document_with_bedrock.rs b/rig-bedrock/examples/document_with_bedrock.rs index 12a8f8c81..b3ea82527 100644 --- a/rig-bedrock/examples/document_with_bedrock.rs +++ b/rig-bedrock/examples/document_with_bedrock.rs @@ -1,11 +1,11 @@ use reqwest::Client; use rig::{ - completion::{message::Document, Prompt}, + completion::{Prompt, message::Document}, message::{ContentFormat, DocumentMediaType}, }; -use base64::{prelude::BASE64_STANDARD, Engine}; +use base64::{Engine, prelude::BASE64_STANDARD}; use rig::client::CompletionClient; use rig_bedrock::{client::ClientBuilder, completion::AMAZON_NOVA_LITE}; use tracing::info; diff --git a/rig-bedrock/examples/embedding_with_bedrock.rs b/rig-bedrock/examples/embedding_with_bedrock.rs index 94134d236..658628993 100644 --- a/rig-bedrock/examples/embedding_with_bedrock.rs +++ b/rig-bedrock/examples/embedding_with_bedrock.rs @@ -1,5 +1,5 @@ -use rig::client::EmbeddingsClient; use rig::Embed; +use rig::client::EmbeddingsClient; use rig_bedrock::{client::ClientBuilder, embedding::AMAZON_TITAN_EMBED_TEXT_V2_0}; use tracing::info; diff --git a/rig-bedrock/examples/image_with_bedrock.rs b/rig-bedrock/examples/image_with_bedrock.rs index 9e0b29e83..497794adb 100644 --- a/rig-bedrock/examples/image_with_bedrock.rs +++ b/rig-bedrock/examples/image_with_bedrock.rs @@ -1,11 +1,11 @@ use reqwest::Client; use rig::{ - completion::{message::Image, Prompt}, + completion::{Prompt, message::Image}, message::{ContentFormat, ImageMediaType}, }; -use base64::{prelude::BASE64_STANDARD, Engine}; +use base64::{Engine, prelude::BASE64_STANDARD}; use rig::client::CompletionClient; use rig_bedrock::{client::ClientBuilder, completion::AMAZON_NOVA_LITE}; use tracing::info; diff --git a/rig-bedrock/examples/rag_with_bedrock.rs b/rig-bedrock/examples/rag_with_bedrock.rs index ea7cfe0b3..38ceaffda 100644 --- a/rig-bedrock/examples/rag_with_bedrock.rs +++ b/rig-bedrock/examples/rag_with_bedrock.rs @@ -2,8 +2,8 @@ use std::vec; use rig::client::{CompletionClient, EmbeddingsClient}; use rig::{ - completion::Prompt, embeddings::EmbeddingsBuilder, - vector_store::in_memory_store::InMemoryVectorStore, Embed, + Embed, completion::Prompt, embeddings::EmbeddingsBuilder, + vector_store::in_memory_store::InMemoryVectorStore, }; use rig_bedrock::{ client::ClientBuilder, completion::AMAZON_NOVA_LITE, embedding::AMAZON_TITAN_EMBED_TEXT_V2_0, diff --git a/rig-bedrock/examples/streaming_with_bedrock.rs b/rig-bedrock/examples/streaming_with_bedrock.rs index a240a72ae..265a748c6 100644 --- a/rig-bedrock/examples/streaming_with_bedrock.rs +++ b/rig-bedrock/examples/streaming_with_bedrock.rs @@ -1,5 +1,5 @@ use rig::client::CompletionClient; -use rig::streaming::{stream_to_stdout, StreamingPrompt}; +use rig::streaming::{StreamingPrompt, stream_to_stdout}; use rig_bedrock::{client::ClientBuilder, completion::AMAZON_NOVA_LITE}; #[tokio::main] diff --git a/rig-bedrock/examples/streaming_with_bedrock_and_tools.rs b/rig-bedrock/examples/streaming_with_bedrock_and_tools.rs index d94c42991..812d67b73 100644 --- a/rig-bedrock/examples/streaming_with_bedrock_and_tools.rs +++ b/rig-bedrock/examples/streaming_with_bedrock_and_tools.rs @@ -1,5 +1,5 @@ use rig::client::CompletionClient; -use rig::streaming::{stream_to_stdout, StreamingPrompt}; +use rig::streaming::{StreamingPrompt, stream_to_stdout}; use rig_bedrock::{client::ClientBuilder, completion::AMAZON_NOVA_LITE}; mod common; diff --git a/rig-bedrock/src/types/assistant_content.rs b/rig-bedrock/src/types/assistant_content.rs index 61cbbdd43..8e61aa544 100644 --- a/rig-bedrock/src/types/assistant_content.rs +++ b/rig-bedrock/src/types/assistant_content.rs @@ -2,9 +2,9 @@ use aws_sdk_bedrockruntime::operation::converse::ConverseOutput; use aws_sdk_bedrockruntime::types as aws_bedrock; use rig::{ + OneOrMany, completion::CompletionError, message::{AssistantContent, Text, ToolCall, ToolFunction}, - OneOrMany, }; use crate::types::message::RigMessage; @@ -116,7 +116,7 @@ mod tests { use super::AwsConverseOutput; use aws_sdk_bedrockruntime::types as aws_bedrock; - use rig::{completion, message::AssistantContent, OneOrMany}; + use rig::{OneOrMany, completion, message::AssistantContent}; #[test] fn aws_converse_output_to_completion_response() { diff --git a/rig-bedrock/src/types/completion_request.rs b/rig-bedrock/src/types/completion_request.rs index 1f43a455d..ab94032fb 100644 --- a/rig-bedrock/src/types/completion_request.rs +++ b/rig-bedrock/src/types/completion_request.rs @@ -5,9 +5,9 @@ use aws_sdk_bedrockruntime::types::{ InferenceConfiguration, SystemContentBlock, Tool, ToolConfiguration, ToolInputSchema, ToolSpecification, }; +use rig::OneOrMany; use rig::completion::{CompletionError, Message}; use rig::message::{ContentFormat, DocumentMediaType, UserContent}; -use rig::OneOrMany; pub struct AwsCompletionRequest(pub rig::completion::CompletionRequest); diff --git a/rig-bedrock/src/types/document.rs b/rig-bedrock/src/types/document.rs index c349bc5d6..601c36d3e 100644 --- a/rig-bedrock/src/types/document.rs +++ b/rig-bedrock/src/types/document.rs @@ -5,7 +5,7 @@ use rig::{ }; pub(crate) use crate::types::media_types::RigDocumentMediaType; -use base64::{prelude::BASE64_STANDARD, Engine}; +use base64::{Engine, prelude::BASE64_STANDARD}; use uuid::Uuid; #[derive(Clone)] @@ -76,7 +76,7 @@ impl TryFrom for RigDocument { #[cfg(test)] mod tests { use aws_sdk_bedrockruntime::types as aws_bedrock; - use base64::{prelude::BASE64_STANDARD, Engine}; + use base64::{Engine, prelude::BASE64_STANDARD}; use rig::{ completion::CompletionError, message::{ContentFormat, Document, DocumentMediaType}, diff --git a/rig-bedrock/src/types/image.rs b/rig-bedrock/src/types/image.rs index daca40a47..3a341ed0f 100644 --- a/rig-bedrock/src/types/image.rs +++ b/rig-bedrock/src/types/image.rs @@ -5,7 +5,7 @@ use rig::{ message::{ContentFormat, Image, ImageMediaType, MimeType}, }; -use base64::{prelude::BASE64_STANDARD, Engine}; +use base64::{Engine, prelude::BASE64_STANDARD}; #[derive(Clone)] pub struct RigImage(pub Image); @@ -80,7 +80,7 @@ impl TryFrom for RigImage { #[cfg(test)] mod tests { use aws_sdk_bedrockruntime::types as aws_bedrock; - use base64::{prelude::BASE64_STANDARD, Engine}; + use base64::{Engine, prelude::BASE64_STANDARD}; use rig::{ completion::CompletionError, message::{ContentFormat, Image, ImageMediaType}, diff --git a/rig-bedrock/src/types/message.rs b/rig-bedrock/src/types/message.rs index 2c12af6a7..6b1d84b30 100644 --- a/rig-bedrock/src/types/message.rs +++ b/rig-bedrock/src/types/message.rs @@ -1,9 +1,9 @@ use aws_sdk_bedrockruntime::types as aws_bedrock; use rig::{ + OneOrMany, completion::CompletionError, message::{AssistantContent, Message, UserContent}, - OneOrMany, }; use super::{assistant_content::RigAssistantContent, user_content::RigUserContent}; @@ -90,8 +90,8 @@ mod tests { use crate::types::message::RigMessage; use aws_sdk_bedrockruntime::types as aws_bedrock; use rig::{ - message::{Message, UserContent}, OneOrMany, + message::{Message, UserContent}, }; #[test] diff --git a/rig-bedrock/src/types/text_to_image.rs b/rig-bedrock/src/types/text_to_image.rs index 81d4e4294..4a7f61652 100644 --- a/rig-bedrock/src/types/text_to_image.rs +++ b/rig-bedrock/src/types/text_to_image.rs @@ -1,5 +1,5 @@ -use base64::prelude::BASE64_STANDARD; use base64::Engine; +use base64::prelude::BASE64_STANDARD; use rig::image_generation; use rig::image_generation::ImageGenerationError; use serde::{Deserialize, Serialize}; diff --git a/rig-bedrock/src/types/tool.rs b/rig-bedrock/src/types/tool.rs index bd1f2c1b9..882139917 100644 --- a/rig-bedrock/src/types/tool.rs +++ b/rig-bedrock/src/types/tool.rs @@ -54,7 +54,7 @@ impl TryFrom for RigToolResultContent { #[cfg(test)] mod tests { use aws_sdk_bedrockruntime::types as aws_bedrock; - use base64::{prelude::BASE64_STANDARD, Engine}; + use base64::{Engine, prelude::BASE64_STANDARD}; use rig::{ completion::CompletionError, message::{ContentFormat, Image, ImageMediaType, Text, ToolResultContent}, diff --git a/rig-bedrock/src/types/user_content.rs b/rig-bedrock/src/types/user_content.rs index 9902927ba..3fe03c467 100644 --- a/rig-bedrock/src/types/user_content.rs +++ b/rig-bedrock/src/types/user_content.rs @@ -1,9 +1,9 @@ use aws_sdk_bedrockruntime::types as aws_bedrock; use rig::{ + OneOrMany, completion::CompletionError, message::{Text, ToolResult, ToolResultContent, UserContent}, - OneOrMany, }; use super::{document::RigDocument, image::RigImage, tool::RigToolResultContent}; @@ -96,9 +96,9 @@ mod tests { use crate::types::user_content::RigUserContent; use aws_sdk_bedrockruntime::types as aws_bedrock; use rig::{ + OneOrMany, completion::CompletionError, message::{ToolResultContent, UserContent}, - OneOrMany, }; #[test] diff --git a/rig-core/examples/agent_parallelization.rs b/rig-core/examples/agent_parallelization.rs index bf2676c7b..13aafb950 100644 --- a/rig-core/examples/agent_parallelization.rs +++ b/rig-core/examples/agent_parallelization.rs @@ -7,7 +7,7 @@ use rig::providers::openai::client::Client; use rig::{ parallel, - pipeline::{self, passthrough, Op}, + pipeline::{self, Op, passthrough}, }; use schemars::JsonSchema; diff --git a/rig-core/examples/agent_with_echochambers.rs b/rig-core/examples/agent_with_echochambers.rs index 4e88a6388..28c592ad8 100644 --- a/rig-core/examples/agent_with_echochambers.rs +++ b/rig-core/examples/agent_with_echochambers.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use reqwest::header::{HeaderMap, HeaderValue, CONTENT_TYPE}; +use reqwest::header::{CONTENT_TYPE, HeaderMap, HeaderValue}; use rig::prelude::*; use rig::{ cli_chatbot::cli_chatbot, diff --git a/rig-core/examples/agent_with_mira.rs b/rig-core/examples/agent_with_mira.rs index 76417c1c7..75f12d13a 100644 --- a/rig-core/examples/agent_with_mira.rs +++ b/rig-core/examples/agent_with_mira.rs @@ -32,7 +32,10 @@ async fn main() -> Result<(), anyhow::Error> { println!("\nProceeding with chat completion...\n"); } Err(e) => { - return Err(anyhow::anyhow!("Failed to connect to Mira API: {}. Please verify your API key and network connection.", e)); + return Err(anyhow::anyhow!( + "Failed to connect to Mira API: {}. Please verify your API key and network connection.", + e + )); } } diff --git a/rig-core/examples/anthropic_streaming.rs b/rig-core/examples/anthropic_streaming.rs index 042e92477..f7400d400 100644 --- a/rig-core/examples/anthropic_streaming.rs +++ b/rig-core/examples/anthropic_streaming.rs @@ -1,7 +1,7 @@ use rig::prelude::*; use rig::{ providers::anthropic::{self, CLAUDE_3_5_SONNET}, - streaming::{stream_to_stdout, StreamingPrompt}, + streaming::{StreamingPrompt, stream_to_stdout}, }; #[tokio::main] async fn main() -> Result<(), anyhow::Error> { diff --git a/rig-core/examples/chain.rs b/rig-core/examples/chain.rs index 337ace7b1..dc4ae128c 100644 --- a/rig-core/examples/chain.rs +++ b/rig-core/examples/chain.rs @@ -4,7 +4,7 @@ use std::env; use rig::{ embeddings::EmbeddingsBuilder, parallel, - pipeline::{self, agent_ops::lookup, passthrough, Op}, + pipeline::{self, Op, agent_ops::lookup, passthrough}, providers::openai::{Client, TEXT_EMBEDDING_ADA_002}, vector_store::in_memory_store::InMemoryVectorStore, }; diff --git a/rig-core/examples/cohere_streaming.rs b/rig-core/examples/cohere_streaming.rs index caa3f37f2..09f320cd5 100644 --- a/rig-core/examples/cohere_streaming.rs +++ b/rig-core/examples/cohere_streaming.rs @@ -1,6 +1,6 @@ use rig::prelude::*; use rig::providers::cohere; -use rig::streaming::{stream_to_stdout, StreamingPrompt}; +use rig::streaming::{StreamingPrompt, stream_to_stdout}; #[tokio::main] async fn main() -> Result<(), anyhow::Error> { diff --git a/rig-core/examples/gemini_embeddings.rs b/rig-core/examples/gemini_embeddings.rs index bf5b07044..ff43b568c 100644 --- a/rig-core/examples/gemini_embeddings.rs +++ b/rig-core/examples/gemini_embeddings.rs @@ -1,6 +1,6 @@ +use rig::Embed; use rig::prelude::*; use rig::providers::gemini; -use rig::Embed; #[derive(Embed, Debug)] struct Greetings { diff --git a/rig-core/examples/gemini_streaming.rs b/rig-core/examples/gemini_streaming.rs index 9de1d6b2a..2a64ab277 100644 --- a/rig-core/examples/gemini_streaming.rs +++ b/rig-core/examples/gemini_streaming.rs @@ -1,7 +1,7 @@ use rig::prelude::*; use rig::{ providers::gemini::{self, completion::GEMINI_1_5_FLASH}, - streaming::{stream_to_stdout, StreamingPrompt}, + streaming::{StreamingPrompt, stream_to_stdout}, }; #[tokio::main] diff --git a/rig-core/examples/huggingface_streaming.rs b/rig-core/examples/huggingface_streaming.rs index 6c31f1c2e..5a0fd5c9c 100644 --- a/rig-core/examples/huggingface_streaming.rs +++ b/rig-core/examples/huggingface_streaming.rs @@ -3,7 +3,7 @@ use std::env; use rig::{ providers::huggingface::{self}, - streaming::{stream_to_stdout, StreamingPrompt}, + streaming::{StreamingPrompt, stream_to_stdout}, }; #[tokio::main] diff --git a/rig-core/examples/image.rs b/rig-core/examples/image.rs index 7e411fdce..7e9067d0c 100644 --- a/rig-core/examples/image.rs +++ b/rig-core/examples/image.rs @@ -1,12 +1,12 @@ use reqwest::Client; use rig::prelude::*; use rig::{ - completion::{message::Image, Prompt}, + completion::{Prompt, message::Image}, message::{ContentFormat, ImageMediaType}, providers::anthropic::{self, CLAUDE_3_5_SONNET}, }; -use base64::{prelude::BASE64_STANDARD, Engine}; +use base64::{Engine, prelude::BASE64_STANDARD}; const IMAGE_URL: &str = "https://upload.wikimedia.org/wikipedia/commons/a/a7/Camponotus_flavomarginatus_ant.jpg"; diff --git a/rig-core/examples/image_ollama.rs b/rig-core/examples/image_ollama.rs index 53a1737e1..aad73e29a 100644 --- a/rig-core/examples/image_ollama.rs +++ b/rig-core/examples/image_ollama.rs @@ -1,8 +1,8 @@ -use base64::{prelude::BASE64_STANDARD, Engine}; +use base64::{Engine, prelude::BASE64_STANDARD}; use rig::prelude::*; use rig::providers::ollama; use rig::{ - completion::{message::Image, Prompt}, + completion::{Prompt, message::Image}, message::{ContentFormat, ImageMediaType}, }; use tokio::fs; diff --git a/rig-core/examples/mistral_embeddings.rs b/rig-core/examples/mistral_embeddings.rs index 75b03dd01..3dfffb293 100644 --- a/rig-core/examples/mistral_embeddings.rs +++ b/rig-core/examples/mistral_embeddings.rs @@ -1,9 +1,9 @@ +use rig::Embed; use rig::client::{EmbeddingsClient, ProviderClient}; use rig::embeddings::EmbeddingsBuilder; use rig::providers::mistral; -use rig::vector_store::in_memory_store::InMemoryVectorStore; use rig::vector_store::VectorStoreIndex; -use rig::Embed; +use rig::vector_store::in_memory_store::InMemoryVectorStore; use serde::{Deserialize, Serialize}; #[derive(Embed, Debug, Serialize, Deserialize, Eq, PartialEq)] diff --git a/rig-core/examples/multi_extract.rs b/rig-core/examples/multi_extract.rs index 5b546992e..460ec2ecc 100644 --- a/rig-core/examples/multi_extract.rs +++ b/rig-core/examples/multi_extract.rs @@ -1,6 +1,6 @@ use rig::prelude::*; use rig::{ - pipeline::{self, agent_ops, TryOp}, + pipeline::{self, TryOp, agent_ops}, providers::openai, try_parallel, }; diff --git a/rig-core/examples/multi_turn_streaming.rs b/rig-core/examples/multi_turn_streaming.rs index c9677e18c..240d6e7c9 100644 --- a/rig-core/examples/multi_turn_streaming.rs +++ b/rig-core/examples/multi_turn_streaming.rs @@ -1,5 +1,6 @@ use futures::{Stream, StreamExt}; use rig::{ + OneOrMany, agent::Agent, client::{CompletionClient, ProviderClient}, completion::{self, CompletionError, CompletionModel, PromptError, ToolDefinition}, @@ -7,7 +8,6 @@ use rig::{ providers::anthropic, streaming::StreamingCompletion, tool::{Tool, ToolSetError}, - OneOrMany, }; use serde::{Deserialize, Serialize}; use serde_json::json; diff --git a/rig-core/examples/ollama_streaming.rs b/rig-core/examples/ollama_streaming.rs index ce85536f6..9a519e762 100644 --- a/rig-core/examples/ollama_streaming.rs +++ b/rig-core/examples/ollama_streaming.rs @@ -1,7 +1,7 @@ use rig::prelude::*; use rig::providers::ollama; -use rig::streaming::{stream_to_stdout, StreamingPrompt}; +use rig::streaming::{StreamingPrompt, stream_to_stdout}; #[tokio::main] diff --git a/rig-core/examples/openai_streaming.rs b/rig-core/examples/openai_streaming.rs index 1eb932534..69be8d830 100644 --- a/rig-core/examples/openai_streaming.rs +++ b/rig-core/examples/openai_streaming.rs @@ -1,6 +1,6 @@ use rig::prelude::*; use rig::providers::openai; -use rig::streaming::{stream_to_stdout, StreamingPrompt}; +use rig::streaming::{StreamingPrompt, stream_to_stdout}; #[tokio::main] async fn main() -> Result<(), anyhow::Error> { diff --git a/rig-core/examples/openai_streaming_with_tools.rs b/rig-core/examples/openai_streaming_with_tools.rs index de66b7bb9..bc9bdfadf 100644 --- a/rig-core/examples/openai_streaming_with_tools.rs +++ b/rig-core/examples/openai_streaming_with_tools.rs @@ -1,12 +1,12 @@ use anyhow::Result; -use futures::{stream, StreamExt}; +use futures::{StreamExt, stream}; +use rig::OneOrMany; use rig::agent::Agent; use rig::completion::{CompletionError, CompletionModel}; use rig::message::{AssistantContent, UserContent}; use rig::prelude::*; -use rig::streaming::{stream_to_stdout, StreamingChat}; +use rig::streaming::{StreamingChat, stream_to_stdout}; use rig::tool::ToolSetError; -use rig::OneOrMany; use rig::{ completion::{Message, ToolDefinition}, providers, diff --git a/rig-core/examples/pdf_agent.rs b/rig-core/examples/pdf_agent.rs index befe80dab..adf0c513b 100644 --- a/rig-core/examples/pdf_agent.rs +++ b/rig-core/examples/pdf_agent.rs @@ -1,8 +1,8 @@ use anyhow::{Context, Result}; use rig::prelude::*; use rig::{ - embeddings::EmbeddingsBuilder, loaders::PdfFileLoader, providers::openai, - vector_store::in_memory_store::InMemoryVectorStore, Embed, + Embed, embeddings::EmbeddingsBuilder, loaders::PdfFileLoader, providers::openai, + vector_store::in_memory_store::InMemoryVectorStore, }; use serde::{Deserialize, Serialize}; use std::path::PathBuf; diff --git a/rig-core/examples/rag.rs b/rig-core/examples/rag.rs index b2151a913..046e7a852 100644 --- a/rig-core/examples/rag.rs +++ b/rig-core/examples/rag.rs @@ -1,8 +1,8 @@ use rig::prelude::*; use rig::providers::openai::client::Client; use rig::{ - completion::Prompt, embeddings::EmbeddingsBuilder, providers::openai::TEXT_EMBEDDING_ADA_002, - vector_store::in_memory_store::InMemoryVectorStore, Embed, + Embed, completion::Prompt, embeddings::EmbeddingsBuilder, + providers::openai::TEXT_EMBEDDING_ADA_002, vector_store::in_memory_store::InMemoryVectorStore, }; use serde::Serialize; use std::{env, vec}; diff --git a/rig-core/examples/rag_ollama.rs b/rig-core/examples/rag_ollama.rs index 45ea1075f..7a480cca0 100644 --- a/rig-core/examples/rag_ollama.rs +++ b/rig-core/examples/rag_ollama.rs @@ -1,7 +1,7 @@ use rig::prelude::*; use rig::{ - completion::Prompt, embeddings::EmbeddingsBuilder, providers::ollama::Client, - vector_store::in_memory_store::InMemoryVectorStore, Embed, + Embed, completion::Prompt, embeddings::EmbeddingsBuilder, providers::ollama::Client, + vector_store::in_memory_store::InMemoryVectorStore, }; use serde::Serialize; diff --git a/rig-core/examples/together_embeddings.rs b/rig-core/examples/together_embeddings.rs index 9571402cb..6e057690c 100644 --- a/rig-core/examples/together_embeddings.rs +++ b/rig-core/examples/together_embeddings.rs @@ -1,6 +1,6 @@ +use rig::Embed; use rig::prelude::*; use rig::providers::together; -use rig::Embed; #[derive(Embed, Debug)] struct Greetings { diff --git a/rig-core/examples/together_streaming.rs b/rig-core/examples/together_streaming.rs index 7f4404bb8..95d58f797 100644 --- a/rig-core/examples/together_streaming.rs +++ b/rig-core/examples/together_streaming.rs @@ -1,7 +1,7 @@ use rig::prelude::*; use rig::{ providers::together::{self}, - streaming::{stream_to_stdout, StreamingPrompt}, + streaming::{StreamingPrompt, stream_to_stdout}, }; #[tokio::main] diff --git a/rig-core/examples/vector_search.rs b/rig-core/examples/vector_search.rs index 1a95d1916..9710410bb 100644 --- a/rig-core/examples/vector_search.rs +++ b/rig-core/examples/vector_search.rs @@ -1,10 +1,10 @@ use rig::prelude::*; use rig::providers::openai::client::Client; use rig::{ + Embed, embeddings::EmbeddingsBuilder, providers::openai::TEXT_EMBEDDING_ADA_002, - vector_store::{in_memory_store::InMemoryVectorStore, VectorStoreIndex}, - Embed, + vector_store::{VectorStoreIndex, in_memory_store::InMemoryVectorStore}, }; use serde::{Deserialize, Serialize}; use std::env; diff --git a/rig-core/examples/vector_search_cohere.rs b/rig-core/examples/vector_search_cohere.rs index f375a04d7..2a3fcbef4 100644 --- a/rig-core/examples/vector_search_cohere.rs +++ b/rig-core/examples/vector_search_cohere.rs @@ -1,8 +1,8 @@ use rig::{ + Embed, embeddings::EmbeddingsBuilder, providers::cohere::{Client, EMBED_ENGLISH_V3}, - vector_store::{in_memory_store::InMemoryVectorStore, VectorStoreIndex}, - Embed, + vector_store::{VectorStoreIndex, in_memory_store::InMemoryVectorStore}, }; use serde::{Deserialize, Serialize}; use std::env; diff --git a/rig-core/examples/vector_search_ollama.rs b/rig-core/examples/vector_search_ollama.rs index 39810466f..d40343a97 100644 --- a/rig-core/examples/vector_search_ollama.rs +++ b/rig-core/examples/vector_search_ollama.rs @@ -1,9 +1,9 @@ use rig::prelude::*; use rig::{ + Embed, embeddings::EmbeddingsBuilder, providers, - vector_store::{in_memory_store::InMemoryVectorStore, VectorStoreIndex}, - Embed, + vector_store::{VectorStoreIndex, in_memory_store::InMemoryVectorStore}, }; use serde::{Deserialize, Serialize}; diff --git a/rig-core/examples/voyageai_embeddings.rs b/rig-core/examples/voyageai_embeddings.rs index b09063426..284c6e1ab 100644 --- a/rig-core/examples/voyageai_embeddings.rs +++ b/rig-core/examples/voyageai_embeddings.rs @@ -1,6 +1,6 @@ +use rig::Embed; use rig::prelude::*; use rig::providers::voyageai; -use rig::Embed; #[derive(Embed, Debug)] struct Greetings { diff --git a/rig-core/examples/xai_streaming.rs b/rig-core/examples/xai_streaming.rs index 21cc10549..019e05f70 100644 --- a/rig-core/examples/xai_streaming.rs +++ b/rig-core/examples/xai_streaming.rs @@ -1,6 +1,6 @@ use rig::prelude::*; use rig::providers::xai; -use rig::streaming::{stream_to_stdout, StreamingPrompt}; +use rig::streaming::{StreamingPrompt, stream_to_stdout}; #[tokio::main] async fn main() -> Result<(), anyhow::Error> { diff --git a/rig-core/rig-core-derive/examples/rig_tool/full.rs b/rig-core/rig-core-derive/examples/rig_tool/full.rs index 48855a0db..a8535db51 100644 --- a/rig-core/rig-core-derive/examples/rig_tool/full.rs +++ b/rig-core/rig-core-derive/examples/rig_tool/full.rs @@ -20,7 +20,7 @@ fn string_processor(text: String, operation: String) -> Result { return Err(rig::tool::ToolError::ToolCallError( format!("Unknown operation: {operation}").into(), - )) + )); } }; diff --git a/rig-core/rig-core-derive/src/basic.rs b/rig-core/rig-core-derive/src/basic.rs index b9c1e5c4e..0fa9dd2cd 100644 --- a/rig-core/rig-core-derive/src/basic.rs +++ b/rig-core/rig-core-derive/src/basic.rs @@ -1,4 +1,4 @@ -use syn::{parse_quote, Attribute, DataStruct, Meta}; +use syn::{Attribute, DataStruct, Meta, parse_quote}; use crate::EMBED; diff --git a/rig-core/rig-core-derive/src/client.rs b/rig-core/rig-core-derive/src/client.rs index 6c808e670..2ddccf826 100644 --- a/rig-core/rig-core-derive/src/client.rs +++ b/rig-core/rig-core-derive/src/client.rs @@ -2,7 +2,7 @@ use deluxe::{ParseAttributes, ParseMetaItem}; use proc_macro::TokenStream; use quote::{format_ident, quote}; use std::collections::HashMap; -use syn::{parse_macro_input, DeriveInput}; +use syn::{DeriveInput, parse_macro_input}; #[derive(ParseMetaItem, Default, ParseAttributes)] #[deluxe(attributes(client))] diff --git a/rig-core/rig-core-derive/src/custom.rs b/rig-core/rig-core-derive/src/custom.rs index 547a32f51..e284c6910 100644 --- a/rig-core/rig-core-derive/src/custom.rs +++ b/rig-core/rig-core-derive/src/custom.rs @@ -1,5 +1,5 @@ use quote::ToTokens; -use syn::{meta::ParseNestedMeta, ExprPath}; +use syn::{ExprPath, meta::ParseNestedMeta}; use crate::EMBED; diff --git a/rig-core/rig-core-derive/src/embed.rs b/rig-core/rig-core-derive/src/embed.rs index 18e7b94ad..a1042030b 100644 --- a/rig-core/rig-core-derive/src/embed.rs +++ b/rig-core/rig-core-derive/src/embed.rs @@ -35,7 +35,7 @@ pub(crate) fn expand_derive_embedding(input: &mut syn::DeriveInput) -> syn::Resu return Err(syn::Error::new_spanned( input, "Embed derive macro should only be used on structs", - )) + )); } }; diff --git a/rig-core/rig-core-derive/src/lib.rs b/rig-core/rig-core-derive/src/lib.rs index 18ee1de49..a2c918f83 100644 --- a/rig-core/rig-core-derive/src/lib.rs +++ b/rig-core/rig-core-derive/src/lib.rs @@ -5,10 +5,10 @@ use proc_macro::TokenStream; use quote::{format_ident, quote}; use std::{collections::HashMap, ops::Deref}; use syn::{ + DeriveInput, Expr, ExprLit, Lit, Meta, PathArguments, ReturnType, Token, Type, parse::{Parse, ParseStream}, parse_macro_input, punctuated::Punctuated, - DeriveInput, Expr, ExprLit, Lit, Meta, PathArguments, ReturnType, Token, Type, }; mod basic; @@ -215,7 +215,9 @@ pub fn rig_tool(args: TokenStream, input: TokenStream) -> TokenStream { // Convert the error type to a string for comparison let error_str = quote!(#error).to_string().replace(" ", ""); if !error_str.contains("rig::tool::ToolError") { - panic!("Expected rig::tool::ToolError as second type parameter but found {error_str}"); + panic!( + "Expected rig::tool::ToolError as second type parameter but found {error_str}" + ); } quote!(#output) diff --git a/rig-core/src/agent/completion.rs b/rig-core/src/agent/completion.rs index 542f120a6..2d9c0f385 100644 --- a/rig-core/src/agent/completion.rs +++ b/rig-core/src/agent/completion.rs @@ -8,7 +8,7 @@ use crate::{ tool::ToolSet, vector_store::VectorStoreError, }; -use futures::{stream, StreamExt, TryStreamExt}; +use futures::{StreamExt, TryStreamExt, stream}; use std::collections::HashMap; /// Struct representing an LLM agent. An agent is an LLM model combined with a preamble diff --git a/rig-core/src/agent/prompt_request.rs b/rig-core/src/agent/prompt_request.rs index 4a19edf5d..2b4c9ccb2 100644 --- a/rig-core/src/agent/prompt_request.rs +++ b/rig-core/src/agent/prompt_request.rs @@ -1,12 +1,12 @@ use std::future::IntoFuture; -use futures::{future::BoxFuture, stream, FutureExt, StreamExt}; +use futures::{FutureExt, StreamExt, future::BoxFuture, stream}; use crate::{ + OneOrMany, completion::{Completion, CompletionError, CompletionModel, Message, PromptError}, message::{AssistantContent, UserContent}, tool::ToolSetError, - OneOrMany, }; use super::Agent; diff --git a/rig-core/src/audio_generation.rs b/rig-core/src/audio_generation.rs index 043b9c922..a2e8a026c 100644 --- a/rig-core/src/audio_generation.rs +++ b/rig-core/src/audio_generation.rs @@ -71,7 +71,7 @@ pub trait AudioGenerationModelDyn: Send + Sync { ) -> BoxFuture, AudioGenerationError>>; fn audio_generation_request(&self) - -> AudioGenerationRequestBuilder; + -> AudioGenerationRequestBuilder; } impl AudioGenerationModelDyn for T { diff --git a/rig-core/src/client/completion.rs b/rig-core/src/client/completion.rs index 380b1b4ad..95d852433 100644 --- a/rig-core/src/client/completion.rs +++ b/rig-core/src/client/completion.rs @@ -95,10 +95,10 @@ pub trait CompletionClientDyn: ProviderClient { } impl< - T: CompletionClient, - M: CompletionModel + 'static, - R: Clone + Unpin + 'static, - > CompletionClientDyn for T + T: CompletionClient, + M: CompletionModel + 'static, + R: Clone + Unpin + 'static, +> CompletionClientDyn for T { fn completion_model<'a>(&self, model: &str) -> Box { Box::new(self.completion_model(model)) diff --git a/rig-core/src/client/embeddings.rs b/rig-core/src/client/embeddings.rs index 3377881f4..1c9ea3cec 100644 --- a/rig-core/src/client/embeddings.rs +++ b/rig-core/src/client/embeddings.rs @@ -1,7 +1,7 @@ +use crate::Embed; use crate::client::{AsEmbeddings, ProviderClient}; use crate::embeddings::embedding::EmbeddingModelDyn; use crate::embeddings::{EmbeddingModel, EmbeddingsBuilder}; -use crate::Embed; /// A provider client with embedding capabilities. /// Clone is required for conversions between client types. diff --git a/rig-core/src/client/mod.rs b/rig-core/src/client/mod.rs index a2e395db8..446a28f98 100644 --- a/rig-core/src/client/mod.rs +++ b/rig-core/src/client/mod.rs @@ -168,6 +168,7 @@ pub use crate::client::transcription::TranscriptionClient; #[cfg(test)] mod tests { + use crate::OneOrMany; use crate::client::ProviderClient; use crate::completion::{Completion, CompletionRequest, ToolDefinition}; use crate::image_generation::ImageGenerationRequest; @@ -179,7 +180,6 @@ mod tests { use crate::streaming::StreamingCompletion; use crate::tool::Tool; use crate::transcription::TranscriptionRequest; - use crate::OneOrMany; use futures::StreamExt; use rig::message::Message; use rig::providers::{groq, ollama, perplexity}; diff --git a/rig-core/src/completion/request.rs b/rig-core/src/completion/request.rs index 9bce1b03a..2fee23933 100644 --- a/rig-core/src/completion/request.rs +++ b/rig-core/src/completion/request.rs @@ -66,12 +66,12 @@ use super::message::{AssistantContent, ContentFormat, DocumentMediaType}; use crate::client::completion::CompletionModelHandle; use crate::streaming::StreamingCompletionResponse; +use crate::{OneOrMany, streaming}; use crate::{ json_utils, message::{Message, UserContent}, tool::ToolSetError, }; -use crate::{streaming, OneOrMany}; use futures::future::BoxFuture; use serde::{Deserialize, Serialize}; use std::collections::HashMap; @@ -235,8 +235,9 @@ pub trait CompletionModel: Clone + Send + Sync { fn completion( &self, request: CompletionRequest, - ) -> impl std::future::Future, CompletionError>> - + Send; + ) -> impl std::future::Future< + Output = Result, CompletionError>, + > + Send; fn stream( &self, diff --git a/rig-core/src/embeddings/builder.rs b/rig-core/src/embeddings/builder.rs index 2f70259b1..598315d09 100644 --- a/rig-core/src/embeddings/builder.rs +++ b/rig-core/src/embeddings/builder.rs @@ -4,13 +4,13 @@ use std::{cmp::max, collections::HashMap}; -use futures::{stream, StreamExt}; +use futures::{StreamExt, stream}; use crate::{ + OneOrMany, embeddings::{ - embed::TextEmbedder, Embed, EmbedError, Embedding, EmbeddingError, EmbeddingModel, + Embed, EmbedError, Embedding, EmbeddingError, EmbeddingModel, embed::TextEmbedder, }, - OneOrMany, }; /// Builder for creating embeddings from one or more documents of type `T`. @@ -144,8 +144,8 @@ impl EmbeddingsBuilder { #[cfg(test)] mod tests { use crate::{ - embeddings::{embed::EmbedError, embed::TextEmbedder, Embedding, EmbeddingModel}, Embed, + embeddings::{Embedding, EmbeddingModel, embed::EmbedError, embed::TextEmbedder}, }; use super::EmbeddingsBuilder; diff --git a/rig-core/src/embeddings/distance.rs b/rig-core/src/embeddings/distance.rs index a2bc90603..66ace4442 100644 --- a/rig-core/src/embeddings/distance.rs +++ b/rig-core/src/embeddings/distance.rs @@ -75,7 +75,7 @@ impl VectorDistance for crate::embeddings::Embedding { #[cfg(feature = "rayon")] mod rayon { - use crate::embeddings::{distance::VectorDistance, Embedding}; + use crate::embeddings::{Embedding, distance::VectorDistance}; use rayon::prelude::*; impl VectorDistance for Embedding { diff --git a/rig-core/src/embeddings/mod.rs b/rig-core/src/embeddings/mod.rs index 696634b7d..5ccdbf2d9 100644 --- a/rig-core/src/embeddings/mod.rs +++ b/rig-core/src/embeddings/mod.rs @@ -10,6 +10,6 @@ pub mod tool; pub mod distance; pub use builder::EmbeddingsBuilder; -pub use embed::{to_texts, Embed, EmbedError, TextEmbedder}; +pub use embed::{Embed, EmbedError, TextEmbedder, to_texts}; pub use embedding::{Embedding, EmbeddingError, EmbeddingModel}; pub use tool::ToolSchema; diff --git a/rig-core/src/embeddings/tool.rs b/rig-core/src/embeddings/tool.rs index a8441a23b..e5c413488 100644 --- a/rig-core/src/embeddings/tool.rs +++ b/rig-core/src/embeddings/tool.rs @@ -1,6 +1,6 @@ //! The module defines the [ToolSchema] struct, which is used to embed an object that implements [crate::tool::ToolEmbedding] -use crate::{tool::ToolEmbeddingDyn, Embed}; +use crate::{Embed, tool::ToolEmbeddingDyn}; use serde::Serialize; use super::embed::EmbedError; diff --git a/rig-core/src/extractor.rs b/rig-core/src/extractor.rs index f871c0efc..36ac7816b 100644 --- a/rig-core/src/extractor.rs +++ b/rig-core/src/extractor.rs @@ -30,7 +30,7 @@ use std::marker::PhantomData; -use schemars::{schema_for, JsonSchema}; +use schemars::{JsonSchema, schema_for}; use serde::{Deserialize, Serialize}; use serde_json::json; diff --git a/rig-core/src/image_generation.rs b/rig-core/src/image_generation.rs index 684444db5..feb0caea0 100644 --- a/rig-core/src/image_generation.rs +++ b/rig-core/src/image_generation.rs @@ -72,7 +72,7 @@ pub trait ImageGenerationModelDyn: Send + Sync { ) -> BoxFuture, ImageGenerationError>>; fn image_generation_request(&self) - -> ImageGenerationRequestBuilder; + -> ImageGenerationRequestBuilder; } impl ImageGenerationModelDyn for T { diff --git a/rig-core/src/json_utils.rs b/rig-core/src/json_utils.rs index 4315ab742..9f8469d2e 100644 --- a/rig-core/src/json_utils.rs +++ b/rig-core/src/json_utils.rs @@ -1,5 +1,5 @@ -use serde::de::{self, Deserializer, SeqAccess, Visitor}; use serde::Deserialize; +use serde::de::{self, Deserializer, SeqAccess, Visitor}; use std::convert::Infallible; use std::fmt; use std::marker::PhantomData; diff --git a/rig-core/src/loaders/epub/loader.rs b/rig-core/src/loaders/epub/loader.rs index 47ed9a705..ba90adffe 100644 --- a/rig-core/src/loaders/epub/loader.rs +++ b/rig-core/src/loaders/epub/loader.rs @@ -6,9 +6,9 @@ use std::io::BufReader; use std::marker::PhantomData; use std::path::PathBuf; +use super::RawTextProcessor; use super::errors::EpubLoaderError; use super::text_processors::TextProcessor; -use super::RawTextProcessor; // ================================================================ // Implementing Loadable trait for loading epubs diff --git a/rig-core/src/loaders/epub/text_processors.rs b/rig-core/src/loaders/epub/text_processors.rs index 28000b29f..102865514 100644 --- a/rig-core/src/loaders/epub/text_processors.rs +++ b/rig-core/src/loaders/epub/text_processors.rs @@ -1,7 +1,7 @@ use std::{convert::Infallible, error::Error}; -use quick_xml::events::Event; use quick_xml::Reader; +use quick_xml::events::Event; // ================================================================ // Implementing TextProcessor trait for post-processing epubs diff --git a/rig-core/src/loaders/file.rs b/rig-core/src/loaders/file.rs index 5197809e7..498f925fb 100644 --- a/rig-core/src/loaders/file.rs +++ b/rig-core/src/loaders/file.rs @@ -214,11 +214,7 @@ impl FileLoader<'_, Result> { Ok(FileLoader { iterator: Box::new(fs::read_dir(directory)?.filter_map(|entry| { let path = entry.ok()?.path(); - if path.is_file() { - Some(Ok(path)) - } else { - None - } + if path.is_file() { Some(Ok(path)) } else { None } })), }) } diff --git a/rig-core/src/pipeline/mod.rs b/rig-core/src/pipeline/mod.rs index bf6559ad2..92447b8cf 100644 --- a/rig-core/src/pipeline/mod.rs +++ b/rig-core/src/pipeline/mod.rs @@ -97,7 +97,7 @@ pub mod conditional; use std::future::Future; -pub use op::{map, passthrough, then, Op}; +pub use op::{Op, map, passthrough, then}; pub use try_op::TryOp; use crate::{completion, extractor::Extractor, vector_store}; diff --git a/rig-core/src/pipeline/parallel.rs b/rig-core/src/pipeline/parallel.rs index f120e08c5..17df9187c 100644 --- a/rig-core/src/pipeline/parallel.rs +++ b/rig-core/src/pipeline/parallel.rs @@ -279,7 +279,7 @@ mod tests { use super::*; use crate::pipeline::{ self, - op::{map, Sequential}, + op::{Sequential, map}, passthrough, then, }; diff --git a/rig-core/src/providers/anthropic/client.rs b/rig-core/src/providers/anthropic/client.rs index 0f50dba55..436ca80f9 100644 --- a/rig-core/src/providers/anthropic/client.rs +++ b/rig-core/src/providers/anthropic/client.rs @@ -1,6 +1,6 @@ //! Anthropic client api implementation -use super::completion::{CompletionModel, ANTHROPIC_VERSION_LATEST}; -use crate::client::{impl_conversion_traits, CompletionClient, ProviderClient}; +use super::completion::{ANTHROPIC_VERSION_LATEST, CompletionModel}; +use crate::client::{CompletionClient, ProviderClient, impl_conversion_traits}; // ================================================================ // Main Anthropic Client diff --git a/rig-core/src/providers/anthropic/completion.rs b/rig-core/src/providers/anthropic/completion.rs index ab8dcf50f..353ed8b4f 100644 --- a/rig-core/src/providers/anthropic/completion.rs +++ b/rig-core/src/providers/anthropic/completion.rs @@ -1,11 +1,11 @@ //! Anthropic completion api implementation use crate::{ + OneOrMany, completion::{self, CompletionError}, json_utils, message::{self, DocumentMediaType, MessageError}, one_or_many::string_or_one_or_many, - OneOrMany, }; use std::{convert::Infallible, str::FromStr}; @@ -107,7 +107,7 @@ impl TryFrom for completion::CompletionResponse { return Err(CompletionError::ResponseError( "Response did not contain a message or tool call".into(), - )) + )); } }) }) @@ -277,7 +277,7 @@ impl TryFrom for ImageFormat { _ => { return Err(MessageError::ConversionError( format!("Unsupported image media type: {media_type:?}").to_owned(), - )) + )); } }) } @@ -372,7 +372,7 @@ impl TryFrom for Message { None => { return Err(MessageError::ConversionError( "Image media type is required".to_owned(), - )) + )); } }, r#type: match format { @@ -429,7 +429,7 @@ impl TryFrom for message::AssistantContent { _ => { return Err(MessageError::ConversionError( format!("Unsupported content type for Assistant role: {content:?}").to_owned(), - )) + )); } }) } @@ -484,7 +484,7 @@ impl TryFrom for message::Message { _ => { return Err(MessageError::ConversionError( "Unsupported content type for User role".to_owned(), - )) + )); } }) })?, @@ -497,7 +497,7 @@ impl TryFrom for message::Message { _ => { return Err(MessageError::ConversionError( format!("Unsupported message for Assistant role: {message:?}").to_owned(), - )) + )); } }, }) diff --git a/rig-core/src/providers/anthropic/decoders/line.rs b/rig-core/src/providers/anthropic/decoders/line.rs index 6b795238a..3bc562681 100644 --- a/rig-core/src/providers/anthropic/decoders/line.rs +++ b/rig-core/src/providers/anthropic/decoders/line.rs @@ -327,7 +327,9 @@ mod tests { Vec::::new() ); assert_eq!( - decoder.decode(&[0xb2, 0xd0, 0xb5, 0xd1, 0x81, 0xd1, 0x82, 0xd0, 0xbd, 0xd0, 0xb8]), + decoder.decode(&[ + 0xb2, 0xd0, 0xb5, 0xd1, 0x81, 0xd1, 0x82, 0xd0, 0xbd, 0xd0, 0xb8 + ]), Vec::::new() ); diff --git a/rig-core/src/providers/azure.rs b/rig-core/src/providers/azure.rs index f63417473..f9b979738 100644 --- a/rig-core/src/providers/azure.rs +++ b/rig-core/src/providers/azure.rs @@ -9,7 +9,7 @@ //! let gpt4o = client.completion_model(azure::GPT_4O); //! ``` -use super::openai::{send_compatible_streaming_request, TranscriptionResponse}; +use super::openai::{TranscriptionResponse, send_compatible_streaming_request}; use crate::json_utils::merge; use crate::streaming::StreamingCompletionResponse; @@ -811,9 +811,9 @@ mod audio_generation { mod azure_tests { use super::*; + use crate::OneOrMany; use crate::completion::CompletionModel; use crate::embeddings::EmbeddingModel; - use crate::OneOrMany; #[tokio::test] #[ignore] diff --git a/rig-core/src/providers/cohere/client.rs b/rig-core/src/providers/cohere/client.rs index 9b6834757..6e6c5332a 100644 --- a/rig-core/src/providers/cohere/client.rs +++ b/rig-core/src/providers/cohere/client.rs @@ -1,7 +1,7 @@ -use crate::{embeddings::EmbeddingsBuilder, Embed}; +use crate::{Embed, embeddings::EmbeddingsBuilder}; use super::{CompletionModel, EmbeddingModel}; -use crate::client::{impl_conversion_traits, CompletionClient, EmbeddingsClient, ProviderClient}; +use crate::client::{CompletionClient, EmbeddingsClient, ProviderClient, impl_conversion_traits}; use serde::Deserialize; #[derive(Debug, Deserialize)] diff --git a/rig-core/src/providers/cohere/completion.rs b/rig-core/src/providers/cohere/completion.rs index 73b03b4bb..c1836032e 100644 --- a/rig-core/src/providers/cohere/completion.rs +++ b/rig-core/src/providers/cohere/completion.rs @@ -1,6 +1,7 @@ use crate::{ + OneOrMany, completion::{self, CompletionError}, - json_utils, message, OneOrMany, + json_utils, message, }; use std::collections::HashMap; @@ -8,7 +9,7 @@ use super::client::Client; use crate::completion::CompletionRequest; use crate::providers::cohere::streaming::StreamingCompletionResponse; use serde::{Deserialize, Serialize}; -use serde_json::{json, Value}; +use serde_json::{Value, json}; #[derive(Debug, Deserialize)] pub struct CompletionResponse { diff --git a/rig-core/src/providers/cohere/embeddings.rs b/rig-core/src/providers/cohere/embeddings.rs index ec708f2e5..9a925ae72 100644 --- a/rig-core/src/providers/cohere/embeddings.rs +++ b/rig-core/src/providers/cohere/embeddings.rs @@ -1,4 +1,4 @@ -use super::{client::ApiResponse, Client}; +use super::{Client, client::ApiResponse}; use crate::embeddings::{self, EmbeddingError}; diff --git a/rig-core/src/providers/cohere/streaming.rs b/rig-core/src/providers/cohere/streaming.rs index 297dfcb10..3c77718f0 100644 --- a/rig-core/src/providers/cohere/streaming.rs +++ b/rig-core/src/providers/cohere/streaming.rs @@ -1,6 +1,6 @@ use crate::completion::{CompletionError, CompletionRequest}; -use crate::providers::cohere::completion::Usage; use crate::providers::cohere::CompletionModel; +use crate::providers::cohere::completion::Usage; use crate::streaming::RawStreamingChoice; use crate::{json_utils, streaming}; use async_stream::stream; diff --git a/rig-core/src/providers/deepseek.rs b/rig-core/src/providers/deepseek.rs index 036fbf75a..5927d2cf3 100644 --- a/rig-core/src/providers/deepseek.rs +++ b/rig-core/src/providers/deepseek.rs @@ -16,8 +16,9 @@ use crate::providers::openai; use crate::providers::openai::send_compatible_streaming_request; use crate::streaming::StreamingCompletionResponse; use crate::{ + OneOrMany, completion::{self, CompletionError, CompletionModel, CompletionRequest}, - impl_conversion_traits, json_utils, message, OneOrMany, + impl_conversion_traits, json_utils, message, }; use reqwest::Client as HttpClient; use serde::{Deserialize, Serialize}; diff --git a/rig-core/src/providers/galadriel.rs b/rig-core/src/providers/galadriel.rs index 0ac2f5c50..541622fe3 100644 --- a/rig-core/src/providers/galadriel.rs +++ b/rig-core/src/providers/galadriel.rs @@ -16,11 +16,12 @@ use crate::json_utils::merge; use crate::providers::openai::send_compatible_streaming_request; use crate::streaming::StreamingCompletionResponse; use crate::{ + OneOrMany, completion::{self, CompletionError, CompletionRequest}, - impl_conversion_traits, json_utils, message, OneOrMany, + impl_conversion_traits, json_utils, message, }; use serde::{Deserialize, Serialize}; -use serde_json::{json, Value}; +use serde_json::{Value, json}; // ================================================================ // Main Galadriel Client diff --git a/rig-core/src/providers/gemini/client.rs b/rig-core/src/providers/gemini/client.rs index 111e785ea..202328f97 100644 --- a/rig-core/src/providers/gemini/client.rs +++ b/rig-core/src/providers/gemini/client.rs @@ -2,13 +2,13 @@ use super::{ completion::CompletionModel, embedding::EmbeddingModel, transcription::TranscriptionModel, }; use crate::client::{ - impl_conversion_traits, CompletionClient, EmbeddingsClient, ProviderClient, TranscriptionClient, + CompletionClient, EmbeddingsClient, ProviderClient, TranscriptionClient, impl_conversion_traits, }; use crate::{ + Embed, agent::AgentBuilder, embeddings::{self}, extractor::ExtractorBuilder, - Embed, }; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; diff --git a/rig-core/src/providers/gemini/completion.rs b/rig-core/src/providers/gemini/completion.rs index 86ee3f19d..491701d79 100644 --- a/rig-core/src/providers/gemini/completion.rs +++ b/rig-core/src/providers/gemini/completion.rs @@ -30,8 +30,8 @@ pub const GEMINI_1_0_PRO: &str = "gemini-1.0-pro"; use self::gemini_api_types::Schema; use crate::providers::gemini::streaming::StreamingCompletionResponse; use crate::{ - completion::{self, CompletionError, CompletionRequest}, OneOrMany, + completion::{self, CompletionError, CompletionRequest}, }; use gemini_api_types::{ Content, FunctionDeclaration, GenerateContentRequest, GenerateContentResponse, @@ -243,7 +243,7 @@ impl TryFrom for completion::CompletionResponse { return Err(CompletionError::ResponseError( "Response did not contain a message or tool call".into(), - )) + )); } }) }) @@ -269,14 +269,14 @@ pub mod gemini_api_types { // Gemini API Types // ================================================================= use serde::{Deserialize, Serialize}; - use serde_json::{json, Value}; + use serde_json::{Value, json}; use crate::{ + OneOrMany, completion::CompletionError, message::{self, MessageError, MimeType as _}, one_or_many::string_or_one_or_many, providers::gemini::gemini_api_types::{CodeExecutionResult, ExecutableCode}, - OneOrMany, }; /// Response from the model supporting multiple candidate responses. @@ -389,14 +389,14 @@ pub mod gemini_api_types { _ => { return Err(message::MessageError::ConversionError( format!("Unsupported media type {mime_type:?}"), - )) + )); } } } _ => { return Err(message::MessageError::ConversionError(format!( "Unsupported gemini content part type: {part:?}" - ))) + ))); } }) })?, @@ -411,7 +411,7 @@ pub mod gemini_api_types { _ => { return Err(message::MessageError::ConversionError(format!( "Unsupported part type: {part:?}" - ))) + ))); } }) })?, @@ -474,7 +474,7 @@ pub mod gemini_api_types { message::ToolResultContent::Image(_) => { return Err(message::MessageError::ConversionError( "Tool result content must be text".to_string(), - )) + )); } }; // Convert to JSON since this value may be a valid JSON value diff --git a/rig-core/src/providers/gemini/embedding.rs b/rig-core/src/providers/gemini/embedding.rs index e45fc79ca..16134de0e 100644 --- a/rig-core/src/providers/gemini/embedding.rs +++ b/rig-core/src/providers/gemini/embedding.rs @@ -7,7 +7,7 @@ use serde_json::json; use crate::embeddings::{self, EmbeddingError}; -use super::{client::ApiResponse, Client}; +use super::{Client, client::ApiResponse}; /// `embedding-001` embedding model pub const EMBEDDING_001: &str = "embedding-001"; diff --git a/rig-core/src/providers/gemini/streaming.rs b/rig-core/src/providers/gemini/streaming.rs index 1d142f1e0..ec8206864 100644 --- a/rig-core/src/providers/gemini/streaming.rs +++ b/rig-core/src/providers/gemini/streaming.rs @@ -2,7 +2,7 @@ use async_stream::stream; use futures::StreamExt; use serde::Deserialize; -use super::completion::{create_request_body, gemini_api_types::ContentCandidate, CompletionModel}; +use super::completion::{CompletionModel, create_request_body, gemini_api_types::ContentCandidate}; use crate::{ completion::{CompletionError, CompletionRequest}, streaming::{self}, diff --git a/rig-core/src/providers/gemini/transcription.rs b/rig-core/src/providers/gemini/transcription.rs index 511e48a26..231d9270d 100644 --- a/rig-core/src/providers/gemini/transcription.rs +++ b/rig-core/src/providers/gemini/transcription.rs @@ -1,18 +1,18 @@ use std::path::Path; -use base64::{prelude::BASE64_STANDARD, Engine}; +use base64::{Engine, prelude::BASE64_STANDARD}; use mime_guess; use serde_json::{Map, Value}; use crate::{ + OneOrMany, providers::gemini::completion::gemini_api_types::{ Blob, Content, GenerateContentRequest, GenerationConfig, Part, Role, }, transcription::{self, TranscriptionError}, - OneOrMany, }; -use super::{completion::gemini_api_types::GenerateContentResponse, Client}; +use super::{Client, completion::gemini_api_types::GenerateContentResponse}; pub use super::completion::{ GEMINI_1_5_FLASH, GEMINI_1_5_PRO, GEMINI_1_5_PRO_8B, GEMINI_2_0_FLASH, @@ -136,7 +136,7 @@ impl TryFrom _ => { return Err(TranscriptionError::ResponseError( "Response content was not text".to_string(), - )) + )); } }; diff --git a/rig-core/src/providers/groq.rs b/rig-core/src/providers/groq.rs index 81f0c79f7..101792413 100644 --- a/rig-core/src/providers/groq.rs +++ b/rig-core/src/providers/groq.rs @@ -8,24 +8,24 @@ //! //! let gpt4o = client.completion_model(groq::GPT_4O); //! ``` -use super::openai::{send_compatible_streaming_request, CompletionResponse, TranscriptionResponse}; +use super::openai::{CompletionResponse, TranscriptionResponse, send_compatible_streaming_request}; use crate::client::{CompletionClient, TranscriptionClient}; use crate::json_utils::merge; use crate::providers::openai; use crate::streaming::StreamingCompletionResponse; use crate::{ + OneOrMany, completion::{self, CompletionError, CompletionRequest}, json_utils, message::{self, MessageError}, providers::openai::ToolDefinition, transcription::{self, TranscriptionError}, - OneOrMany, }; use reqwest::multipart::Part; use rig::client::ProviderClient; use rig::impl_conversion_traits; use serde::{Deserialize, Serialize}; -use serde_json::{json, Value}; +use serde_json::{Value, json}; // ================================================================ // Main Groq Client @@ -217,7 +217,7 @@ impl TryFrom for Message { message::AssistantContent::ToolCall(_tool_call) => { return Err(MessageError::ConversionError( "Tool calls do not exist on this message".into(), - )) + )); } } } diff --git a/rig-core/src/providers/huggingface/completion.rs b/rig-core/src/providers/huggingface/completion.rs index 516d98416..4966b5487 100644 --- a/rig-core/src/providers/huggingface/completion.rs +++ b/rig-core/src/providers/huggingface/completion.rs @@ -1,15 +1,15 @@ use serde::{Deserialize, Deserializer, Serialize}; -use serde_json::{json, Value}; +use serde_json::{Value, json}; use std::{convert::Infallible, str::FromStr}; use super::client::Client; use crate::providers::openai::StreamingCompletionResponse; use crate::{ + OneOrMany, completion::{self, CompletionError, CompletionRequest}, json_utils, message::{self}, one_or_many::string_or_one_or_many, - OneOrMany, }; #[derive(Debug, Deserialize)] diff --git a/rig-core/src/providers/huggingface/mod.rs b/rig-core/src/providers/huggingface/mod.rs index 6cf740039..1aa7e7c4c 100644 --- a/rig-core/src/providers/huggingface/mod.rs +++ b/rig-core/src/providers/huggingface/mod.rs @@ -20,7 +20,7 @@ pub mod transcription; pub use client::{Client, ClientBuilder, SubProvider}; pub use completion::{ - GEMMA_2, META_LLAMA_3_1, PHI_4, QWEN2_5, QWEN2_5_CODER, QWEN2_VL, QWEN_QVQ_PREVIEW, + GEMMA_2, META_LLAMA_3_1, PHI_4, QWEN_QVQ_PREVIEW, QWEN2_5, QWEN2_5_CODER, QWEN2_VL, SMALLTHINKER_PREVIEW, }; diff --git a/rig-core/src/providers/huggingface/streaming.rs b/rig-core/src/providers/huggingface/streaming.rs index a6ee4befc..2d1a014dd 100644 --- a/rig-core/src/providers/huggingface/streaming.rs +++ b/rig-core/src/providers/huggingface/streaming.rs @@ -1,10 +1,10 @@ use super::completion::CompletionModel; use crate::completion::{CompletionError, CompletionRequest}; use crate::json_utils::merge_inplace; -use crate::providers::openai::{send_compatible_streaming_request, StreamingCompletionResponse}; +use crate::providers::openai::{StreamingCompletionResponse, send_compatible_streaming_request}; use crate::{json_utils, streaming}; use serde::{Deserialize, Serialize}; -use serde_json::{json, Value}; +use serde_json::{Value, json}; use std::convert::Infallible; use std::str::FromStr; diff --git a/rig-core/src/providers/huggingface/transcription.rs b/rig-core/src/providers/huggingface/transcription.rs index f3dedd590..70f99fdc0 100644 --- a/rig-core/src/providers/huggingface/transcription.rs +++ b/rig-core/src/providers/huggingface/transcription.rs @@ -1,9 +1,9 @@ -use crate::providers::huggingface::completion::ApiResponse; use crate::providers::huggingface::Client; +use crate::providers::huggingface::completion::ApiResponse; use crate::transcription; use crate::transcription::TranscriptionError; -use base64::prelude::BASE64_STANDARD; use base64::Engine; +use base64::prelude::BASE64_STANDARD; use serde::Deserialize; use serde_json::json; diff --git a/rig-core/src/providers/hyperbolic.rs b/rig-core/src/providers/hyperbolic.rs index 341272793..9854373b7 100644 --- a/rig-core/src/providers/hyperbolic.rs +++ b/rig-core/src/providers/hyperbolic.rs @@ -9,7 +9,7 @@ //! let llama_3_1_8b = client.completion_model(hyperbolic::LLAMA_3_1_8B); //! ``` -use super::openai::{send_compatible_streaming_request, AssistantContent}; +use super::openai::{AssistantContent, send_compatible_streaming_request}; use crate::client::{CompletionClient, ProviderClient}; use crate::json_utils::merge_inplace; @@ -19,13 +19,13 @@ use crate::streaming::StreamingCompletionResponse; use crate::impl_conversion_traits; use crate::providers::openai; use crate::{ + OneOrMany, completion::{self, CompletionError, CompletionRequest}, json_utils, providers::openai::Message, - OneOrMany, }; use serde::Deserialize; -use serde_json::{json, Value}; +use serde_json::{Value, json}; // ================================================================ // Main Hyperbolic Client @@ -385,8 +385,8 @@ mod image_generation { use crate::image_generation; use crate::image_generation::{ImageGenerationError, ImageGenerationRequest}; use crate::json_utils::merge_inplace; - use base64::prelude::BASE64_STANDARD; use base64::Engine; + use base64::prelude::BASE64_STANDARD; use serde::Deserialize; use serde_json::json; @@ -522,8 +522,8 @@ mod audio_generation { use crate::audio_generation; use crate::audio_generation::{AudioGenerationError, AudioGenerationRequest}; use crate::client::AudioGenerationClient; - use base64::prelude::BASE64_STANDARD; use base64::Engine; + use base64::prelude::BASE64_STANDARD; use serde::Deserialize; use serde_json::json; diff --git a/rig-core/src/providers/mira.rs b/rig-core/src/providers/mira.rs index 64801b804..dea490e65 100644 --- a/rig-core/src/providers/mira.rs +++ b/rig-core/src/providers/mira.rs @@ -13,14 +13,14 @@ use crate::providers::openai; use crate::providers::openai::send_compatible_streaming_request; use crate::streaming::StreamingCompletionResponse; use crate::{ + OneOrMany, completion::{self, CompletionError, CompletionRequest}, impl_conversion_traits, message::{self, AssistantContent, Message, UserContent}, - OneOrMany, }; -use reqwest::header::{HeaderMap, HeaderValue, CONTENT_TYPE}; +use reqwest::header::{CONTENT_TYPE, HeaderMap, HeaderValue}; use serde::Deserialize; -use serde_json::{json, Value}; +use serde_json::{Value, json}; use std::string::FromUtf8Error; use thiserror::Error; use tracing; @@ -529,13 +529,13 @@ impl TryFrom for Message { _ => { return Err(CompletionError::ResponseError( "Message content must be string or array".to_owned(), - )) + )); } }, None => { return Err(CompletionError::ResponseError( "Message missing content field".to_owned(), - )) + )); } }; diff --git a/rig-core/src/providers/mistral/client.rs b/rig-core/src/providers/mistral/client.rs index 62f5873f9..6b74e8fc6 100644 --- a/rig-core/src/providers/mistral/client.rs +++ b/rig-core/src/providers/mistral/client.rs @@ -1,8 +1,8 @@ use serde::Deserialize; use super::{ - embedding::{EmbeddingModel, MISTRAL_EMBED}, CompletionModel, + embedding::{EmbeddingModel, MISTRAL_EMBED}, }; use crate::client::{CompletionClient, EmbeddingsClient, ProviderClient}; use crate::impl_conversion_traits; diff --git a/rig-core/src/providers/mistral/completion.rs b/rig-core/src/providers/mistral/completion.rs index be32e9b56..a43870abc 100644 --- a/rig-core/src/providers/mistral/completion.rs +++ b/rig-core/src/providers/mistral/completion.rs @@ -1,15 +1,15 @@ use async_stream::stream; use serde::{Deserialize, Serialize}; -use serde_json::{json, Value}; +use serde_json::{Value, json}; use std::{convert::Infallible, str::FromStr}; use super::client::{Client, Usage}; use crate::streaming::{RawStreamingChoice, StreamingCompletionResponse}; use crate::{ + OneOrMany, completion::{self, CompletionError, CompletionRequest}, json_utils, message, providers::mistral::client::ApiResponse, - OneOrMany, }; pub const CODESTRAL: &str = "codestral-latest"; diff --git a/rig-core/src/providers/moonshot.rs b/rig-core/src/providers/moonshot.rs index 394c5f834..d2005b7d7 100644 --- a/rig-core/src/providers/moonshot.rs +++ b/rig-core/src/providers/moonshot.rs @@ -20,7 +20,7 @@ use crate::{ }; use crate::{impl_conversion_traits, message}; use serde::Deserialize; -use serde_json::{json, Value}; +use serde_json::{Value, json}; // ================================================================ // Main Moonshot Client diff --git a/rig-core/src/providers/ollama.rs b/rig-core/src/providers/ollama.rs index d75a9f265..c81fce6ec 100644 --- a/rig-core/src/providers/ollama.rs +++ b/rig-core/src/providers/ollama.rs @@ -43,17 +43,18 @@ use crate::json_utils::merge_inplace; use crate::message::MessageError; use crate::streaming::RawStreamingChoice; use crate::{ + Embed, OneOrMany, completion::{self, CompletionError, CompletionRequest}, embeddings::{self, EmbeddingError, EmbeddingsBuilder}, impl_conversion_traits, json_utils, message, message::{ImageDetail, Text}, - streaming, Embed, OneOrMany, + streaming, }; use async_stream::stream; use futures::StreamExt; use reqwest; use serde::{Deserialize, Serialize}; -use serde_json::{json, Value}; +use serde_json::{Value, json}; use std::convert::Infallible; use std::{convert::TryFrom, str::FromStr}; // ---------- Main Client ---------- @@ -386,11 +387,13 @@ impl CompletionModel { "stream": false, }); if !completion_request.tools.is_empty() { - request_payload["tools"] = json!(completion_request - .tools - .into_iter() - .map(|tool| tool.into()) - .collect::>()); + request_payload["tools"] = json!( + completion_request + .tools + .into_iter() + .map(|tool| tool.into()) + .collect::>() + ); } tracing::debug!(target: "rig", "Chat mode payload: {}", request_payload); diff --git a/rig-core/src/providers/openai/client.rs b/rig-core/src/providers/openai/client.rs index 47aa6f4b0..da1fcdfca 100644 --- a/rig-core/src/providers/openai/client.rs +++ b/rig-core/src/providers/openai/client.rs @@ -204,7 +204,7 @@ mod tests { use crate::providers::openai::{ AssistantContent, Function, ImageUrl, Message, ToolCall, ToolType, UserContent, }; - use crate::{message, OneOrMany}; + use crate::{OneOrMany, message}; use serde_path_to_error::deserialize; #[test] diff --git a/rig-core/src/providers/openai/completion.rs b/rig-core/src/providers/openai/completion.rs index 84d8c0c03..2766e6190 100644 --- a/rig-core/src/providers/openai/completion.rs +++ b/rig-core/src/providers/openai/completion.rs @@ -6,9 +6,9 @@ use super::{ApiErrorResponse, ApiResponse, Client, StreamingCompletionResponse, use crate::completion::{CompletionError, CompletionRequest}; use crate::message::{AudioMediaType, ImageDetail}; use crate::one_or_many::string_or_one_or_many; -use crate::{completion, json_utils, message, OneOrMany}; +use crate::{OneOrMany, completion, json_utils, message}; use serde::{Deserialize, Serialize}; -use serde_json::{json, Value}; +use serde_json::{Value, json}; use std::convert::Infallible; use std::str::FromStr; diff --git a/rig-core/src/providers/openai/image_generation.rs b/rig-core/src/providers/openai/image_generation.rs index 095a085fd..084303b0a 100644 --- a/rig-core/src/providers/openai/image_generation.rs +++ b/rig-core/src/providers/openai/image_generation.rs @@ -1,8 +1,8 @@ use crate::image_generation; use crate::image_generation::{ImageGenerationError, ImageGenerationRequest}; use crate::providers::openai::{ApiResponse, Client}; -use base64::prelude::BASE64_STANDARD; use base64::Engine; +use base64::prelude::BASE64_STANDARD; use serde::Deserialize; use serde_json::json; diff --git a/rig-core/src/providers/openrouter/completion.rs b/rig-core/src/providers/openrouter/completion.rs index 019d37fd2..9c0a256e4 100644 --- a/rig-core/src/providers/openrouter/completion.rs +++ b/rig-core/src/providers/openrouter/completion.rs @@ -3,12 +3,12 @@ use serde::Deserialize; use super::client::{ApiErrorResponse, ApiResponse, Client, Usage}; use crate::{ + OneOrMany, completion::{self, CompletionError, CompletionRequest}, json_utils, providers::openai::Message, - OneOrMany, }; -use serde_json::{json, Value}; +use serde_json::{Value, json}; use crate::providers::openai::AssistantContent; use crate::providers::openrouter::streaming::FinalCompletionResponse; diff --git a/rig-core/src/providers/openrouter/streaming.rs b/rig-core/src/providers/openrouter/streaming.rs index 8bad2aafc..7c3f5a560 100644 --- a/rig-core/src/providers/openrouter/streaming.rs +++ b/rig-core/src/providers/openrouter/streaming.rs @@ -8,7 +8,7 @@ use crate::{ use async_stream::stream; use futures::StreamExt; use reqwest::RequestBuilder; -use serde_json::{json, Value}; +use serde_json::{Value, json}; use crate::completion::{CompletionError, CompletionRequest}; use serde::{Deserialize, Serialize}; diff --git a/rig-core/src/providers/perplexity.rs b/rig-core/src/providers/perplexity.rs index 30f881ef7..cae3dae2a 100644 --- a/rig-core/src/providers/perplexity.rs +++ b/rig-core/src/providers/perplexity.rs @@ -10,10 +10,11 @@ //! ``` use crate::{ + OneOrMany, agent::AgentBuilder, - completion::{self, message, CompletionError, MessageError}, + completion::{self, CompletionError, MessageError, message}, extractor::ExtractorBuilder, - impl_conversion_traits, json_utils, OneOrMany, + impl_conversion_traits, json_utils, }; use crate::client::{CompletionClient, ProviderClient}; @@ -24,7 +25,7 @@ use crate::providers::openai::send_compatible_streaming_request; use crate::streaming::StreamingCompletionResponse; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use serde_json::{json, Value}; +use serde_json::{Value, json}; // ================================================================ // Main Cohere Client diff --git a/rig-core/src/providers/together/client.rs b/rig-core/src/providers/together/client.rs index 6d6b387c2..56bd3dbe9 100644 --- a/rig-core/src/providers/together/client.rs +++ b/rig-core/src/providers/together/client.rs @@ -1,5 +1,5 @@ -use super::{completion::CompletionModel, embedding::EmbeddingModel, M2_BERT_80M_8K_RETRIEVAL}; -use crate::client::{impl_conversion_traits, EmbeddingsClient, ProviderClient}; +use super::{M2_BERT_80M_8K_RETRIEVAL, completion::CompletionModel, embedding::EmbeddingModel}; +use crate::client::{EmbeddingsClient, ProviderClient, impl_conversion_traits}; use rig::client::CompletionClient; // ================================================================ diff --git a/rig-core/src/providers/together/completion.rs b/rig-core/src/providers/together/completion.rs index cc6f5c63f..fd0e0f54a 100644 --- a/rig-core/src/providers/together/completion.rs +++ b/rig-core/src/providers/together/completion.rs @@ -9,7 +9,7 @@ use crate::{ providers::openai, }; -use super::client::{together_ai_api_types::ApiResponse, Client}; +use super::client::{Client, together_ai_api_types::ApiResponse}; use crate::completion::CompletionRequest; use crate::streaming::StreamingCompletionResponse; use serde_json::json; diff --git a/rig-core/src/providers/together/embedding.rs b/rig-core/src/providers/together/embedding.rs index 03f94cd13..1a79e4384 100644 --- a/rig-core/src/providers/together/embedding.rs +++ b/rig-core/src/providers/together/embedding.rs @@ -9,8 +9,8 @@ use serde_json::json; use crate::embeddings::{self, EmbeddingError}; use super::{ - client::together_ai_api_types::{ApiErrorResponse, ApiResponse}, Client, + client::together_ai_api_types::{ApiErrorResponse, ApiResponse}, }; // ================================================================ diff --git a/rig-core/src/providers/together/mod.rs b/rig-core/src/providers/together/mod.rs index 7152bd27f..53010fa75 100644 --- a/rig-core/src/providers/together/mod.rs +++ b/rig-core/src/providers/together/mod.rs @@ -16,36 +16,35 @@ pub mod streaming; pub use client::Client; pub use completion::{ - ALPACA_7B, CHRONOS_HERMES_13B, CODE_LLAMA_13B_INSTRUCT, CODE_LLAMA_13B_INSTRUCT_TOGETHER, - CODE_LLAMA_34B_INSTRUCT, CODE_LLAMA_34B_INSTRUCT_TOGETHER, CODE_LLAMA_70B_INSTRUCT, - CODE_LLAMA_7B_INSTRUCT_TOGETHER, DBRX_INSTRUCT, DEEPSEEK_CODER_33B_INSTRUCT, - DEEPSEEK_LLM_67B_CHAT, DOLPHIN_2_5_MIXTRAL_8X7B, GEMMA_2B_IT, GEMMA_2_27B_IT, GEMMA_2_9B_IT, - GEMMA_7B_IT, GUANACO_13B, GUANACO_33B, GUANACO_65B, GUANACO_7B, HERMES_2_THETA_LLAMA_3_70B, - KOALA_13B, KOALA_7B, LLAMA_2_13B_CHAT, LLAMA_2_13B_CHAT_TOGETHER, LLAMA_2_70B_CHAT_TOGETHER, - LLAMA_2_7B_CHAT, LLAMA_2_7B_CHAT_TOGETHER, LLAMA_3_1_405B_INSTRUCT_LITE_PRO, - LLAMA_3_1_405B_INSTRUCT_TURBO, LLAMA_3_1_70B_INSTRUCT_REFERENCE, LLAMA_3_1_70B_INSTRUCT_TURBO, - LLAMA_3_1_8B_INSTRUCT_REFERENCE, LLAMA_3_1_8B_INSTRUCT_TURBO, - LLAMA_3_2_11B_VISION_INSTRUCT_TURBO, LLAMA_3_2_3B_INSTRUCT_TURBO, - LLAMA_3_2_90B_VISION_INSTRUCT_TURBO, LLAMA_3_70B_CHAT_HF, LLAMA_3_70B_INSTRUCT, + ALPACA_7B, CHRONOS_HERMES_13B, CODE_LLAMA_7B_INSTRUCT_TOGETHER, CODE_LLAMA_13B_INSTRUCT, + CODE_LLAMA_13B_INSTRUCT_TOGETHER, CODE_LLAMA_34B_INSTRUCT, CODE_LLAMA_34B_INSTRUCT_TOGETHER, + CODE_LLAMA_70B_INSTRUCT, DBRX_INSTRUCT, DEEPSEEK_CODER_33B_INSTRUCT, DEEPSEEK_LLM_67B_CHAT, + DOLPHIN_2_5_MIXTRAL_8X7B, GEMMA_2_9B_IT, GEMMA_2_27B_IT, GEMMA_2B_IT, GEMMA_7B_IT, GUANACO_7B, + GUANACO_13B, GUANACO_33B, GUANACO_65B, HERMES_2_THETA_LLAMA_3_70B, KOALA_7B, KOALA_13B, + LLAMA_2_7B_CHAT, LLAMA_2_7B_CHAT_TOGETHER, LLAMA_2_13B_CHAT, LLAMA_2_13B_CHAT_TOGETHER, + LLAMA_2_70B_CHAT_TOGETHER, LLAMA_3_1_8B_INSTRUCT_REFERENCE, LLAMA_3_1_8B_INSTRUCT_TURBO, + LLAMA_3_1_70B_INSTRUCT_REFERENCE, LLAMA_3_1_70B_INSTRUCT_TURBO, + LLAMA_3_1_405B_INSTRUCT_LITE_PRO, LLAMA_3_1_405B_INSTRUCT_TURBO, LLAMA_3_2_3B_INSTRUCT_TURBO, + LLAMA_3_2_11B_VISION_INSTRUCT_TURBO, LLAMA_3_2_90B_VISION_INSTRUCT_TURBO, LLAMA_3_8B_CHAT_HF, + LLAMA_3_8B_CHAT_HF_INT4, LLAMA_3_8B_CHAT_HF_INT8, LLAMA_3_8B_INSTRUCT, + LLAMA_3_8B_INSTRUCT_LITE, LLAMA_3_8B_INSTRUCT_TURBO, LLAMA_3_70B_CHAT_HF, LLAMA_3_70B_INSTRUCT, LLAMA_3_70B_INSTRUCT_GRADIENT_1048K, LLAMA_3_70B_INSTRUCT_LITE, LLAMA_3_70B_INSTRUCT_TURBO, - LLAMA_3_8B_CHAT_HF, LLAMA_3_8B_CHAT_HF_INT4, LLAMA_3_8B_CHAT_HF_INT8, LLAMA_3_8B_INSTRUCT, - LLAMA_3_8B_INSTRUCT_LITE, LLAMA_3_8B_INSTRUCT_TURBO, LLAMA_VISION_FREE, LLAVA_NEXT_MISTRAL_7B, - MISTRAL_7B_INSTRUCT_V0_1, MISTRAL_7B_INSTRUCT_V0_2, MISTRAL_7B_INSTRUCT_V0_3, - MIXTRAL_8X22B_INSTRUCT_V0_1, MIXTRAL_8X7B_INSTRUCT_V0_1, ML318BR, MYTHOMAX_L2_13B, - MYTHOMAX_L2_13B_LITE, NOUS_CAPYBARA_V1_9, NOUS_HERMES_2_MISTRAL_DPO, - NOUS_HERMES_2_MIXTRAL_8X7B_DPO, NOUS_HERMES_2_MIXTRAL_8X7B_SFT, NOUS_HERMES_LLAMA2_13B, - NOUS_HERMES_LLAMA2_70B, NOUS_HERMES_LLAMA2_7B, OLMO_7B_INSTRUCT, OPENCHAT_3_5, + LLAMA_VISION_FREE, LLAVA_NEXT_MISTRAL_7B, MISTRAL_7B_INSTRUCT_V0_1, MISTRAL_7B_INSTRUCT_V0_2, + MISTRAL_7B_INSTRUCT_V0_3, MIXTRAL_8X7B_INSTRUCT_V0_1, MIXTRAL_8X22B_INSTRUCT_V0_1, ML318BR, + MYTHOMAX_L2_13B, MYTHOMAX_L2_13B_LITE, NOUS_CAPYBARA_V1_9, NOUS_HERMES_2_MISTRAL_DPO, + NOUS_HERMES_2_MIXTRAL_8X7B_DPO, NOUS_HERMES_2_MIXTRAL_8X7B_SFT, NOUS_HERMES_LLAMA2_7B, + NOUS_HERMES_LLAMA2_13B, NOUS_HERMES_LLAMA2_70B, OLMO_7B_INSTRUCT, OPENCHAT_3_5, OPENHERMES_2_5_MISTRAL_7B, OPENHERMES_2_MISTRAL_7B, OPENORCA_MISTRAL_7B_8K, - PLATYPUS2_70B_INSTRUCT, QWEN1_5_0_5B_CHAT, QWEN1_5_110B_CHAT, QWEN1_5_14B_CHAT, - QWEN1_5_1_8B_CHAT, QWEN1_5_32B_CHAT, QWEN1_5_4B_CHAT, QWEN1_5_72B_CHAT, QWEN1_5_7B_CHAT, - QWEN2_5_72B_INSTRUCT_TURBO, QWEN2_5_7B_INSTRUCT_TURBO, QWEN_2_1_5B_INSTRUCT, - QWEN_2_72B_INSTRUCT, QWEN_2_7B_INSTRUCT, REMM_SLERP_L2_13B, SNORKEL_MISTRAL_PAIRRM_DPO, + PLATYPUS2_70B_INSTRUCT, QWEN_2_1_5B_INSTRUCT, QWEN_2_7B_INSTRUCT, QWEN_2_72B_INSTRUCT, + QWEN1_5_0_5B_CHAT, QWEN1_5_1_8B_CHAT, QWEN1_5_4B_CHAT, QWEN1_5_7B_CHAT, QWEN1_5_14B_CHAT, + QWEN1_5_32B_CHAT, QWEN1_5_72B_CHAT, QWEN1_5_110B_CHAT, QWEN2_5_7B_INSTRUCT_TURBO, + QWEN2_5_72B_INSTRUCT_TURBO, REMM_SLERP_L2_13B, SNORKEL_MISTRAL_PAIRRM_DPO, SNOWFLAKE_ARCTIC_INSTRUCT, SOLAR_10_7B_INSTRUCT_V1, SOLAR_10_7B_INSTRUCT_V1_INT4, TOPPY_M_7B, - VICUNA_13B_V1_3, VICUNA_13B_V1_5, VICUNA_13B_V1_5_16K, VICUNA_7B_V1_3, VICUNA_7B_V1_5, - WIZARDLM_13B_V1_2, WIZARDLM_2_8X22B, YI_34B_CHAT, ZEPHYR_7B_BETA, + VICUNA_7B_V1_3, VICUNA_7B_V1_5, VICUNA_13B_V1_3, VICUNA_13B_V1_5, VICUNA_13B_V1_5_16K, + WIZARDLM_2_8X22B, WIZARDLM_13B_V1_2, YI_34B_CHAT, ZEPHYR_7B_BETA, }; pub use embedding::{ BERT_BASE_UNCASED, BGE_BASE_EN_V1_5, BGE_LARGE_EN_V1_5, M2_BERT_2K_RETRIEVAL_ENCODER_V1, - M2_BERT_80M_2K_RETRIEVAL, M2_BERT_80M_32K_RETRIEVAL, M2_BERT_80M_8K_RETRIEVAL, SENTENCE_BERT, + M2_BERT_80M_2K_RETRIEVAL, M2_BERT_80M_8K_RETRIEVAL, M2_BERT_80M_32K_RETRIEVAL, SENTENCE_BERT, UAE_LARGE_V1, }; diff --git a/rig-core/src/providers/xai/client.rs b/rig-core/src/providers/xai/client.rs index 431e2956b..a6a8d6e15 100644 --- a/rig-core/src/providers/xai/client.rs +++ b/rig-core/src/providers/xai/client.rs @@ -1,5 +1,5 @@ use super::completion::CompletionModel; -use crate::client::{impl_conversion_traits, CompletionClient, ProviderClient}; +use crate::client::{CompletionClient, ProviderClient, impl_conversion_traits}; // ================================================================ // xAI Client diff --git a/rig-core/src/providers/xai/completion.rs b/rig-core/src/providers/xai/completion.rs index fdc5620f4..d2d842263 100644 --- a/rig-core/src/providers/xai/completion.rs +++ b/rig-core/src/providers/xai/completion.rs @@ -9,11 +9,11 @@ use crate::{ providers::openai::Message, }; -use super::client::{xai_api_types::ApiResponse, Client}; +use super::client::{Client, xai_api_types::ApiResponse}; use crate::completion::CompletionRequest; use crate::providers::openai; use crate::streaming::StreamingCompletionResponse; -use serde_json::{json, Value}; +use serde_json::{Value, json}; use xai_api_types::{CompletionResponse, ToolDefinition}; /// xAI completion models as of 2025-06-04 @@ -142,9 +142,9 @@ impl completion::CompletionModel for CompletionModel { pub mod xai_api_types { use serde::{Deserialize, Serialize}; + use crate::OneOrMany; use crate::completion::{self, CompletionError}; use crate::providers::openai::{AssistantContent, Message}; - use crate::OneOrMany; impl TryFrom for completion::CompletionResponse { type Error = CompletionError; diff --git a/rig-core/src/streaming.rs b/rig-core/src/streaming.rs index da8053274..c7654f4c0 100644 --- a/rig-core/src/streaming.rs +++ b/rig-core/src/streaming.rs @@ -8,12 +8,12 @@ //! - [StreamingCompletion]: Defines a low-level streaming LLM completion interface //! +use crate::OneOrMany; use crate::agent::Agent; use crate::completion::{ CompletionError, CompletionModel, CompletionRequestBuilder, CompletionResponse, Message, }; use crate::message::{AssistantContent, ToolCall, ToolFunction}; -use crate::OneOrMany; use futures::{Stream, StreamExt}; use std::boxed::Box; use std::future::Future; diff --git a/rig-core/src/transcription.rs b/rig-core/src/transcription.rs index 81c2cd574..4457ed7b1 100644 --- a/rig-core/src/transcription.rs +++ b/rig-core/src/transcription.rs @@ -47,8 +47,9 @@ pub trait Transcription { &self, filename: &str, data: &[u8], - ) -> impl std::future::Future, TranscriptionError>> - + Send; + ) -> impl std::future::Future< + Output = Result, TranscriptionError>, + > + Send; } /// General transcription response struct that contains the transcription text diff --git a/rig-core/src/vector_store/in_memory_store.rs b/rig-core/src/vector_store/in_memory_store.rs index 1cd74914d..a1c8f99b2 100644 --- a/rig-core/src/vector_store/in_memory_store.rs +++ b/rig-core/src/vector_store/in_memory_store.rs @@ -9,8 +9,8 @@ use serde::{Deserialize, Serialize}; use super::{VectorStoreError, VectorStoreIndex}; use crate::{ - embeddings::{distance::VectorDistance, Embedding, EmbeddingModel}, OneOrMany, + embeddings::{Embedding, EmbeddingModel, distance::VectorDistance}, }; /// [InMemoryVectorStore] is a simple in-memory vector store that stores embeddings @@ -263,7 +263,7 @@ impl VectorStoreIndex mod tests { use std::cmp::Reverse; - use crate::{embeddings::embedding::Embedding, OneOrMany}; + use crate::{OneOrMany, embeddings::embedding::Embedding}; use super::{InMemoryVectorStore, RankingItem}; diff --git a/rig-core/tests/embed_macro.rs b/rig-core/tests/embed_macro.rs index daf6dcf8f..681c16364 100644 --- a/rig-core/tests/embed_macro.rs +++ b/rig-core/tests/embed_macro.rs @@ -1,6 +1,6 @@ use rig::{ - embeddings::{self, embed::EmbedError, TextEmbedder}, Embed, + embeddings::{self, TextEmbedder, embed::EmbedError}, }; use serde::Serialize; diff --git a/rig-eternalai/src/providers/eternalai.rs b/rig-eternalai/src/providers/eternalai.rs index 3cf23c93a..d59f05f73 100644 --- a/rig-eternalai/src/providers/eternalai.rs +++ b/rig-eternalai/src/providers/eternalai.rs @@ -12,6 +12,7 @@ use crate::eternalai_system_prompt_manager_toolset; use crate::json_utils; use async_stream::stream; +use rig::OneOrMany; use rig::agent::AgentBuilder; use rig::completion::{CompletionError, CompletionRequest}; use rig::embeddings::{EmbeddingError, EmbeddingsBuilder}; @@ -20,11 +21,10 @@ use rig::message; use rig::message::AssistantContent; use rig::providers::openai::{self, Message}; use rig::streaming::{RawStreamingChoice, StreamingCompletionResponse}; -use rig::OneOrMany; -use rig::{completion, embeddings, Embed}; +use rig::{Embed, completion, embeddings}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use serde_json::{json, Value}; +use serde_json::{Value, json}; use std::ffi::c_uint; use std::time::Duration; diff --git a/rig-fastembed/examples/vector_search.rs b/rig-fastembed/examples/vector_search.rs index dbb568fea..25e50f50d 100644 --- a/rig-fastembed/examples/vector_search.rs +++ b/rig-fastembed/examples/vector_search.rs @@ -1,7 +1,7 @@ use rig::{ - embeddings::EmbeddingsBuilder, - vector_store::{in_memory_store::InMemoryVectorStore, VectorStoreIndex}, Embed, + embeddings::EmbeddingsBuilder, + vector_store::{VectorStoreIndex, in_memory_store::InMemoryVectorStore}, }; use rig_fastembed::FastembedModel; use serde::{Deserialize, Serialize}; diff --git a/rig-fastembed/examples/vector_search_local.rs b/rig-fastembed/examples/vector_search_local.rs index b3bb588b9..bc9cb8622 100644 --- a/rig-fastembed/examples/vector_search_local.rs +++ b/rig-fastembed/examples/vector_search_local.rs @@ -1,11 +1,11 @@ use fastembed::{ - read_file_to_bytes, EmbeddingModel as FastembedModel, Pooling, - TextEmbedding as FastembedTextEmbedding, TokenizerFiles, UserDefinedEmbeddingModel, + EmbeddingModel as FastembedModel, Pooling, TextEmbedding as FastembedTextEmbedding, + TokenizerFiles, UserDefinedEmbeddingModel, read_file_to_bytes, }; use rig::{ - embeddings::EmbeddingsBuilder, - vector_store::{in_memory_store::InMemoryVectorStore, VectorStoreIndex}, Embed, + embeddings::EmbeddingsBuilder, + vector_store::{VectorStoreIndex, in_memory_store::InMemoryVectorStore}, }; use rig_fastembed::EmbeddingModel; use serde::{Deserialize, Serialize}; diff --git a/rig-fastembed/src/lib.rs b/rig-fastembed/src/lib.rs index 000d8e5ab..0f604100d 100644 --- a/rig-fastembed/src/lib.rs +++ b/rig-fastembed/src/lib.rs @@ -5,8 +5,8 @@ use fastembed::{ InitOptions, InitOptionsUserDefined, ModelInfo, TextEmbedding, UserDefinedEmbeddingModel, }; use rig::{ - embeddings::{self, EmbeddingError, EmbeddingsBuilder}, Embed, + embeddings::{self, EmbeddingError, EmbeddingsBuilder}, }; /// The `rig-fastembed` client. diff --git a/rig-lancedb/examples/fixtures/lib.rs b/rig-lancedb/examples/fixtures/lib.rs index f2de914cd..f1c7efef6 100644 --- a/rig-lancedb/examples/fixtures/lib.rs +++ b/rig-lancedb/examples/fixtures/lib.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use arrow_array::{types::Float64Type, ArrayRef, FixedSizeListArray, RecordBatch, StringArray}; +use arrow_array::{ArrayRef, FixedSizeListArray, RecordBatch, StringArray, types::Float64Type}; use lancedb::arrow::arrow_schema::{DataType, Field, Fields, Schema}; use rig::embeddings::Embedding; use rig::{Embed, OneOrMany}; diff --git a/rig-lancedb/examples/vector_search_local_ann.rs b/rig-lancedb/examples/vector_search_local_ann.rs index 6f5cf4464..0cdfa42af 100644 --- a/rig-lancedb/examples/vector_search_local_ann.rs +++ b/rig-lancedb/examples/vector_search_local_ann.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use arrow_array::RecordBatchIterator; -use fixture::{as_record_batch, schema, words, Word}; +use fixture::{Word, as_record_batch, schema, words}; use lancedb::index::vector::IvfPqIndexBuilder; use rig::client::{EmbeddingsClient, ProviderClient}; use rig::{ diff --git a/rig-lancedb/examples/vector_search_s3_ann.rs b/rig-lancedb/examples/vector_search_s3_ann.rs index ce48f83a6..b7fdfe782 100644 --- a/rig-lancedb/examples/vector_search_s3_ann.rs +++ b/rig-lancedb/examples/vector_search_s3_ann.rs @@ -1,8 +1,8 @@ use std::sync::Arc; use arrow_array::RecordBatchIterator; -use fixture::{as_record_batch, schema, words, Word}; -use lancedb::{index::vector::IvfPqIndexBuilder, DistanceType}; +use fixture::{Word, as_record_batch, schema, words}; +use lancedb::{DistanceType, index::vector::IvfPqIndexBuilder}; use rig::client::{EmbeddingsClient, ProviderClient}; use rig::{ embeddings::{EmbeddingModel, EmbeddingsBuilder}, diff --git a/rig-lancedb/src/lib.rs b/rig-lancedb/src/lib.rs index 04fdbf605..3a3771410 100644 --- a/rig-lancedb/src/lib.rs +++ b/rig-lancedb/src/lib.rs @@ -1,6 +1,6 @@ use lancedb::{ - query::{QueryBase, VectorQuery}, DistanceType, + query::{QueryBase, VectorQuery}, }; use rig::{ embeddings::embedding::EmbeddingModel, diff --git a/rig-lancedb/src/utils/deserializer.rs b/rig-lancedb/src/utils/deserializer.rs index 7f9d1d7d0..960c0ab98 100644 --- a/rig-lancedb/src/utils/deserializer.rs +++ b/rig-lancedb/src/utils/deserializer.rs @@ -1,23 +1,23 @@ use std::sync::Arc; use arrow_array::{ + Array, ArrowPrimitiveType, OffsetSizeTrait, RecordBatch, RunArray, StructArray, UnionArray, cast::AsArray, types::{ ArrowDictionaryKeyType, BinaryType, ByteArrayType, Date32Type, Date64Type, Decimal128Type, DurationMicrosecondType, DurationMillisecondType, DurationNanosecondType, - DurationSecondType, Float32Type, Float64Type, Int16Type, Int32Type, Int64Type, Int8Type, + DurationSecondType, Float32Type, Float64Type, Int8Type, Int16Type, Int32Type, Int64Type, IntervalDayTime, IntervalDayTimeType, IntervalMonthDayNano, IntervalMonthDayNanoType, IntervalYearMonthType, LargeBinaryType, LargeUtf8Type, RunEndIndexType, Time32MillisecondType, Time32SecondType, Time64MicrosecondType, Time64NanosecondType, TimestampMicrosecondType, TimestampMillisecondType, TimestampNanosecondType, - TimestampSecondType, UInt16Type, UInt32Type, UInt64Type, UInt8Type, Utf8Type, + TimestampSecondType, UInt8Type, UInt16Type, UInt32Type, UInt64Type, Utf8Type, }, - Array, ArrowPrimitiveType, OffsetSizeTrait, RecordBatch, RunArray, StructArray, UnionArray, }; use lancedb::arrow::arrow_schema::{ArrowError, DataType, IntervalUnit, TimeUnit}; use rig::vector_store::VectorStoreError; use serde::Serialize; -use serde_json::{json, Value}; +use serde_json::{Value, json}; use crate::serde_to_rig_error; @@ -246,7 +246,7 @@ fn type_matcher(column: &Arc) -> Result, VectorStoreError> ArrowError::CastError(format!( "Dictionary keys type is not accepted: {keys_type:?}" )), - ))) + ))); } }; @@ -326,7 +326,7 @@ fn type_matcher(column: &Arc) -> Result, VectorStoreError> ArrowError::CastError(format!( "RunEndEncoded index type is not accepted: {index_type:?}" )), - ))) + ))); } }; @@ -611,15 +611,15 @@ mod tests { use std::sync::Arc; use arrow_array::{ + ArrayRef, BinaryArray, FixedSizeListArray, Float32Array, Float64Array, GenericListArray, + Int8Array, Int16Array, Int32Array, Int64Array, LargeBinaryArray, LargeStringArray, + MapArray, RecordBatch, StringArray, StructArray, UInt8Array, UInt16Array, UInt32Array, + UInt64Array, builder::{ FixedSizeListBuilder, ListBuilder, StringBuilder, StringDictionaryBuilder, StringRunBuilder, UnionBuilder, }, - types::{Float64Type, Int16Type, Int32Type, Int8Type}, - ArrayRef, BinaryArray, FixedSizeListArray, Float32Array, Float64Array, GenericListArray, - Int16Array, Int32Array, Int64Array, Int8Array, LargeBinaryArray, LargeStringArray, - MapArray, RecordBatch, StringArray, StructArray, UInt16Array, UInt32Array, UInt64Array, - UInt8Array, + types::{Float64Type, Int8Type, Int16Type, Int32Type}, }; use lancedb::arrow::arrow_schema::{DataType, Field, Fields}; use serde_json::json; diff --git a/rig-lancedb/tests/fixtures/lib.rs b/rig-lancedb/tests/fixtures/lib.rs index f2de914cd..f1c7efef6 100644 --- a/rig-lancedb/tests/fixtures/lib.rs +++ b/rig-lancedb/tests/fixtures/lib.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use arrow_array::{types::Float64Type, ArrayRef, FixedSizeListArray, RecordBatch, StringArray}; +use arrow_array::{ArrayRef, FixedSizeListArray, RecordBatch, StringArray, types::Float64Type}; use lancedb::arrow::arrow_schema::{DataType, Field, Fields, Schema}; use rig::embeddings::Embedding; use rig::{Embed, OneOrMany}; diff --git a/rig-lancedb/tests/integration_tests.rs b/rig-lancedb/tests/integration_tests.rs index 294b6f751..579652638 100644 --- a/rig-lancedb/tests/integration_tests.rs +++ b/rig-lancedb/tests/integration_tests.rs @@ -1,7 +1,7 @@ use serde_json::json; use arrow_array::RecordBatchIterator; -use fixture::{as_record_batch, schema, words, Word}; +use fixture::{Word, as_record_batch, schema, words}; use lancedb::index::vector::IvfPqIndexBuilder; use rig::{ client::EmbeddingsClient, diff --git a/rig-milvus/examples/vector_search_milvus.rs b/rig-milvus/examples/vector_search_milvus.rs index 34794d6df..5054b7eaf 100644 --- a/rig-milvus/examples/vector_search_milvus.rs +++ b/rig-milvus/examples/vector_search_milvus.rs @@ -1,8 +1,8 @@ use rig::{ + Embed, client::{EmbeddingsClient, ProviderClient}, embeddings::EmbeddingsBuilder, vector_store::VectorStoreIndex, - Embed, }; use serde::{Deserialize, Serialize}; diff --git a/rig-milvus/src/lib.rs b/rig-milvus/src/lib.rs index d7175ce76..e4654d878 100644 --- a/rig-milvus/src/lib.rs +++ b/rig-milvus/src/lib.rs @@ -1,8 +1,8 @@ use reqwest::StatusCode; use rig::{ + Embed, OneOrMany, embeddings::{Embedding, EmbeddingModel}, vector_store::{VectorStoreError, VectorStoreIndex}, - Embed, OneOrMany, }; use serde::{Deserialize, Serialize}; diff --git a/rig-mongodb/examples/vector_search_mongodb.rs b/rig-mongodb/examples/vector_search_mongodb.rs index d7ec32826..9f7f8c0a5 100644 --- a/rig-mongodb/examples/vector_search_mongodb.rs +++ b/rig-mongodb/examples/vector_search_mongodb.rs @@ -1,7 +1,7 @@ use mongodb::{ + Client as MongoClient, Collection, bson::{self, doc}, options::ClientOptions, - Client as MongoClient, Collection, }; use rig::providers::openai::TEXT_EMBEDDING_ADA_002; use serde::{Deserialize, Deserializer}; @@ -10,7 +10,7 @@ use std::env; use rig::client::EmbeddingsClient; use rig::{ - embeddings::EmbeddingsBuilder, providers::openai::Client, vector_store::VectorStoreIndex, Embed, + Embed, embeddings::EmbeddingsBuilder, providers::openai::Client, vector_store::VectorStoreIndex, }; use rig_mongodb::{MongoDbVectorIndex, SearchParams}; diff --git a/rig-mongodb/tests/integration_tests.rs b/rig-mongodb/tests/integration_tests.rs index 6ed5bc68f..757819573 100644 --- a/rig-mongodb/tests/integration_tests.rs +++ b/rig-mongodb/tests/integration_tests.rs @@ -1,21 +1,21 @@ use futures::StreamExt; use mongodb::{ + Collection, SearchIndexModel, bson::{self, doc}, options::ClientOptions, - Collection, SearchIndexModel, }; use rig::client::EmbeddingsClient; use rig::{ - embeddings::EmbeddingsBuilder, providers::openai, vector_store::VectorStoreIndex, Embed, + Embed, embeddings::EmbeddingsBuilder, providers::openai, vector_store::VectorStoreIndex, }; use rig_mongodb::{MongoDbVectorIndex, SearchParams}; use serde_json::json; use testcontainers::{ + GenericImage, ImageExt, core::{IntoContainerPort, WaitFor}, runners::AsyncRunner, - GenericImage, ImageExt, }; -use tokio::time::{sleep, Duration}; +use tokio::time::{Duration, sleep}; #[derive(Embed, Clone, serde::Deserialize, serde::Serialize, Debug, PartialEq)] struct Word { diff --git a/rig-neo4j/examples/vector_search_movies_add_embeddings.rs b/rig-neo4j/examples/vector_search_movies_add_embeddings.rs index dd38d1c40..1516e1d5b 100644 --- a/rig-neo4j/examples/vector_search_movies_add_embeddings.rs +++ b/rig-neo4j/examples/vector_search_movies_add_embeddings.rs @@ -15,8 +15,8 @@ use rig::{ use neo4rs::*; use rig::client::EmbeddingsClient; use rig_neo4j::{ - vector_index::{IndexConfig, SearchParams}, Neo4jClient, ToBoltType, + vector_index::{IndexConfig, SearchParams}, }; use serde::{Deserialize, Serialize}; diff --git a/rig-neo4j/examples/vector_search_movies_consume.rs b/rig-neo4j/examples/vector_search_movies_consume.rs index 73a4658b0..13dd5cfe0 100644 --- a/rig-neo4j/examples/vector_search_movies_consume.rs +++ b/rig-neo4j/examples/vector_search_movies_consume.rs @@ -14,7 +14,7 @@ //! [examples/vector_search_movies_add_embeddings.rs](examples/vector_search_movies_add_embeddings.rs) provides an example of //! how to add embeddings to an existing `recommendations` database. use neo4rs::ConfigBuilder; -use rig_neo4j::{vector_index::SearchParams, Neo4jClient}; +use rig_neo4j::{Neo4jClient, vector_index::SearchParams}; use std::env; diff --git a/rig-neo4j/examples/vector_search_simple.rs b/rig-neo4j/examples/vector_search_simple.rs index c7007b718..e8edee67b 100644 --- a/rig-neo4j/examples/vector_search_simple.rs +++ b/rig-neo4j/examples/vector_search_simple.rs @@ -11,12 +11,12 @@ use std::env; use futures::{StreamExt, TryStreamExt}; use rig::client::EmbeddingsClient; use rig::{ + Embed, embeddings::EmbeddingsBuilder, providers::openai::{Client, TEXT_EMBEDDING_ADA_002}, vector_store::VectorStoreIndex as _, - Embed, }; -use rig_neo4j::{vector_index::SearchParams, Neo4jClient, ToBoltType}; +use rig_neo4j::{Neo4jClient, ToBoltType, vector_index::SearchParams}; #[derive(Embed, Clone, Debug)] pub struct Word { diff --git a/rig-neo4j/src/vector_index.rs b/rig-neo4j/src/vector_index.rs index 4d123f1b0..8d62ceaaa 100644 --- a/rig-neo4j/src/vector_index.rs +++ b/rig-neo4j/src/vector_index.rs @@ -9,7 +9,7 @@ use rig::{ embeddings::{Embedding, EmbeddingModel}, vector_store::{VectorStoreError, VectorStoreIndex}, }; -use serde::{de::Error, Deserialize, Serialize}; +use serde::{Deserialize, Serialize, de::Error}; use crate::Neo4jClient; diff --git a/rig-neo4j/tests/integration_tests.rs b/rig-neo4j/tests/integration_tests.rs index 0df905c34..6bc62db30 100644 --- a/rig-neo4j/tests/integration_tests.rs +++ b/rig-neo4j/tests/integration_tests.rs @@ -1,19 +1,19 @@ use serde_json::json; use testcontainers::{ + GenericImage, ImageExt, core::{IntoContainerPort, WaitFor}, runners::AsyncRunner, - GenericImage, ImageExt, }; use futures::{StreamExt, TryStreamExt}; use rig::client::EmbeddingsClient; use rig::vector_store::VectorStoreIndex; use rig::{ + Embed, OneOrMany, embeddings::{Embedding, EmbeddingsBuilder}, providers::openai, - Embed, OneOrMany, }; -use rig_neo4j::{vector_index::SearchParams, Neo4jClient, ToBoltType}; +use rig_neo4j::{Neo4jClient, ToBoltType, vector_index::SearchParams}; const BOLT_PORT: u16 = 7687; const HTTP_PORT: u16 = 7474; diff --git a/rig-postgres/examples/vector_search_postgres.rs b/rig-postgres/examples/vector_search_postgres.rs index e6474b2f7..7d2b79918 100644 --- a/rig-postgres/examples/vector_search_postgres.rs +++ b/rig-postgres/examples/vector_search_postgres.rs @@ -1,5 +1,5 @@ use rig::client::{EmbeddingsClient, ProviderClient}; -use rig::{embeddings::EmbeddingsBuilder, vector_store::VectorStoreIndex, Embed}; +use rig::{Embed, embeddings::EmbeddingsBuilder, vector_store::VectorStoreIndex}; use rig_postgres::PostgresVectorStore; use serde::{Deserialize, Serialize}; use sqlx::postgres::PgPoolOptions; diff --git a/rig-postgres/src/lib.rs b/rig-postgres/src/lib.rs index 43fadb8b2..d8c9331b6 100644 --- a/rig-postgres/src/lib.rs +++ b/rig-postgres/src/lib.rs @@ -1,11 +1,11 @@ use std::fmt::Display; use rig::{ + Embed, OneOrMany, embeddings::{Embedding, EmbeddingModel}, vector_store::{VectorStoreError, VectorStoreIndex}, - Embed, OneOrMany, }; -use serde::{de::DeserializeOwned, Deserialize, Serialize}; +use serde::{Deserialize, Serialize, de::DeserializeOwned}; use serde_json::Value; use sqlx::PgPool; use uuid::Uuid; diff --git a/rig-postgres/tests/integration_tests.rs b/rig-postgres/tests/integration_tests.rs index 20e0657b8..4775604ce 100644 --- a/rig-postgres/tests/integration_tests.rs +++ b/rig-postgres/tests/integration_tests.rs @@ -1,13 +1,13 @@ use rig::client::EmbeddingsClient; -use rig::{embeddings::EmbeddingsBuilder, vector_store::VectorStoreIndex, Embed}; +use rig::{Embed, embeddings::EmbeddingsBuilder, vector_store::VectorStoreIndex}; use rig_postgres::PostgresVectorStore; use serde::{Deserialize, Serialize}; use serde_json::json; -use sqlx::{postgres::PgPoolOptions, PgPool}; +use sqlx::{PgPool, postgres::PgPoolOptions}; use testcontainers::{ + ContainerAsync, GenericImage, ImageExt, core::{IntoContainerPort, WaitFor}, runners::AsyncRunner, - ContainerAsync, GenericImage, ImageExt, }; const POSTGRES_PORT: u16 = 5432; diff --git a/rig-qdrant/examples/qdrant_vector_search.rs b/rig-qdrant/examples/qdrant_vector_search.rs index ec72ac05d..574b2587d 100644 --- a/rig-qdrant/examples/qdrant_vector_search.rs +++ b/rig-qdrant/examples/qdrant_vector_search.rs @@ -10,15 +10,15 @@ use std::env; use anyhow::anyhow; use qdrant_client::{ - qdrant::{CreateCollectionBuilder, Distance, QueryPointsBuilder, VectorParamsBuilder}, Qdrant, + qdrant::{CreateCollectionBuilder, Distance, QueryPointsBuilder, VectorParamsBuilder}, }; use rig::client::EmbeddingsClient; use rig::{ + Embed, embeddings::EmbeddingsBuilder, providers::openai::{Client, TEXT_EMBEDDING_ADA_002}, vector_store::VectorStoreIndex, - Embed, }; use rig_qdrant::QdrantVectorStore; diff --git a/rig-qdrant/src/lib.rs b/rig-qdrant/src/lib.rs index cb2162755..5b1c940d7 100644 --- a/rig-qdrant/src/lib.rs +++ b/rig-qdrant/src/lib.rs @@ -1,13 +1,13 @@ use qdrant_client::{ + Payload, Qdrant, qdrant::{ - point_id::PointIdOptions, PointId, PointStruct, Query, QueryPoints, UpsertPointsBuilder, + PointId, PointStruct, Query, QueryPoints, UpsertPointsBuilder, point_id::PointIdOptions, }, - Payload, Qdrant, }; use rig::{ + Embed, OneOrMany, embeddings::{Embedding, EmbeddingModel}, vector_store::{VectorStoreError, VectorStoreIndex}, - Embed, OneOrMany, }; use serde::{Deserialize, Serialize}; use uuid::Uuid; diff --git a/rig-qdrant/tests/integration_tests.rs b/rig-qdrant/tests/integration_tests.rs index 2663defea..b59319153 100644 --- a/rig-qdrant/tests/integration_tests.rs +++ b/rig-qdrant/tests/integration_tests.rs @@ -1,20 +1,20 @@ use serde_json::json; use testcontainers::{ + GenericImage, core::{IntoContainerPort, WaitFor}, runners::AsyncRunner, - GenericImage, }; use qdrant_client::{ + Payload, Qdrant, qdrant::{ CreateCollectionBuilder, Distance, PointStruct, QueryPointsBuilder, UpsertPointsBuilder, VectorParamsBuilder, }, - Payload, Qdrant, }; use rig::client::EmbeddingsClient; use rig::{ - embeddings::EmbeddingsBuilder, providers::openai, vector_store::VectorStoreIndex, Embed, + Embed, embeddings::EmbeddingsBuilder, providers::openai, vector_store::VectorStoreIndex, }; use rig_qdrant::QdrantVectorStore; diff --git a/rig-sqlite/examples/vector_search_sqlite.rs b/rig-sqlite/examples/vector_search_sqlite.rs index e3b6c9941..0b26cd103 100644 --- a/rig-sqlite/examples/vector_search_sqlite.rs +++ b/rig-sqlite/examples/vector_search_sqlite.rs @@ -1,9 +1,9 @@ use rig::client::EmbeddingsClient; use rig::{ + Embed, embeddings::EmbeddingsBuilder, providers::openai::{Client, TEXT_EMBEDDING_ADA_002}, vector_store::VectorStoreIndex, - Embed, }; use rig_sqlite::{Column, ColumnValue, SqliteVectorStore, SqliteVectorStoreTable}; use rusqlite::ffi::{sqlite3, sqlite3_api_routines, sqlite3_auto_extension}; diff --git a/rig-sqlite/src/lib.rs b/rig-sqlite/src/lib.rs index 1b53c5ba0..1e0e9cc28 100644 --- a/rig-sqlite/src/lib.rs +++ b/rig-sqlite/src/lib.rs @@ -1,6 +1,6 @@ +use rig::OneOrMany; use rig::embeddings::{Embedding, EmbeddingModel}; use rig::vector_store::{VectorStoreError, VectorStoreIndex}; -use rig::OneOrMany; use serde::Deserialize; use std::marker::PhantomData; use tokio_rusqlite::Connection; diff --git a/rig-sqlite/tests/integration_test.rs b/rig-sqlite/tests/integration_test.rs index 9164bdad7..a1995c82e 100644 --- a/rig-sqlite/tests/integration_test.rs +++ b/rig-sqlite/tests/integration_test.rs @@ -3,9 +3,9 @@ use serde_json::json; use rig::client::EmbeddingsClient; use rig::vector_store::VectorStoreIndex; use rig::{ + Embed, OneOrMany, embeddings::{Embedding, EmbeddingsBuilder}, providers::openai, - Embed, OneOrMany, }; use rig_sqlite::{Column, ColumnValue, SqliteVectorStore, SqliteVectorStoreTable}; use rusqlite::ffi::{sqlite3, sqlite3_api_routines, sqlite3_auto_extension}; diff --git a/rig-surrealdb/examples/vector_search_surreal.rs b/rig-surrealdb/examples/vector_search_surreal.rs index 72066c5cd..322f13a10 100644 --- a/rig-surrealdb/examples/vector_search_surreal.rs +++ b/rig-surrealdb/examples/vector_search_surreal.rs @@ -1,5 +1,5 @@ use rig::client::{EmbeddingsClient, ProviderClient}; -use rig::{embeddings::EmbeddingsBuilder, vector_store::VectorStoreIndex, Embed}; +use rig::{Embed, embeddings::EmbeddingsBuilder, vector_store::VectorStoreIndex}; use rig_surrealdb::{Mem, SurrealVectorStore}; use serde::{Deserialize, Serialize}; use surrealdb::Surreal; diff --git a/rig-surrealdb/src/lib.rs b/rig-surrealdb/src/lib.rs index d094303bc..e457e8c93 100644 --- a/rig-surrealdb/src/lib.rs +++ b/rig-surrealdb/src/lib.rs @@ -1,12 +1,12 @@ use std::fmt::Display; use rig::{ + Embed, OneOrMany, embeddings::{Embedding, EmbeddingModel}, vector_store::{VectorStoreError, VectorStoreIndex}, - Embed, OneOrMany, }; -use serde::{de::DeserializeOwned, Deserialize, Serialize}; -use surrealdb::{sql::Thing, Connection, Surreal}; +use serde::{Deserialize, Serialize, de::DeserializeOwned}; +use surrealdb::{Connection, Surreal, sql::Thing}; pub use surrealdb::engine::local::Mem; pub use surrealdb::engine::remote::ws::{Ws, Wss}; From 905073c3ed5edf5bf287cb8e8f38ba544a9c89ae Mon Sep 17 00:00:00 2001 From: Quang Luong Date: Mon, 30 Jun 2025 21:36:13 +0700 Subject: [PATCH 5/5] Use expr directly in macros instead of expr_2021 Since we don't use const or _ expression anywhere, this should be safe --- rig-core/src/pipeline/conditional.rs | 4 ++-- rig-core/src/pipeline/parallel.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rig-core/src/pipeline/conditional.rs b/rig-core/src/pipeline/conditional.rs index 998cc69d1..276c9557f 100644 --- a/rig-core/src/pipeline/conditional.rs +++ b/rig-core/src/pipeline/conditional.rs @@ -46,7 +46,7 @@ /// ``` #[macro_export] macro_rules! conditional { - ($enum:ident, $( $variant:ident => $op:expr_2021 ),+ $(,)?) => { + ($enum:ident, $( $variant:ident => $op:expr ),+ $(,)?) => { { #[allow(non_snake_case)] struct ConditionalOp<$($variant),+> { @@ -125,7 +125,7 @@ macro_rules! conditional { /// ``` #[macro_export] macro_rules! try_conditional { - ($enum:ident, $( $variant:ident => $op:expr_2021 ),+ $(,)?) => { + ($enum:ident, $( $variant:ident => $op:expr ),+ $(,)?) => { { #[allow(non_snake_case)] struct TryConditionalOp<$( $variant ),+> { diff --git a/rig-core/src/pipeline/parallel.rs b/rig-core/src/pipeline/parallel.rs index 17df9187c..32c602e96 100644 --- a/rig-core/src/pipeline/parallel.rs +++ b/rig-core/src/pipeline/parallel.rs @@ -160,7 +160,7 @@ macro_rules! tuple_pattern { #[macro_export] macro_rules! parallel { - ($($es:expr_2021),+ $(,)?) => { + ($($es:expr),+ $(,)?) => { $crate::parallel_internal! { current_position: [] values_and_positions: [] @@ -260,7 +260,7 @@ macro_rules! try_parallel_internal { #[macro_export] macro_rules! try_parallel { - ($($es:expr_2021),+ $(,)?) => { + ($($es:expr),+ $(,)?) => { $crate::try_parallel_internal! { current_position: [] values_and_positions: []