diff --git a/.gitignore b/.gitignore index bcb45aa6..6e26ed7e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ target/ .workspaces/ .beads .jj/ +.codegraph/ # These are backup files generated by rustfmt diff --git a/Cargo.toml b/Cargo.toml index 06924627..b6b9add0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,10 @@ members = [ "vendor/baml/crates/*", ] +[workspace.package] +edition = "2024" +rust-version = "1.96.0" + [patch.crates-io] # TODO(dsrs-facet-pin): switch back to upstream main/release once #2040/#2041 are merged and released. facet = { git = "https://github.com/darinkishore/facet", rev = "cc8613c97cd1ec03e63659db34a947989b45c8a5" } diff --git a/crates/bamltype-derive/Cargo.toml b/crates/bamltype-derive/Cargo.toml index 639e2fce..c25bf50a 100644 --- a/crates/bamltype-derive/Cargo.toml +++ b/crates/bamltype-derive/Cargo.toml @@ -2,6 +2,7 @@ name = "bamltype-derive" version = "0.1.0" edition = "2024" +rust-version = "1.96.0" license = "Apache-2.0" publish = false description = "Attribute macro for facet-based BAML type generation (proc-macro crate)" diff --git a/crates/bamltype/Cargo.toml b/crates/bamltype/Cargo.toml index 174ee13b..c0cc13fc 100644 --- a/crates/bamltype/Cargo.toml +++ b/crates/bamltype/Cargo.toml @@ -2,6 +2,7 @@ name = "bamltype" version = "0.1.0" edition = "2024" +rust-version = "1.96.0" license = "Apache-2.0" publish = false description = "Facet-based BAML type generation" diff --git a/crates/dspy-rs/Cargo.toml b/crates/dspy-rs/Cargo.toml index 94f32610..494e61d1 100644 --- a/crates/dspy-rs/Cargo.toml +++ b/crates/dspy-rs/Cargo.toml @@ -3,6 +3,7 @@ name = "dspy-rs" authors = ["Herumb Shandilya "] version = "0.7.3" edition = "2024" +rust-version = "1.96.0" description = "A DSPy rewrite(not port) to Rust." readme = "../../README.md" documentation = "https://dsrs.herumbshandilya.com" diff --git a/crates/dspy-rs/src/core/dyn_predictor.rs b/crates/dspy-rs/src/core/dyn_predictor.rs index d5a436a8..36450a27 100644 --- a/crates/dspy-rs/src/core/dyn_predictor.rs +++ b/crates/dspy-rs/src/core/dyn_predictor.rs @@ -88,6 +88,93 @@ facet::define_attr_grammar! { } } +pub(crate) mod dsrs { + macro_rules! __attr { + (@ns { $ns:path } predict_accessor { $field:tt : $ty:ty }) => {{ + static __ATTR_DATA: $crate::core::dyn_predictor::Attr = + $crate::core::dyn_predictor::Attr::PredictAccessor(None); + ::facet::Attr::new(Some("dsrs"), "predict_accessor", &__ATTR_DATA) + }}; + (@ns { $ns:path } predict_accessor { $field:tt : $ty:ty | = $value:expr }) => {{ + ::facet::Attr::new( + Some("dsrs"), + "predict_accessor", + &const { $crate::core::dyn_predictor::Attr::PredictAccessor(Some($value)) }, + ) + }}; + (@ns { $ns:path } predict_accessor { $field:tt : $ty:ty | $value:expr }) => {{ + ::facet::Attr::new( + Some("dsrs"), + "predict_accessor", + &const { $crate::core::dyn_predictor::Attr::PredictAccessor(Some($value)) }, + ) + }}; + (@ns { $ns:path } predict_accessor { }) => {{ + static __ATTR_DATA: $crate::core::dyn_predictor::Attr = + $crate::core::dyn_predictor::Attr::PredictAccessor(None); + ::facet::Attr::new(Some("dsrs"), "predict_accessor", &__ATTR_DATA) + }}; + (@ns { $ns:path } predict_accessor { | = $value:expr }) => {{ + ::facet::Attr::new( + Some("dsrs"), + "predict_accessor", + &const { $crate::core::dyn_predictor::Attr::PredictAccessor(Some($value)) }, + ) + }}; + (@ns { $ns:path } predict_accessor { | $value:expr }) => {{ + ::facet::Attr::new( + Some("dsrs"), + "predict_accessor", + &const { $crate::core::dyn_predictor::Attr::PredictAccessor(Some($value)) }, + ) + }}; + (@const @ns { $ns:path } predict_accessor { $field:tt : $ty:ty }) => {{ + ::facet::Attr::new( + Some("dsrs"), + "predict_accessor", + &const { $crate::core::dyn_predictor::Attr::PredictAccessor(None) }, + ) + }}; + (@const @ns { $ns:path } predict_accessor { $field:tt : $ty:ty | = $value:expr }) => {{ + ::facet::Attr::new( + Some("dsrs"), + "predict_accessor", + &const { $crate::core::dyn_predictor::Attr::PredictAccessor(Some($value)) }, + ) + }}; + (@const @ns { $ns:path } predict_accessor { $field:tt : $ty:ty | $value:expr }) => {{ + ::facet::Attr::new( + Some("dsrs"), + "predict_accessor", + &const { $crate::core::dyn_predictor::Attr::PredictAccessor(Some($value)) }, + ) + }}; + (@const @ns { $ns:path } predict_accessor { }) => {{ + ::facet::Attr::new( + Some("dsrs"), + "predict_accessor", + &const { $crate::core::dyn_predictor::Attr::PredictAccessor(None) }, + ) + }}; + (@const @ns { $ns:path } predict_accessor { | = $value:expr }) => {{ + ::facet::Attr::new( + Some("dsrs"), + "predict_accessor", + &const { $crate::core::dyn_predictor::Attr::PredictAccessor(Some($value)) }, + ) + }}; + (@const @ns { $ns:path } predict_accessor { | $value:expr }) => {{ + ::facet::Attr::new( + Some("dsrs"), + "predict_accessor", + &const { $crate::core::dyn_predictor::Attr::PredictAccessor(Some($value)) }, + ) + }}; + } + + pub(crate) use __attr; +} + /// Error from [`visit_named_predictors_mut`] when the Facet walker encounters an unsupported structure. #[derive(Debug, thiserror::Error, PartialEq, Eq)] pub(crate) enum NamedParametersError { @@ -396,7 +483,6 @@ fn pointer_name(pointer: Option) -> &'static str { #[cfg(test)] mod tests { use super::*; - use crate as dsrs; use crate::Signature; use crate::predictors::Predict as RealPredict; use std::ops::ControlFlow; diff --git a/crates/dspy-rs/src/core/lm/mod.rs b/crates/dspy-rs/src/core/lm/mod.rs index 52273430..a539ef34 100644 --- a/crates/dspy-rs/src/core/lm/mod.rs +++ b/crates/dspy-rs/src/core/lm/mod.rs @@ -553,7 +553,7 @@ impl LM { ChoiceAction::ToolCalls { calls, full_content, - assistant_text, + assistant_text: _, } if tool_loop_mode == ToolLoopMode::Auto && !tools.is_empty() => { debug!(count = calls.len(), "entering tool loop"); let result = self diff --git a/crates/dspy-rs/src/predictors/predict.rs b/crates/dspy-rs/src/predictors/predict.rs index 1b35f902..3e3b8f2c 100644 --- a/crates/dspy-rs/src/predictors/predict.rs +++ b/crates/dspy-rs/src/predictors/predict.rs @@ -8,8 +8,9 @@ use std::ops::ControlFlow; use std::sync::Arc; use tracing::{debug, trace}; -use crate as dsrs; -use crate::core::{DynPredictor, Module, PredictAccessorFns, PredictState, Signature}; +use crate::core::{ + DynPredictor, Module, PredictAccessorFns, PredictState, Signature, dyn_predictor::dsrs, +}; use crate::data::example::Example as RawExample; use crate::{ BamlType, BamlValue, CallMetadata, Chat, ChatAdapter, GLOBAL_SETTINGS, LmError, LmUsage, diff --git a/crates/dspy-rs/tests/test_predict_lm_override.rs b/crates/dspy-rs/tests/test_predict_lm_override.rs index 4d2ab610..499fb895 100644 --- a/crates/dspy-rs/tests/test_predict_lm_override.rs +++ b/crates/dspy-rs/tests/test_predict_lm_override.rs @@ -61,9 +61,7 @@ async fn predict_uses_per_instance_lm_over_global() { let (override_lm, _override_client) = make_test_lm(vec![override_response]).await; // Predict with per-instance LM override - let predict = Predict::::builder() - .lm(override_lm) - .build(); + let predict = Predict::::builder().lm(override_lm).build(); let result = predict .call(QAInput { diff --git a/crates/dspy-rs/tests/test_public_api_compile_fail.rs b/crates/dspy-rs/tests/test_public_api_compile_fail.rs index 83c387bc..4a172863 100644 --- a/crates/dspy-rs/tests/test_public_api_compile_fail.rs +++ b/crates/dspy-rs/tests/test_public_api_compile_fail.rs @@ -7,10 +7,12 @@ fn run_compile_fail_case(name: &str, source: &str) -> String { let case_dir = temp.path().join(name); fs::create_dir_all(case_dir.join("src")).expect("case src dir should be creatable"); - let manifest_path = Path::new(env!("CARGO_MANIFEST_DIR")); + let manifest_path = Path::new(env!("CARGO_MANIFEST_DIR")) + .to_string_lossy() + .replace('\\', "/"); let cargo_toml = format!( "[package]\nname = \"{name}\"\nversion = \"0.1.0\"\nedition = \"2024\"\n\n[dependencies]\ndspy-rs = {{ path = \"{}\" }}\nanyhow = \"1\"\n", - manifest_path.display() + manifest_path ); fs::write(case_dir.join("Cargo.toml"), cargo_toml).expect("cargo manifest should be writable"); diff --git a/crates/dsrs-macros/Cargo.toml b/crates/dsrs-macros/Cargo.toml index 4b666638..643f3e07 100644 --- a/crates/dsrs-macros/Cargo.toml +++ b/crates/dsrs-macros/Cargo.toml @@ -2,6 +2,7 @@ name = "dsrs_macros" version = "0.7.2" edition = "2024" +rust-version = "1.96.0" authors = ["Herumb Shandilya "] description = "Derive macros for DSRs (DSPy Rust)" readme = "../../README.md" diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 00000000..0f87b448 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "1.96.0" diff --git a/vendor/baml/crates/baml-ids/Cargo.toml b/vendor/baml/crates/baml-ids/Cargo.toml index a0184f6e..688517cf 100644 --- a/vendor/baml/crates/baml-ids/Cargo.toml +++ b/vendor/baml/crates/baml-ids/Cargo.toml @@ -1,7 +1,8 @@ [package] -edition = "2021" +edition = "2024" name = "baml-ids" version = "0.0.1" +rust-version = "1.96.0" license = "Apache-2.0" publish = false description = "Typesafe IDs for BAML backends and runtime" diff --git a/vendor/baml/crates/baml-types/Cargo.toml b/vendor/baml/crates/baml-types/Cargo.toml index 6ffd089b..3cd4846b 100644 --- a/vendor/baml/crates/baml-types/Cargo.toml +++ b/vendor/baml/crates/baml-types/Cargo.toml @@ -1,7 +1,8 @@ [package] -edition = "2021" +edition = "2024" name = "baml-types" version = "0.1.0" +rust-version = "1.96.0" license = "Apache-2.0" publish = false description = "BAML type system and IR" diff --git a/vendor/baml/crates/baml-types/src/baml_value.rs b/vendor/baml/crates/baml-types/src/baml_value.rs index 1623b2fc..cd6e5ba8 100644 --- a/vendor/baml/crates/baml-types/src/baml_value.rs +++ b/vendor/baml/crates/baml-types/src/baml_value.rs @@ -6,15 +6,16 @@ use std::{ use anyhow::{Context, Result}; use indexmap::IndexMap; use pretty::RcDoc; -use serde::{de::Visitor, ser::SerializeMap, Deserialize, Deserializer, Serialize, Serializer}; +use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Visitor, ser::SerializeMap}; use crate::{ + BamlMap, BamlMedia, HasType, LiteralValue, ResponseCheck, TypeValue, ir_type::{ TypeGeneric, TypeIR, TypeNonStreaming, TypeStreaming, UnionConstructor, UnionTypeViewGeneric, }, media::BamlMediaType, - type_meta, BamlMap, BamlMedia, HasType, LiteralValue, ResponseCheck, TypeValue, + type_meta, }; #[derive(Clone, Debug, PartialEq)] diff --git a/vendor/baml/crates/baml-types/src/expr.rs b/vendor/baml/crates/baml-types/src/expr.rs index 4c5fd2ba..72ee7e0b 100644 --- a/vendor/baml/crates/baml-types/src/expr.rs +++ b/vendor/baml/crates/baml-types/src/expr.rs @@ -7,7 +7,7 @@ use std::{ use internal_baml_diagnostics::Span; use itertools::join; -use crate::{ir_type::TypeIR, BamlMap, BamlValueWithMeta}; +use crate::{BamlMap, BamlValueWithMeta, ir_type::TypeIR}; /// A BAML expression term. /// T is the type of the metadata. diff --git a/vendor/baml/crates/baml-types/src/ir_type/converters/non_streaming.rs b/vendor/baml/crates/baml-types/src/ir_type/converters/non_streaming.rs index a9ca7449..f362afa4 100644 --- a/vendor/baml/crates/baml-types/src/ir_type/converters/non_streaming.rs +++ b/vendor/baml/crates/baml-types/src/ir_type/converters/non_streaming.rs @@ -1,7 +1,8 @@ use crate::{ + StreamingMode, TypeIR, TypeValue, baml_value::TypeLookups, ir_type::{ArrowGeneric, TypeNonStreaming, UnionTypeGeneric}, - type_meta, StreamingMode, TypeIR, TypeValue, + type_meta, }; pub fn from_type_ir(r#type: &TypeIR, _lookup: &impl TypeLookups) -> TypeNonStreaming { diff --git a/vendor/baml/crates/baml-types/src/ir_type/converters/streaming.rs b/vendor/baml/crates/baml-types/src/ir_type/converters/streaming.rs index ebf09bac..a99acab5 100644 --- a/vendor/baml/crates/baml-types/src/ir_type/converters/streaming.rs +++ b/vendor/baml/crates/baml-types/src/ir_type/converters/streaming.rs @@ -1,7 +1,8 @@ use crate::{ + BamlMediaType, StreamingMode, TypeIR, TypeValue, baml_value::TypeLookups, ir_type::{ArrowGeneric, TypeStreaming, UnionTypeGeneric}, - type_meta, BamlMediaType, StreamingMode, TypeIR, TypeValue, + type_meta, }; pub fn from_type_ir(r#type: &TypeIR, lookup: &impl TypeLookups) -> TypeStreaming { diff --git a/vendor/baml/crates/baml-types/src/ir_type/display.rs b/vendor/baml/crates/baml-types/src/ir_type/display.rs index 9d6c8c5b..4be12677 100644 --- a/vendor/baml/crates/baml-types/src/ir_type/display.rs +++ b/vendor/baml/crates/baml-types/src/ir_type/display.rs @@ -1,6 +1,6 @@ use std::fmt::{self, Formatter}; -use super::{type_meta, ConstraintLevel, TypeGeneric}; +use super::{ConstraintLevel, TypeGeneric, type_meta}; use crate::ir_type::UnionTypeViewGeneric; /// ---------- 1. The helper that prints the *core* type string ---------- diff --git a/vendor/baml/crates/baml-types/src/ir_type/mod.rs b/vendor/baml/crates/baml-types/src/ir_type/mod.rs index 41c311b4..343e2f52 100644 --- a/vendor/baml/crates/baml-types/src/ir_type/mod.rs +++ b/vendor/baml/crates/baml-types/src/ir_type/mod.rs @@ -4,9 +4,9 @@ use indexmap::IndexSet; use itertools::Itertools; use crate::{ + BamlMediaType, ConstraintLevel, baml_value::{TypeLookups, TypeLookupsMeta}, type_meta::MayHaveMeta, - BamlMediaType, ConstraintLevel, }; mod builder; @@ -1043,7 +1043,7 @@ pub struct TypeMetaIR { mod tests { use super::*; use crate::{ - ir_type::union_type::UnionConstructor, type_meta::stream::TypeMetaStreaming, Constraint, + Constraint, ir_type::union_type::UnionConstructor, type_meta::stream::TypeMetaStreaming, }; fn make_optional(inner: TypeStreaming) -> TypeStreaming { @@ -1211,84 +1211,105 @@ mod tests { }, TestCase { name: "(A|B)@stream.not_null => (A@stream.not_null|B@stream.not_null)@stream.not_null", - input: make_union(vec![TypeIR::int(), TypeIR::string()], type_meta::IR { - constraints: vec![], - streaming_behavior: type_meta::base::StreamingBehavior { - needed: true, - ..Default::default() - }, - }), - expected: make_union(vec![ - TypeIR::int_with_meta(type_meta::IR { + input: make_union( + vec![TypeIR::int(), TypeIR::string()], + type_meta::IR { constraints: vec![], streaming_behavior: type_meta::base::StreamingBehavior { needed: true, ..Default::default() }, - }), - TypeIR::string_with_meta(type_meta::IR { + }, + ), + expected: make_union( + vec![ + TypeIR::int_with_meta(type_meta::IR { + constraints: vec![], + streaming_behavior: type_meta::base::StreamingBehavior { + needed: true, + ..Default::default() + }, + }), + TypeIR::string_with_meta(type_meta::IR { + constraints: vec![], + streaming_behavior: type_meta::base::StreamingBehavior { + needed: true, + ..Default::default() + }, + }), + ], + type_meta::IR { constraints: vec![], streaming_behavior: type_meta::base::StreamingBehavior { needed: true, ..Default::default() }, - }), - ], type_meta::IR { - constraints: vec![], - streaming_behavior: type_meta::base::StreamingBehavior { - needed: true, - ..Default::default() }, - }), + ), }, TestCase { name: "(A|B)@stream.with_state => (A|B)@stream.with_state", - input: make_union(vec![TypeIR::int(), TypeIR::string()], type_meta::IR { - constraints: vec![], - streaming_behavior: type_meta::base::StreamingBehavior { - state: true, - ..Default::default() + input: make_union( + vec![TypeIR::int(), TypeIR::string()], + type_meta::IR { + constraints: vec![], + streaming_behavior: type_meta::base::StreamingBehavior { + state: true, + ..Default::default() + }, }, - }), - expected: make_union(vec![ - TypeIR::int(), - TypeIR::string(), - ], type_meta::IR { - constraints: vec![], - streaming_behavior: type_meta::base::StreamingBehavior { - state: true, - ..Default::default() + ), + expected: make_union( + vec![TypeIR::int(), TypeIR::string()], + type_meta::IR { + constraints: vec![], + streaming_behavior: type_meta::base::StreamingBehavior { + state: true, + ..Default::default() + }, }, - }), + ), }, - TestCase{ + TestCase { name: "(A@stream_with_state | B@stream_with_state) => (A@stream_with_state | B@stream_with_state)", - input: make_union(vec![TypeIR::int_with_meta(type_meta::IR { - constraints: vec![], - streaming_behavior: type_meta::base::StreamingBehavior { - state: true, - ..Default::default() - }, - }), TypeIR::string_with_meta(type_meta::IR { - constraints: vec![], - streaming_behavior: type_meta::base::StreamingBehavior { - state: true, - ..Default::default() - }, - })], Default::default()), - expected: make_union(vec![TypeIR::int_with_meta(type_meta::IR { - constraints: vec![], - streaming_behavior: type_meta::base::StreamingBehavior { - state: true, - ..Default::default() - }, - }), TypeIR::string_with_meta(type_meta::IR { - constraints: vec![], - streaming_behavior: type_meta::base::StreamingBehavior { - state: true, - ..Default::default() - }, - })], Default::default()) + input: make_union( + vec![ + TypeIR::int_with_meta(type_meta::IR { + constraints: vec![], + streaming_behavior: type_meta::base::StreamingBehavior { + state: true, + ..Default::default() + }, + }), + TypeIR::string_with_meta(type_meta::IR { + constraints: vec![], + streaming_behavior: type_meta::base::StreamingBehavior { + state: true, + ..Default::default() + }, + }), + ], + Default::default(), + ), + expected: make_union( + vec![ + TypeIR::int_with_meta(type_meta::IR { + constraints: vec![], + streaming_behavior: type_meta::base::StreamingBehavior { + state: true, + ..Default::default() + }, + }), + TypeIR::string_with_meta(type_meta::IR { + constraints: vec![], + streaming_behavior: type_meta::base::StreamingBehavior { + state: true, + ..Default::default() + }, + }), + ], + Default::default(), + ), }, ]; diff --git a/vendor/baml/crates/baml-types/src/ir_type/simplify/ir.rs b/vendor/baml/crates/baml-types/src/ir_type/simplify/ir.rs index 34b2b410..08141ca2 100644 --- a/vendor/baml/crates/baml-types/src/ir_type/simplify/ir.rs +++ b/vendor/baml/crates/baml-types/src/ir_type/simplify/ir.rs @@ -1,8 +1,9 @@ use itertools::Itertools; use crate::{ + ConstraintLevel, ir_type::{TypeGeneric, UnionTypeGeneric}, - type_meta, ConstraintLevel, + type_meta, }; /// Strip metadata from a type for comparison purposes. diff --git a/vendor/baml/crates/baml-types/src/ir_type/simplify/non_streaming.rs b/vendor/baml/crates/baml-types/src/ir_type/simplify/non_streaming.rs index 32204c15..a64ce647 100644 --- a/vendor/baml/crates/baml-types/src/ir_type/simplify/non_streaming.rs +++ b/vendor/baml/crates/baml-types/src/ir_type/simplify/non_streaming.rs @@ -1,8 +1,9 @@ use itertools::Itertools; use crate::{ + ConstraintLevel, ir_type::{TypeGeneric, UnionTypeGeneric}, - type_meta, ConstraintLevel, + type_meta, }; impl TypeGeneric { diff --git a/vendor/baml/crates/baml-types/src/ir_type/union_type.rs b/vendor/baml/crates/baml-types/src/ir_type/union_type.rs index 3963bc5c..fc6e2778 100644 --- a/vendor/baml/crates/baml-types/src/ir_type/union_type.rs +++ b/vendor/baml/crates/baml-types/src/ir_type/union_type.rs @@ -1,4 +1,4 @@ -use super::{type_meta, TypeGeneric, UnionTypeGeneric}; +use super::{TypeGeneric, UnionTypeGeneric, type_meta}; impl UnionTypeGeneric { // disallow construction so people have to use: @@ -12,7 +12,9 @@ impl UnionTypeGeneric { pub(crate) unsafe fn new_unsafe(types: Vec>) -> Self { if types.iter().all(|t| t.is_null()) { - panic!("FATAL, please report this bug: Union type must have at least one non-null type. Got {types:?}"); + panic!( + "FATAL, please report this bug: Union type must have at least one non-null type. Got {types:?}" + ); } Self { types, diff --git a/vendor/baml/crates/baml-types/src/lib.rs b/vendor/baml/crates/baml-types/src/lib.rs index fe3b7241..a7a5fd84 100644 --- a/vendor/baml/crates/baml-types/src/lib.rs +++ b/vendor/baml/crates/baml-types/src/lib.rs @@ -23,8 +23,8 @@ pub use baml_value::{BamlValue, BamlValueWithMeta, Completion, CompletionState}; pub use constraint::*; pub use generator::{GeneratorDefaultClientMode, GeneratorOutputType}; pub use ir_type::{ - type_meta, Arrow, HasType, LiteralValue, StreamingMode, ToUnionName, TypeIR, TypeValue, - UnionType, UnionTypeView, + Arrow, HasType, LiteralValue, StreamingMode, ToUnionName, TypeIR, TypeValue, UnionType, + UnionTypeView, type_meta, }; pub use map::Map as BamlMap; pub use media::{BamlMedia, BamlMediaContent, BamlMediaType, MediaBase64, MediaFile, MediaUrl}; diff --git a/vendor/baml/crates/baml-types/src/tracing/events.rs b/vendor/baml/crates/baml-types/src/tracing/events.rs index 4752d624..c9a72c1b 100644 --- a/vendor/baml/crates/baml-types/src/tracing/events.rs +++ b/vendor/baml/crates/baml-types/src/tracing/events.rs @@ -6,7 +6,7 @@ use indexmap::IndexMap; use serde::{Deserialize, Serialize}; pub use super::errors::BamlError; -use crate::{type_meta, BamlMap, BamlMedia, BamlValueWithMeta, HasType}; +use crate::{BamlMap, BamlMedia, BamlValueWithMeta, HasType, type_meta}; pub type TraceTags = serde_json::Map; diff --git a/vendor/baml/crates/bstd/Cargo.toml b/vendor/baml/crates/bstd/Cargo.toml index 99f78f40..f4e92fe3 100644 --- a/vendor/baml/crates/bstd/Cargo.toml +++ b/vendor/baml/crates/bstd/Cargo.toml @@ -1,7 +1,8 @@ [package] -edition = "2021" +edition = "2024" name = "bstd" version = "0.1.0" +rust-version = "1.96.0" license = "Apache-2.0" publish = false description = "BAML standard utilities" diff --git a/vendor/baml/crates/bstd/src/lib.rs b/vendor/baml/crates/bstd/src/lib.rs index 80b5483c..e83217fd 100644 --- a/vendor/baml/crates/bstd/src/lib.rs +++ b/vendor/baml/crates/bstd/src/lib.rs @@ -2,7 +2,7 @@ mod dedent; mod project_fqn; mod random_word_id; -pub use dedent::{dedent, DedentedString}; +pub use dedent::{DedentedString, dedent}; use num::Integer; pub use project_fqn::ProjectFqn; pub use random_word_id::random_word_id; diff --git a/vendor/baml/crates/bstd/src/random_word_id.rs b/vendor/baml/crates/bstd/src/random_word_id.rs index 537818dc..b447895e 100644 --- a/vendor/baml/crates/bstd/src/random_word_id.rs +++ b/vendor/baml/crates/bstd/src/random_word_id.rs @@ -1,4 +1,4 @@ -use rand::{seq::SliceRandom, Rng}; +use rand::{Rng, seq::SliceRandom}; const TAILS: &[&str] = &[ "orca", diff --git a/vendor/baml/crates/internal-baml-diagnostics/Cargo.toml b/vendor/baml/crates/internal-baml-diagnostics/Cargo.toml index 1e8b595e..45270315 100644 --- a/vendor/baml/crates/internal-baml-diagnostics/Cargo.toml +++ b/vendor/baml/crates/internal-baml-diagnostics/Cargo.toml @@ -1,7 +1,8 @@ [package] -edition = "2021" +edition = "2024" name = "internal-baml-diagnostics" version = "0.1.0" +rust-version = "1.96.0" license = "Apache-2.0" publish = false description = "Internal diagnostics support for BAML" diff --git a/vendor/baml/crates/internal-baml-diagnostics/src/collection.rs b/vendor/baml/crates/internal-baml-diagnostics/src/collection.rs index a4c01084..2b1eb84c 100644 --- a/vendor/baml/crates/internal-baml-diagnostics/src/collection.rs +++ b/vendor/baml/crates/internal-baml-diagnostics/src/collection.rs @@ -1,7 +1,7 @@ use std::{collections::HashMap, path::PathBuf}; use super::DatamodelError; -use crate::{warning::DatamodelWarning, SourceFile, Span}; +use crate::{SourceFile, Span, warning::DatamodelWarning}; /// Represents a list of validation or parser errors and warnings. /// diff --git a/vendor/baml/crates/internal-baml-diagnostics/src/error.rs b/vendor/baml/crates/internal-baml-diagnostics/src/error.rs index fc9a43e4..b40558e9 100644 --- a/vendor/baml/crates/internal-baml-diagnostics/src/error.rs +++ b/vendor/baml/crates/internal-baml-diagnostics/src/error.rs @@ -3,8 +3,8 @@ use std::{borrow::Cow, iter::Iterator, ops::Index}; use colored::{ColoredString, Colorize}; use crate::{ - pretty_print::{pretty_print, DiagnosticColorer}, Span, + pretty_print::{DiagnosticColorer, pretty_print}, }; #[derive(Debug, Clone)] @@ -116,7 +116,9 @@ impl DatamodelError { given_count: usize, span: Span, ) -> DatamodelError { - let msg = format!("Function \"{function_name}\" takes {required_count} arguments, but received {given_count}."); + let msg = format!( + "Function \"{function_name}\" takes {required_count} arguments, but received {given_count}." + ); Self::new(msg, span) } @@ -193,7 +195,9 @@ impl DatamodelError { suggestion: &str, span: Span, ) -> DatamodelError { - let msg = format!("The prefix {given_prefix} is invalid. It must be equal to the name of an existing datasource e.g. {expected_prefix}. Did you mean to use {suggestion}?"); + let msg = format!( + "The prefix {given_prefix} is invalid. It must be equal to the name of an existing datasource e.g. {expected_prefix}. Did you mean to use {suggestion}?" + ); DatamodelError::new(msg, span) } @@ -217,7 +221,9 @@ impl DatamodelError { existing_model_name: &str, span: Span, ) -> DatamodelError { - let msg = format!("The model with database name \"{model_database_name}\" could not be defined because another model or view with this name exists: \"{existing_model_name}\""); + let msg = format!( + "The model with database name \"{model_database_name}\" could not be defined because another model or view with this name exists: \"{existing_model_name}\"" + ); Self::new(msg, span) } @@ -226,7 +232,9 @@ impl DatamodelError { existing_model_name: &str, span: Span, ) -> DatamodelError { - let msg = format!("The view with database name \"{model_database_name}\" could not be defined because another model or view with this name exists: \"{existing_model_name}\""); + let msg = format!( + "The view with database name \"{model_database_name}\" could not be defined because another model or view with this name exists: \"{existing_model_name}\"" + ); Self::new(msg, span) } @@ -333,7 +341,9 @@ impl DatamodelError { pub fn new_invalid_function_syntax_error(func_name: &str, span: Span) -> DatamodelError { Self::new( - format!("Invalid syntax for function \"{func_name}\". Use:\nfunction {func_name}(params...) -> ReturnType {{ ... }}"), + format!( + "Invalid syntax for function \"{func_name}\". Use:\nfunction {func_name}(params...) -> ReturnType {{ ... }}" + ), span, ) } @@ -376,7 +386,9 @@ impl DatamodelError { field_name: &str, span: Span, ) -> DatamodelError { - let msg = format!("Field \"{field_name}\" in {container} \"{container_name}\" can't be a list. The current connector does not support lists of primitive types."); + let msg = format!( + "Field \"{field_name}\" in {container} \"{container_name}\" can't be a list. The current connector does not support lists of primitive types." + ); Self::new(msg, span) } @@ -645,19 +657,20 @@ impl DatamodelError { { let close_names = sort_by_match(property_name, &alternatives, None); - Self::new(match close_names.len() { - 0 => format!("Property not known: \"{property_name}\".",), - 1 => - format!( + Self::new( + match close_names.len() { + 0 => format!("Property not known: \"{property_name}\".",), + 1 => format!( "Property not known: \"{property_name}\". Did you mean this: \"{close_name}\"?", close_name = close_names[0] ), - _ => - format!( + _ => format!( "Property not known: \"{property_name}\". Did you mean one of these: \"{close_names}\"?", close_names = close_names.join("\", \"") ), - }, span) + }, + span, + ) } pub fn new_argument_not_known_error(property_name: &str, span: Span) -> DatamodelError { diff --git a/vendor/baml/crates/internal-baml-diagnostics/src/span.rs b/vendor/baml/crates/internal-baml-diagnostics/src/span.rs index 105b7b11..ac90b800 100644 --- a/vendor/baml/crates/internal-baml-diagnostics/src/span.rs +++ b/vendor/baml/crates/internal-baml-diagnostics/src/span.rs @@ -69,7 +69,7 @@ impl Span { } pub fn line_number(&self) -> usize { - self.line_and_column().0 .0 + self.line_and_column().0.0 } /// Create a fake span. Useful when generating test data that requires diff --git a/vendor/baml/crates/internal-baml-diagnostics/src/warning.rs b/vendor/baml/crates/internal-baml-diagnostics/src/warning.rs index a64dc744..c43d745e 100644 --- a/vendor/baml/crates/internal-baml-diagnostics/src/warning.rs +++ b/vendor/baml/crates/internal-baml-diagnostics/src/warning.rs @@ -1,9 +1,9 @@ use colored::{ColoredString, Colorize}; use crate::{ - error::sort_by_match, - pretty_print::{pretty_print, DiagnosticColorer}, Span, + error::sort_by_match, + pretty_print::{DiagnosticColorer, pretty_print}, }; // use indoc::indoc; diff --git a/vendor/baml/crates/internal-baml-jinja/Cargo.toml b/vendor/baml/crates/internal-baml-jinja/Cargo.toml index 77ad5490..1e171f5a 100644 --- a/vendor/baml/crates/internal-baml-jinja/Cargo.toml +++ b/vendor/baml/crates/internal-baml-jinja/Cargo.toml @@ -1,7 +1,8 @@ [package] name = "internal-baml-jinja" -edition = "2021" +edition = "2024" version = "0.1.0" +rust-version = "1.96.0" license = "Apache-2.0" publish = false description = "Internal BAML Jinja runtime" diff --git a/vendor/baml/crates/internal-baml-jinja/src/output_format/types.rs b/vendor/baml/crates/internal-baml-jinja/src/output_format/types.rs index 23cb1f0b..89950241 100644 --- a/vendor/baml/crates/internal-baml-jinja/src/output_format/types.rs +++ b/vendor/baml/crates/internal-baml-jinja/src/output_format/types.rs @@ -1,7 +1,7 @@ use std::{ops::Deref, sync::Arc}; use anyhow::Result; -use baml_types::{ir_type::UnionTypeViewGeneric, type_meta, Constraint, TypeIR, TypeValue}; +use baml_types::{Constraint, TypeIR, TypeValue, ir_type::UnionTypeViewGeneric, type_meta}; use indexmap::{IndexMap, IndexSet}; #[derive(Debug, PartialEq, Eq)] @@ -754,7 +754,7 @@ impl OutputFormatContent { return Err(minijinja::Error::new( minijinja::ErrorKind::BadSerialization, format!("type '{media_type}' is not supported in outputs"), - )) + )); } }, TypeIR::Literal(v, _) => v.to_string(), @@ -847,7 +847,7 @@ impl OutputFormatContent { return Err(minijinja::Error::new( minijinja::ErrorKind::BadSerialization, "Tuple type is not supported in outputs", - )) + )); } TypeIR::Map(key_type, value_type, _) => MapRender { style: &options.map_style, @@ -859,7 +859,7 @@ impl OutputFormatContent { return Err(minijinja::Error::new( minijinja::ErrorKind::BadSerialization, "Arrow type is not supported in LLM function outputs", - )) + )); } TypeIR::Top(_) => panic!( "TypeIR::Top should have been resolved by the compiler before code generation. \ diff --git a/vendor/baml/crates/jsonish/Cargo.toml b/vendor/baml/crates/jsonish/Cargo.toml index 51657d0c..362f89ee 100644 --- a/vendor/baml/crates/jsonish/Cargo.toml +++ b/vendor/baml/crates/jsonish/Cargo.toml @@ -1,7 +1,8 @@ [package] -edition = "2021" +edition = "2024" name = "jsonish" version = "0.1.0" +rust-version = "1.96.0" license = "Apache-2.0" publish = false description = "Jsonish parser and coercer for BAML" diff --git a/vendor/baml/crates/jsonish/src/deserializer/coercer/array_helper.rs b/vendor/baml/crates/jsonish/src/deserializer/coercer/array_helper.rs index df39fdfb..963d387f 100644 --- a/vendor/baml/crates/jsonish/src/deserializer/coercer/array_helper.rs +++ b/vendor/baml/crates/jsonish/src/deserializer/coercer/array_helper.rs @@ -133,11 +133,11 @@ pub(super) fn pick_best( match (unparseables_a, unparseables_b) { // If A has no unparseables and B has unparseables and B is empty, prefer A (0, b) if b > 0 && items_b.is_empty() => { - return std::cmp::Ordering::Less + return std::cmp::Ordering::Less; } // If A has unparseables and B has no unparseables and A is empty, prefer B (a, 0) if a > 0 && items_a.is_empty() => { - return std::cmp::Ordering::Greater + return std::cmp::Ordering::Greater; } _ => {} } diff --git a/vendor/baml/crates/jsonish/src/deserializer/coercer/coerce_literal.rs b/vendor/baml/crates/jsonish/src/deserializer/coercer/coerce_literal.rs index 8a402b80..e0b57120 100644 --- a/vendor/baml/crates/jsonish/src/deserializer/coercer/coerce_literal.rs +++ b/vendor/baml/crates/jsonish/src/deserializer/coercer/coerce_literal.rs @@ -3,10 +3,10 @@ use std::vec; use anyhow::Result; use baml_types::{LiteralValue, TypeIR}; -use super::{coerce_primitive::coerce_int, ParsingContext, ParsingError}; +use super::{ParsingContext, ParsingError, coerce_primitive::coerce_int}; use crate::{ deserializer::{ - coercer::{coerce_primitive::coerce_bool, match_string::match_string, TypeCoercer}, + coercer::{TypeCoercer, coerce_primitive::coerce_bool, match_string::match_string}, deserialize_flags::{DeserializerConditions, Flag}, types::BamlValueWithFlags, }, diff --git a/vendor/baml/crates/jsonish/src/deserializer/coercer/coerce_primitive.rs b/vendor/baml/crates/jsonish/src/deserializer/coercer/coerce_primitive.rs index 3fdc2d03..4104ad48 100644 --- a/vendor/baml/crates/jsonish/src/deserializer/coercer/coerce_primitive.rs +++ b/vendor/baml/crates/jsonish/src/deserializer/coercer/coerce_primitive.rs @@ -2,7 +2,7 @@ use anyhow::Result; use baml_types::{BamlMediaType, CompletionState, TypeIR, TypeValue}; use regex::Regex; -use super::{array_helper::coerce_array_to_singular, ParsingContext, ParsingError}; +use super::{ParsingContext, ParsingError, array_helper::coerce_array_to_singular}; use crate::deserializer::{ coercer::TypeCoercer, deserialize_flags::{DeserializerConditions, Flag}, diff --git a/vendor/baml/crates/jsonish/src/deserializer/coercer/field_type.rs b/vendor/baml/crates/jsonish/src/deserializer/coercer/field_type.rs index 8b80f36a..7a796cfd 100644 --- a/vendor/baml/crates/jsonish/src/deserializer/coercer/field_type.rs +++ b/vendor/baml/crates/jsonish/src/deserializer/coercer/field_type.rs @@ -4,17 +4,16 @@ use baml_types::{ }; use super::{ - array_helper, + ParsingContext, ParsingError, array_helper, coerce_array::coerce_array, coerce_map::coerce_map, coerce_union::coerce_union, - ir_ref::{coerce_alias::coerce_alias, IrRef}, - ParsingContext, ParsingError, + ir_ref::{IrRef, coerce_alias::coerce_alias}, }; use crate::deserializer::{ coercer::{ - coerce_array::try_cast_array, coerce_map::try_cast_map, coerce_union::try_cast_union, - ir_ref::coerce_alias::try_cast_alias, run_user_checks, DefaultValue, TypeCoercer, + DefaultValue, TypeCoercer, coerce_array::try_cast_array, coerce_map::try_cast_map, + coerce_union::try_cast_union, ir_ref::coerce_alias::try_cast_alias, run_user_checks, }, deserialize_flags::{DeserializerConditions, Flag}, types::BamlValueWithFlags, @@ -292,7 +291,7 @@ impl DefaultValue for TypeIR { .iter() .find_map(|i| i.default_value(error)), TypeIR::Primitive(TypeValue::Null, _) => { - return Some(BamlValueWithFlags::Null(self.clone(), get_flags())) + return Some(BamlValueWithFlags::Null(self.clone(), get_flags())); } TypeIR::Map(..) => Some(BamlValueWithFlags::Map( get_flags(), diff --git a/vendor/baml/crates/jsonish/src/deserializer/coercer/ir_ref/coerce_class.rs b/vendor/baml/crates/jsonish/src/deserializer/coercer/ir_ref/coerce_class.rs index 2b736338..b38b2544 100644 --- a/vendor/baml/crates/jsonish/src/deserializer/coercer/ir_ref/coerce_class.rs +++ b/vendor/baml/crates/jsonish/src/deserializer/coercer/ir_ref/coerce_class.rs @@ -5,10 +5,10 @@ use internal_baml_jinja::types::{Class, Name}; use super::ParsingContext; use crate::deserializer::{ coercer::{ - array_helper, + DefaultValue, ParsingError, TypeCoercer, array_helper, field_type::validate_asserts, match_string::{match_string, matches_string_to_string}, - run_user_checks, DefaultValue, ParsingError, TypeCoercer, + run_user_checks, }, deserialize_flags::{DeserializerConditions, Flag}, types::BamlValueWithFlags, @@ -84,7 +84,7 @@ impl TypeCoercer for Class { let flags = DeserializerConditions::new(); for (k, v) in obj.iter() { if let Some(&idx) = key_to_idx.get(k.as_str()) { - let (_, field_type, ref mut val) = &mut field_states[idx]; + let (_, field_type, val) = &mut field_states[idx]; if matches!(val, Triple::Present(_)) { continue; } diff --git a/vendor/baml/crates/jsonish/src/deserializer/coercer/ir_ref/coerce_enum.rs b/vendor/baml/crates/jsonish/src/deserializer/coercer/ir_ref/coerce_enum.rs index 1300ffb2..969f3128 100644 --- a/vendor/baml/crates/jsonish/src/deserializer/coercer/ir_ref/coerce_enum.rs +++ b/vendor/baml/crates/jsonish/src/deserializer/coercer/ir_ref/coerce_enum.rs @@ -5,8 +5,8 @@ use internal_baml_jinja::types::Enum; use super::ParsingContext; use crate::deserializer::{ coercer::{ - ir_ref::coerce_class::apply_constraints, match_string::match_string, ParsingError, - TypeCoercer, + ParsingError, TypeCoercer, ir_ref::coerce_class::apply_constraints, + match_string::match_string, }, types::BamlValueWithFlags, }; diff --git a/vendor/baml/crates/jsonish/src/jsonish/mod.rs b/vendor/baml/crates/jsonish/src/jsonish/mod.rs index 65c6fa1f..b1e399c8 100644 --- a/vendor/baml/crates/jsonish/src/jsonish/mod.rs +++ b/vendor/baml/crates/jsonish/src/jsonish/mod.rs @@ -1,5 +1,5 @@ mod parser; mod value; -pub use parser::{parse, ParseOptions}; +pub use parser::{ParseOptions, parse}; pub use value::{Fixes, Value}; diff --git a/vendor/baml/crates/jsonish/src/jsonish/parser/entry.rs b/vendor/baml/crates/jsonish/src/jsonish/parser/entry.rs index 52531eb2..1fa429ef 100644 --- a/vendor/baml/crates/jsonish/src/jsonish/parser/entry.rs +++ b/vendor/baml/crates/jsonish/src/jsonish/parser/entry.rs @@ -3,13 +3,13 @@ use baml_types::CompletionState; use super::ParseOptions; use crate::jsonish::{ + Value, parser::{ fixing_parser, markdown_parser::{self, MarkdownResult}, multi_json_parser, }, value::Fixes, - Value, }; pub(super) fn parse_func(str: &str, mut options: ParseOptions, is_done: bool) -> Result { diff --git a/vendor/baml/crates/jsonish/src/jsonish/parser/fixing_parser.rs b/vendor/baml/crates/jsonish/src/jsonish/parser/fixing_parser.rs index f62a8fb9..ba9270a6 100644 --- a/vendor/baml/crates/jsonish/src/jsonish/parser/fixing_parser.rs +++ b/vendor/baml/crates/jsonish/src/jsonish/parser/fixing_parser.rs @@ -6,7 +6,7 @@ use baml_types::CompletionState; use self::json_parse_state::JsonParseState; use super::ParseOptions; -use crate::jsonish::{value::Fixes, Value}; +use crate::jsonish::{Value, value::Fixes}; pub fn parse(str: &str, _options: &ParseOptions) -> Result)>> { // Try to fix some common JSON issues diff --git a/vendor/baml/crates/jsonish/src/jsonish/parser/fixing_parser/json_collection.rs b/vendor/baml/crates/jsonish/src/jsonish/parser/fixing_parser/json_collection.rs index e4519baa..5185eb23 100644 --- a/vendor/baml/crates/jsonish/src/jsonish/parser/fixing_parser/json_collection.rs +++ b/vendor/baml/crates/jsonish/src/jsonish/parser/fixing_parser/json_collection.rs @@ -69,7 +69,7 @@ impl From for Option { fn from(collection: JsonCollection) -> Option { Some(match collection { JsonCollection::TrailingComment(_, _) | JsonCollection::BlockComment(_, _) => { - return None + return None; } JsonCollection::Object(keys, values, object_completion) => { // log::debug!("keys: {:?}", keys); diff --git a/vendor/baml/crates/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs b/vendor/baml/crates/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs index 3fb632b9..4992c274 100644 --- a/vendor/baml/crates/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs +++ b/vendor/baml/crates/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs @@ -4,7 +4,7 @@ use anyhow::Result; use baml_types::CompletionState; use super::json_collection::JsonCollection; -use crate::jsonish::{value::Fixes, Value}; +use crate::jsonish::{Value, value::Fixes}; /// Tracks quote and backslash state incrementally for quoted strings /// to avoid O(n²) rescanning when determining if a quote closes a string. @@ -215,7 +215,7 @@ impl JsonParseState { match c { // If at some point we find a valid json character, we'll close the string '{' | '[' => { - return CloseStringResult::Close(idx, CompletionState::Complete) + return CloseStringResult::Close(idx, CompletionState::Complete); } x => { let _ = self.consume(x); @@ -294,7 +294,9 @@ impl JsonParseState { } else { // Likely end of the key as the LLM generated a ", " token by mistake instead of a "," // so drop the comma - log::debug!("Closing due to: newline after comma + space"); + log::debug!( + "Closing due to: newline after comma + space" + ); return CloseStringResult::Close( idx, CompletionState::Complete, @@ -322,7 +324,9 @@ impl JsonParseState { }, '"' => { // This is likely a new key - log::debug!("Closing due to: new key after space + comma"); + log::debug!( + "Closing due to: new key after space + comma" + ); return CloseStringResult::Close( idx, CompletionState::Complete, diff --git a/vendor/baml/crates/jsonish/src/jsonish/parser/markdown_parser.rs b/vendor/baml/crates/jsonish/src/jsonish/parser/markdown_parser.rs index 5e82915b..85bc3087 100644 --- a/vendor/baml/crates/jsonish/src/jsonish/parser/markdown_parser.rs +++ b/vendor/baml/crates/jsonish/src/jsonish/parser/markdown_parser.rs @@ -4,8 +4,8 @@ use anyhow::Result; use super::ParseOptions; use crate::jsonish::{ - parser::{entry, ParsingMode}, Value, + parser::{ParsingMode, entry}, }; #[derive(Debug)] @@ -58,11 +58,12 @@ pub fn parse(str: &str, options: &ParseOptions) -> Result> { for end in ends.iter() { let candidate = after_start[..end.start()].trim(); - if let Ok(v) = super::entry::parse_func( + let parsed = super::entry::parse_func( candidate, options.next_from_mode(ParsingMode::JsonMarkdown), false, - ) { + ); + if let Ok(v) = parsed { parsed_value = Some(v); chosen_end = *end; md_content = candidate; @@ -163,15 +164,17 @@ print("Hello, world!") let Value::AnyOf(value, _) = value else { panic!("Expected AnyOf, got {value:#?}"); }; - assert!(value.contains(&Value::Object( - [( - "a".to_string(), - Value::Number((1).into(), CompletionState::Complete) - )] - .into_iter() - .collect(), - CompletionState::Complete - ))); + assert!( + value.contains(&Value::Object( + [( + "a".to_string(), + Value::Number((1).into(), CompletionState::Complete) + )] + .into_iter() + .collect(), + CompletionState::Complete + )) + ); } { let (tag, value) = if let MarkdownResult::CodeBlock(tag, value) = &res[1] { @@ -257,8 +260,8 @@ dolor sit amet } #[test] - fn fence_like_sequence_inside_triple_backtick_string_does_not_split_markdown_blocks( - ) -> Result<()> { + fn fence_like_sequence_inside_triple_backtick_string_does_not_split_markdown_blocks() + -> Result<()> { let res = parse( r#" ```json diff --git a/vendor/baml/crates/jsonish/src/jsonish/parser/multi_json_parser.rs b/vendor/baml/crates/jsonish/src/jsonish/parser/multi_json_parser.rs index 11f259fc..d98468e5 100644 --- a/vendor/baml/crates/jsonish/src/jsonish/parser/multi_json_parser.rs +++ b/vendor/baml/crates/jsonish/src/jsonish/parser/multi_json_parser.rs @@ -1,6 +1,6 @@ use anyhow::Result; -use super::{entry, ParseOptions}; +use super::{ParseOptions, entry}; use crate::jsonish::Value; pub fn parse(str: &str, options: &ParseOptions) -> Result> { @@ -34,11 +34,12 @@ pub fn parse(str: &str, options: &ParseOptions) -> Result> { } else { &str[..end_index] }; - match entry::parse_func( + let parsed = entry::parse_func( json_str, options.next_from_mode(super::ParsingMode::AllJsonObjects), false, - ) { + ); + match parsed { Ok(json) => json_objects.push(json), Err(e) => { // Ignore errors @@ -124,15 +125,17 @@ print("Hello, world!") let Value::AnyOf(value, _) = value else { panic!("Expected AnyOf, got {value:#?}"); }; - assert!(value.contains(&Value::Object( - [( - "a".to_string(), - Value::Number((1).into(), CompletionState::Complete) - )] - .into_iter() - .collect(), - CompletionState::Complete - ))); + assert!( + value.contains(&Value::Object( + [( + "a".to_string(), + Value::Number((1).into(), CompletionState::Complete) + )] + .into_iter() + .collect(), + CompletionState::Complete + )) + ); } { let value = &res[1]; diff --git a/vendor/baml/crates/jsonish/src/lib.rs b/vendor/baml/crates/jsonish/src/lib.rs index ac8da0ec..76e2f0e9 100644 --- a/vendor/baml/crates/jsonish/src/lib.rs +++ b/vendor/baml/crates/jsonish/src/lib.rs @@ -7,8 +7,8 @@ pub mod jsonish; use baml_types::TypeValue; use baml_types::{ - type_meta, BamlValue, BamlValueWithMeta, Completion, CompletionState, HasType, JinjaExpression, - ResponseCheck, TypeIR, + BamlValue, BamlValueWithMeta, Completion, CompletionState, HasType, JinjaExpression, + ResponseCheck, TypeIR, type_meta, }; pub use deserializer::types::BamlValueWithFlags; use deserializer::{ @@ -19,8 +19,8 @@ use deserializer::{ use internal_baml_jinja::types::OutputFormatContent; use jsonish::Value; use serde::{ - ser::{SerializeMap, SerializeStruct}, Serialize, Serializer, + ser::{SerializeMap, SerializeStruct}, }; use crate::deserializer::score::WithScore; @@ -88,31 +88,31 @@ impl serde::Serialize for SerializeResponseBamlValue<'_> { let serialize_mode = &self.serialize_mode; match &self.value { - String(s, ref meta) => { + String(s, meta) => { log::debug!("Serializing string"); serialize_with_meta(&s, meta, serialize_mode, serializer) } - Int(i, ref meta) => { + Int(i, meta) => { log::debug!("Serializing int"); serialize_with_meta(&i, meta, serialize_mode, serializer) } - Float(f, ref meta) => { + Float(f, meta) => { log::debug!("Serializing float"); serialize_with_meta(&f, meta, serialize_mode, serializer) } - Bool(b, ref meta) => { + Bool(b, meta) => { log::debug!("Serializing bool"); serialize_with_meta(&b, meta, serialize_mode, serializer) } - Media(v, ref meta) => { + Media(v, meta) => { log::debug!("Serializing media"); serialize_with_meta(&v, meta, serialize_mode, serializer) } - Enum(ref name, v, ref meta) => { + Enum(name, v, meta) => { log::debug!("Serializing enum {name}"); serialize_with_meta(&v, meta, serialize_mode, serializer) } - Map(items, ref meta) => { + Map(items, meta) => { log::debug!("Serializing map"); let new_items = items .into_iter() @@ -128,7 +128,7 @@ impl serde::Serialize for SerializeResponseBamlValue<'_> { .collect::>>(); serialize_with_meta(&new_items, meta, serialize_mode, serializer) } - List(items, ref meta) => { + List(items, meta) => { log::debug!("Serializing list"); let new_items = items .iter() @@ -139,7 +139,7 @@ impl serde::Serialize for SerializeResponseBamlValue<'_> { .collect::>(); serialize_with_meta(&new_items, meta, serialize_mode, serializer) } - Class(name, fields, ref meta) => { + Class(name, fields, meta) => { log::debug!("Serializing class {name}"); let new_fields = fields .into_iter() @@ -166,7 +166,7 @@ impl serde::Serialize for SerializeResponseBamlValue<'_> { .collect::>(); serialize_with_meta(&new_fields, meta, serialize_mode, serializer) } - Null(ref meta) => { + Null(meta) => { log::debug!("Serializing null"); serialize_with_meta(&(), meta, serialize_mode, serializer) } @@ -182,12 +182,12 @@ impl<'a, T: Serialize> serde::Serialize for ResponseChecksMetadata<'a, T> { fn serialize(&self, serializer: S) -> Result { let checks_map: HashMap<_, _> = self .0 - .1 + .1 .iter() .map(|check| (check.name.clone(), check)) .collect(); let mut state = serializer.serialize_struct("Checked", 2)?; - state.serialize_field("value", &self.0 .0)?; + state.serialize_field("value", &self.0.0)?; state.serialize_field("checks", &checks_map)?; state.end() }