Skip to content

Commit 825d39e

Browse files
committed
chore: #1086 clean up unused imports, fix typos, and organize style
- removed unused imports - fixed typos in code and comments - reorganized function for improved readability and style
1 parent fa200b2 commit 825d39e

File tree

86 files changed

+213
-221
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+213
-221
lines changed

CHANGELOG.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ The default base URL for the Gemini provider has been updated to v1beta. This ch
368368
- LLVM install and rebuild script (#794) - ([9ee66ed](https://github.com/boundaryml/baml/commit/9ee66ed2dd14bc0ee12a788f41eae64377e7f2b0)) - Anish Palakurthi
369369
- Prevent version mismatches when generating baml_client (#791) - ([d793603](https://github.com/boundaryml/baml/commit/d7936036e6afa4a0e738242cfb3feaa9e15b3657)) - aaronvg
370370
- fiddle build fix (#800) - ([d304203](https://github.com/boundaryml/baml/commit/d304203241726ac0ba8781db7ac5693339189eb4)) - aaronvg
371-
- Dont drop extra fields in dynamic classes when passing them as inputs to a function (#802) - ([4264c9b](https://github.com/boundaryml/baml/commit/4264c9b143edda0239af197d110357b1969bf12c)) - aaronvg
371+
- Don't drop extra fields in dynamic classes when passing them as inputs to a function (#802) - ([4264c9b](https://github.com/boundaryml/baml/commit/4264c9b143edda0239af197d110357b1969bf12c)) - aaronvg
372372
- Adding support for a sync client for Python + Typescript (#803) - ([62085e7](https://github.com/boundaryml/baml/commit/62085e79d4d86f580ce189bc60f36bd1414893c4)) - hellovai
373373
- Fix WASM-related issues introduced in #803 (#804) - ([0a950e0](https://github.com/boundaryml/baml/commit/0a950e084748837ee2e269504d22dba66f339ca4)) - hellovai
374374
- Adding various fixes (#806) - ([e8c1a61](https://github.com/boundaryml/baml/commit/e8c1a61a96051160566b6458dac5c89d5ddfb86e)) - hellovai
@@ -416,7 +416,7 @@ The default base URL for the Gemini provider has been updated to v1beta. This ch
416416

417417
### Bug Fixes
418418

419-
- Fix env variables dialoge on VSCode (#750)
419+
- Fix env variables dialog on VSCode (#750)
420420
- Playground selects correct function after loading (#757) - ([09963a0](https://github.com/boundaryml/baml/commit/09963a02e581da9eb8f7bafd3ba812058c97f672)) - aaronvg
421421

422422
### Miscellaneous Chores
@@ -528,7 +528,7 @@ The default base URL for the Gemini provider has been updated to v1beta. This ch
528528
- add internal build tooling for sam (#512) - ([9ebacca](https://github.com/boundaryml/baml/commit/9ebaccaa542760cb96382ae2a91d780f1ade613b)) - Samuel Lijin
529529
- delete clients dir, this is now dead code (#652) - ([ec2627f](https://github.com/boundaryml/baml/commit/ec2627f59c7fe9edfff46fcdb65f9b9f0e2e072c)) - Samuel Lijin
530530
- consolidate vscode workspace, bump a bunch of deps (#654) - ([82bf6ab](https://github.com/boundaryml/baml/commit/82bf6ab1ad839f84782a7ef0441f21124c368757)) - Samuel Lijin
531-
- Add RB2B tracking script to propmt fiddle (#681) - ([4cf806b](https://github.com/boundaryml/baml/commit/4cf806bba26563fd8b6ddbd68296ab8bdfac21c4)) - hellovai
531+
- Add RB2B tracking script to prompt fiddle (#681) - ([4cf806b](https://github.com/boundaryml/baml/commit/4cf806bba26563fd8b6ddbd68296ab8bdfac21c4)) - hellovai
532532
- Adding better release script (#688) - ([5bec282](https://github.com/boundaryml/baml/commit/5bec282d39d2250b39ef4aba5d6bba9830a35988)) - hellovai
533533

534534
### [AUTO

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ Showcase of applications using BAML
185185
- [Aer Compliance](https://www.aercompliance.com/) - AI-powered compliance tasks
186186
- [Haven](https://www.usehaven.ai/) - Automate Tenant communications with AI
187187
- [Muckrock](https://www.muckrock.com/) - FOIA request tracking and filing
188-
- and more! [Let us know](https://calendly.com/boundaryml/meeting-with-founders) if you want to be showcased or want to work with us 1-1 to solve your usecase.
188+
- and more! [Let us know](https://calendly.com/boundaryml/meeting-with-founders) if you want to be showcased or want to work with us 1-1 to solve your use cases.
189189

190190
## Observability
191191

@@ -227,7 +227,7 @@ BAML handles this and many more cases, such as identifying `Enums` in LLM string
227227

228228
**Aliasing issues**
229229

230-
Prompt engineering requires you to think carefully about what the name of each key in the schema is. Rather than changing your code everytime you want to try a new name out, you can alias fields to a different name and convert them back into the original field name during parsing.
230+
Prompt engineering requires you to think carefully about what the name of each key in the schema is. Rather than changing your code every time you want to try a new name out, you can alias fields to a different name and convert them back into the original field name during parsing.
231231

232232
Here's how BAML differs from these frameworks:
233233

@@ -302,7 +302,7 @@ We basically wanted [Jinja](https://jinja.palletsprojects.com/en/3.1.x/), but wi
302302

303303
### Does BAML use LLMs to generate code?
304304

305-
No, the BAML dependency transpiles the code using Rust 🦀. It takes just a few milliseconds!
305+
No, the BAML dependency transpile the code using Rust 🦀. It takes just a few milliseconds!
306306

307307
### What does BAML stand for?
308308

engine/baml-lib/baml-core/src/ir/ir_helpers/to_baml_arg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use baml_types::{BamlMap, BamlMediaType, BamlValue, FieldType, LiteralValue, TypeValue};
1+
use baml_types::{BamlMap, BamlValue, FieldType, LiteralValue, TypeValue};
22
use core::result::Result;
33
use std::path::PathBuf;
44

engine/baml-lib/baml-core/src/ir/json_schema.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use baml_types::TypeValue;
44
use serde_json::json;
55

66
use super::{
7-
repr::{self},
87
Class, Enum, FieldType, FunctionArgs, FunctionNode, IntermediateRepr, Walker,
98
};
109

engine/baml-lib/baml-core/src/ir/repr.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::collections::HashSet;
22

3-
use anyhow::{anyhow, Context, Result};
3+
use anyhow::{anyhow, Result};
44
use baml_types::FieldType;
55
use either::Either;
66
use indexmap::IndexMap;
@@ -355,7 +355,7 @@ impl WithRepr<FieldType> for ast::FieldType {
355355
pub enum Identifier {
356356
/// Starts with env.*
357357
ENV(String),
358-
/// The path to a Local Identifer + the local identifer. Separated by '.'
358+
/// The path to a Local Identifier + the local identifier. Separated by '.'
359359
#[allow(dead_code)]
360360
Ref(Vec<String>),
361361
/// A string without spaces or '.' Always starts with a letter. May contain numbers
@@ -622,7 +622,7 @@ pub enum OracleType {
622622
#[derive(serde::Serialize, Debug)]
623623
pub struct AliasOverride {
624624
pub name: String,
625-
// This is used to generate deserializers with aliased keys (see .overload in python deserializer)
625+
// This is used to generate deserializer with aliased keys (see .overload in python deserializer)
626626
pub aliased_keys: Vec<AliasedKey>,
627627
}
628628

@@ -974,7 +974,7 @@ impl WithRepr<TestCase> for ConfigurationWalker<'_> {
974974
}
975975
#[derive(Debug, Clone, Serialize)]
976976
pub enum Prompt {
977-
// The prompt stirng, and a list of input replacer keys (raw key w/ magic string, and key to replace with)
977+
// The prompt string, and a list of input replacer keys (raw key w/ magic string, and key to replace with)
978978
String(String, Vec<(String, String)>),
979979

980980
// same thing, the chat message, and the replacer input keys (raw key w/ magic string, and key to replace with)

engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/types.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn errors_with_names<'a>(ctx: &'a mut Context<'_>, idn: &Identifier) {
1717
///
1818
/// Operates in two passes:
1919
///
20-
/// 1. Verify that the type is resolveable (for REF types)
20+
/// 1. Verify that the type is resolvable (for REF types)
2121
/// 2. Verify that the type is well-formed/allowed in the language
2222
pub(crate) fn validate_type(ctx: &mut Context<'_>, field_type: &FieldType) {
2323
validate_type_exists(ctx, field_type);
@@ -46,7 +46,7 @@ fn validate_type_exists(ctx: &mut Context<'_>, field_type: &FieldType) -> bool {
4646
fn validate_type_allowed(ctx: &mut Context<'_>, field_type: &FieldType) {
4747
match field_type {
4848
FieldType::Map(arity, kv_types, ..) => {
49-
if (arity.is_optional()) {
49+
if arity.is_optional() {
5050
ctx.push_error(DatamodelError::new_validation_error(
5151
format!("Maps are not allowed to be optional").as_str(),
5252
field_type.span().clone(),
@@ -70,7 +70,7 @@ fn validate_type_allowed(ctx: &mut Context<'_>, field_type: &FieldType) {
7070
FieldType::Symbol(..) => {}
7171

7272
FieldType::List(arity, field_type, ..) => {
73-
if (arity.is_optional()) {
73+
if arity.is_optional() {
7474
ctx.push_error(DatamodelError::new_validation_error(
7575
format!("Lists are not allowed to be optional").as_str(),
7676
field_type.span().clone(),

engine/baml-lib/baml-types/src/field_type/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ impl std::fmt::Display for FieldType {
113113
.join(", ")
114114
)
115115
}
116-
FieldType::Map(k, v) => write!(f, "map<{}, {}>", k.to_string(), v.to_string()),
117-
FieldType::List(t) => write!(f, "{}[]", t.to_string()),
118-
FieldType::Optional(t) => write!(f, "{}?", t.to_string()),
116+
FieldType::Map(k, v) => write!(f, "map<{}, {}>", k, v),
117+
FieldType::List(t) => write!(f, "{}[]", t),
118+
FieldType::Optional(t) => write!(f, "{}?", t),
119119
}
120120
}
121121
}

engine/baml-lib/baml/tests/parsing/comments.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::common::*;
33
#[test]
44
fn trailing_comments_allowed_in_configuration_blocks() {
55
let schema = r#"
6-
// This is a random commet
6+
// This is a random comment
77
88
// Anther random comment
99
// But in a block

engine/baml-lib/baml/tests/validation_files/class/misspeled_boolean_literals.baml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ class TestLiterals {
44
}
55

66
// error: Type `True` does not exist. Did you mean one of these: `true`, `string`, `int`, `bool`, `false`, `float`, `TestLiterals`?
7-
// --> class/misspeled_boolean_literals.baml:3
7+
// --> class/misspelled_boolean_literals.baml:3
88
// |
99
// 2 | a "SingleLiteral"
1010
// 3 | b "boolean" | True | False
1111
// |
1212
// error: Type `False` does not exist. Did you mean one of these: `false`, `float`, `true`, `int`, `bool`, `string`, `TestLiterals`?
13-
// --> class/misspeled_boolean_literals.baml:3
13+
// --> class/misspelled_boolean_literals.baml:3
1414
// |
1515
// 2 | a "SingleLiteral"
1616
// 3 | b "boolean" | True | False

engine/baml-lib/baml/tests/validation_files/dictionary/valid_dictionary.baml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ client<llm> MyClient {
77
array_key_with_quoted_unquoted [ "abc", "abc", "ccc" ]
88
// separate by commas
99
key2 "some random value", hello "world", thing "hello"
10-
block_string #"hello there my frien
10+
block_string #"hello there my friend
1111
d"#
1212
inline_raw_string #"inline "raw" string,,"#
1313
keyStringNoSpacesWorksWithoutQuotes NoQuotes!!123

engine/baml-lib/baml/tests/validation_files/functions_v2/shorthand_clients.baml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function InputEnum(color: Color) -> string {
2929
prompt #" color {{ color }} "#
3030
}
3131

32-
// Try it with wierd spacing and comments
32+
// Try it with weird spacing and comments
3333

3434
function InputEnum2(
3535
color: Color,

engine/baml-lib/baml/tests/validation_files/functions_v2/tests/failing_tests.baml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function InputEnum(color: Color) -> string {
3333
prompt #" color {{ color }} "#
3434
}
3535

36-
// Try it with wierd spacing and comments
36+
// Try it with weird spacing and comments
3737

3838
function InputEnum2(
3939
color: Color,

engine/baml-lib/baml/tests/validation_files/functions_v2/tests/valid_tests.baml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function InputEnum(color: Color) -> string {
3333
prompt #" color {{ color }} "#
3434
}
3535

36-
// Try it with wierd spacing and comments
36+
// Try it with weird spacing and comments
3737

3838
function InputEnum2(
3939
color: Color,

engine/baml-lib/baml/tests/validation_files/functions_v2/valid.baml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function InputEnum(color: Color) -> string {
3333
prompt #" color {{ color }} "#
3434
}
3535

36-
// Try it with wierd spacing and comments
36+
// Try it with weird spacing and comments
3737

3838
function InputEnum2(
3939
color: Color,

engine/baml-lib/jinja-runtime/src/baml_value_to_jinja_value.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl IntoMiniJinjaValue for BamlValue {
4242
// For enums and classes we compute the aliases from the IR, and generate custom jinja structs that print out the alias if stringified.
4343
BamlValue::Enum(name, value) => {
4444
minijinja::Value::from(value.clone())
45-
// Until we can fix the broken test, just return the normal value. For now we wont suppport enum alias rendering.
45+
// Until we can fix the broken test, just return the normal value. For now we wont support enum alias rendering.
4646
// let mut alias: Option<String> = None;
4747
// if let Ok(e) = ir.find_enum(name) {
4848
// if let Some(enum_value) = e

engine/baml-lib/jinja-runtime/src/chat_message_part.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::collections::{HashMap, HashSet};
1+
use std::collections::HashMap;
22

33
use baml_types::{BamlMedia, BamlMediaContent};
44
use serde::Serialize;

engine/baml-lib/jinja-runtime/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub use output_format::types;
88
mod baml_value_to_jinja_value;
99

1010
use minijinja::{self, value::Kwargs};
11-
use minijinja::{context, ErrorKind, Value};
11+
use minijinja::{context, ErrorKind};
1212
use output_format::types::OutputFormatContent;
1313
use serde::{Deserialize, Serialize};
1414
use serde_json::json;
@@ -463,7 +463,7 @@ mod render_tests {
463463

464464
pub fn make_test_ir(source_code: &str) -> anyhow::Result<IntermediateRepr> {
465465
use internal_baml_core::validate;
466-
use internal_baml_core::{Configuration, ValidatedSchema};
466+
use internal_baml_core::ValidatedSchema;
467467
use internal_baml_diagnostics::SourceFile;
468468
use std::path::PathBuf;
469469
let path: PathBuf = "fake_file.baml".into();
@@ -1849,7 +1849,7 @@ mod render_tests {
18491849
}
18501850

18511851
// See the note in baml_value_to_jinja_value.rs for Enum for why we don't support aliases.
1852-
// tl;dr we don't havea way to override the equality operator for enum comparisons to NOT use the alias.
1852+
// tl;dr we don't have a way to override the equality operator for enum comparisons to NOT use the alias.
18531853
// #[test]
18541854
// fn test_render_prompt_with_enum() -> anyhow::Result<()> {
18551855
// setup_logging();

engine/baml-lib/jinja/src/evaluate_type/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl TypeError {
194194
)
195195
};
196196

197-
Self { message: format!("{message}\n\nSee: https://docs.rs/minijinja/latest/minijinja/filters/index.html#functions for the compelete list"), span }
197+
Self { message: format!("{message}\n\nSee: https://docs.rs/minijinja/latest/minijinja/filters/index.html#functions for the complete list"), span }
198198
}
199199

200200
fn new_invalid_type(expr: &Expr, got: &Type, expected: &str, span: Span) -> Self {

engine/baml-lib/jinja/src/evaluate_type/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ impl PredefinedTypes {
304304
};
305305

306306
// Any vars that are in both branches are merged
307-
// Any vars that are only in one branch, unioned with undefined
307+
// Any vars that are only in one branch, united with undefined
308308

309309
let mut new_vars = HashMap::new();
310310
for (name, t) in true_vars.iter() {

engine/baml-lib/jsonish/src/deserializer/coercer/array_helper.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
use std::any::Any;
2-
31
use crate::deserializer::{deserialize_flags::Flag, types::BamlValueWithFlags};
42
use anyhow::Result;
5-
use internal_baml_core::{ast::Field, ir::FieldType};
3+
use internal_baml_core::ir::FieldType;
64

75
use super::{ParsingContext, ParsingError};
86

engine/baml-lib/jsonish/src/deserializer/coercer/coerce_optional.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub(super) fn coerce_optional(
3232
Some(v) => match inner.coerce(ctx, optional_target, Some(v)) {
3333
Ok(v) => Ok(v),
3434
Err(e) => {
35-
flags.add_flag(Flag::DefaultButHadUnparseableValue(e));
35+
flags.add_flag(Flag::DefaultButHadUnparsableValue(e));
3636
Ok(BamlValueWithFlags::Null(flags))
3737
}
3838
},

engine/baml-lib/jsonish/src/deserializer/coercer/field_type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl DefaultValue for FieldType {
9393
fn default_value(&self, error: Option<&ParsingError>) -> Option<BamlValueWithFlags> {
9494
let get_flags = || {
9595
DeserializerConditions::new().with_flag(error.map_or(Flag::DefaultFromNoValue, |e| {
96-
Flag::DefaultButHadUnparseableValue(e.clone())
96+
Flag::DefaultButHadUnparsableValue(e.clone())
9797
}))
9898
};
9999

engine/baml-lib/jsonish/src/deserializer/coercer/ir_ref/coerce_class.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl TypeCoercer for Class {
132132
let parsed = match field.1.coerce(&scope, &field.1, Some(x)) {
133133
Ok(mut v) => {
134134
v.add_flag(Flag::ImpliedKey(field.0.real_name().into()));
135-
flags.add_flag(Flag::InferedObject(x.clone()));
135+
flags.add_flag(Flag::InferredObject(x.clone()));
136136
Ok(v)
137137
}
138138
Err(e) => Err(e),
@@ -275,7 +275,7 @@ impl TypeCoercer for Class {
275275
k.to_string(),
276276
BamlValueWithFlags::Null(
277277
DeserializerConditions::new()
278-
.with_flag(Flag::DefaultButHadUnparseableValue(e)),
278+
.with_flag(Flag::DefaultButHadUnparsableValue(e)),
279279
),
280280
),
281281
}

engine/baml-lib/jsonish/src/deserializer/coercer/match_string.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ pub(super) fn match_string(
4949
}
5050
};
5151

52-
// Trim whitespaces.
52+
// Trim whitespace.
5353
let match_context = jsonish_string.trim();
5454

55-
// First attempt, case sensitive match ignoring possible pucntuation.
55+
// First attempt, case sensitive match ignoring possible punctuation.
5656
if let Some(string_match) = string_match_strategy(&match_context, &candidates, &mut flags) {
5757
return try_match_only_once(parsing_context, target, string_match, flags);
5858
}
@@ -125,10 +125,10 @@ fn try_match_only_once(
125125
/// Heuristic string match algorithm.
126126
///
127127
/// The algorithm is case sensitive so for case insensitive matches it must
128-
/// recieve lowercase strings. This algorithm will first try to look for exact
128+
/// receive lowercase strings. This algorithm will first try to look for exact
129129
/// matches in the input string, if it doesn't find any it will look for
130130
/// substring matches and return the one with the most matches. Whether that is
131-
/// an ambigous match or not is up to the caller to decide.
131+
/// an ambiguous match or not is up to the caller to decide.
132132
fn string_match_strategy<'c>(
133133
value_str: &str,
134134
candidates: &'c [(&'c str, Vec<String>)],
@@ -148,7 +148,7 @@ fn string_match_strategy<'c>(
148148
let match_count_pos = valid_names
149149
.iter()
150150
.filter_map(|valid_name| {
151-
// Match ocurrences of valid name.
151+
// Match occurrences of valid name.
152152
let matches = value_str.match_indices(valid_name);
153153
// Return (count, first_idx)
154154
matches.fold(None, |acc, (idx, _)| match acc {

0 commit comments

Comments
 (0)