Skip to content

Commit

Permalink
debug failing ts tests
Browse files Browse the repository at this point in the history
  • Loading branch information
imalsogreg committed Jan 9, 2025
1 parent 2728345 commit e5a36e3
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 27 deletions.
15 changes: 2 additions & 13 deletions engine/baml-lib/baml-core/src/ir/ir_helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -857,25 +857,14 @@ fn item_type<T: Clone + std::fmt::Debug>(
FieldType::Union(variants) => variants
.into_iter()
.find(|variant| {
let typechecks = ir
ir
.distribute_type_with_meta(baml_child_value.clone(), variant.clone().to_owned())
.is_ok();
eprintln!(
"typecheck {:?} against {:?}: {:?}",
baml_child_value.clone().value(),
variant,
typechecks
);
typechecks
.is_ok()
})
.map(|v| v.clone()),
FieldType::Tuple(_) => None,
FieldType::WithMetadata { base, .. } => item_type(ir, base, baml_child_value),
};
eprintln!(
"item_type for {:?}\nitem value {:?}\nresult: {:?}",
field_type, baml_child_value, res
);
res
}

Expand Down
1 change: 1 addition & 0 deletions engine/baml-lib/baml-types/src/baml_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@ impl Serialize for BamlValueWithMeta<Vec<ResponseCheck>> {
where
S: Serializer,
{
eprintln!("ABOUT TO SERIALIZE");
match self {
BamlValueWithMeta::String(v, cr) => serialize_with_checks(v, cr, serializer),
BamlValueWithMeta::Int(v, cr) => serialize_with_checks(v, cr, serializer),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl std::fmt::Debug for DeserializerConditions {

impl std::fmt::Display for DeserializerConditions {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
if self.flags.is_empty() {
if true {
return Ok(());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ pub fn validate_streaming_state(
typed_baml_value.map_meta(|(flags, r#type)| (completion_state(&flags), r#type));
// dbg!(&baml_value_with_streaming_state_and_behavior);

process_node(
let res = process_node(
ir,
baml_value_with_streaming_state_and_behavior,
allow_partials,
)
);
res
}

/// Consider a node's type, streaming state, and streaming behavior annotations. Return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ print("Hello, world!")
let Value::AnyOf(value, _) = value else {
panic!("Expected AnyOf, got {:#?}", value);
};
dbg!(&value);
// dbg!(&value);
assert!(value.contains(&Value::String(
"This is a test".to_string(),
CompletionState::Complete
Expand Down
3 changes: 0 additions & 3 deletions engine/baml-runtime/src/internal/llm_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ pub fn parsed_value_to_response(
field_type: &FieldType,
allow_partials: bool,
) -> Result<ResponseBamlValue> {
// dbg!(&baml_value);
let meta_flags: BamlValueWithMeta<Vec<Flag>> = baml_value.clone().into();
let baml_value_with_meta: BamlValueWithMeta<Vec<(String, JinjaExpression, bool)>> =
baml_value.clone().into();
// dbg!(&baml_value_with_meta);

let value_with_response_checks: BamlValueWithMeta<Vec<ResponseCheck>> = baml_value_with_meta
.map_meta(|cs| {
Expand Down Expand Up @@ -66,7 +64,6 @@ pub fn parsed_value_to_response(
.zip_meta(value_with_response_checks)?
.zip_meta(meta_flags)?
.map_meta(|((x, y), z)| (z.clone(), y.clone(), if allow_partials { x.clone() } else { None } ));
// dbg!(&response_value);
Ok(ResponseBamlValue(response_value))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ pub async fn orchestrate(
};

let sleep_duration = node.error_sleep_duration().cloned();
// let (parsed_response, response_with_constraints) = match parsed_response {
// Some(Ok(v)) => (Some(Ok(v.clone())), Some(Ok(parsed_value_to_response(&v)))),
// Some(Err(e)) => (None, Some(Err(e))),
// None => (None, None),
// };
results.push((
node.scope,
response,
Expand Down
3 changes: 2 additions & 1 deletion engine/baml-runtime/src/internal/prompt_renderer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ impl PromptRenderer {
raw_string,
allow_partials,
)?;
parsed_value_to_response(ir, &parsed, &self.output_type, allow_partials)
let res = parsed_value_to_response(ir, &parsed, &self.output_type, allow_partials);
res
}

pub fn render_prompt(
Expand Down
2 changes: 1 addition & 1 deletion integ-tests/typescript/test-report.html

Large diffs are not rendered by default.

0 comments on commit e5a36e3

Please sign in to comment.