Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions engine/baml-lib/ast/src/ast/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ pub struct RawString {
pub raw_value: String,
pub inner_value: String,

/// If set indicates the language of the raw string.
/// By default it is a text string.
pub language: Option<(String, Span)>,

// This is useful for getting the final offset.
pub indent: usize,
inner_span_start: usize,
Expand All @@ -34,7 +30,7 @@ impl WithSpan for RawString {
}

impl RawString {
pub(crate) fn new(value: String, span: Span, language: Option<(String, Span)>) -> Self {
pub(crate) fn new(value: String, span: Span) -> Self {
let dedented_value = value.trim_start_matches(['\n', '\r']);
let start_trim_count = value.len() - dedented_value.len();
let dedented_value = dedented_value.trim_end();
Expand All @@ -45,7 +41,6 @@ impl RawString {
inner_value: dedented.content,
indent: dedented.indent_size,
inner_span_start: start_trim_count,
language,
}
}

Expand Down Expand Up @@ -86,7 +81,6 @@ impl RawString {
pub fn assert_eq_up_to_span(&self, other: &RawString) {
assert_eq!(self.inner_value, other.inner_value);
assert_eq!(self.raw_value, other.raw_value);
assert_eq!(self.language, other.language);
assert_eq!(self.indent, other.indent);
}
}
Expand Down
10 changes: 5 additions & 5 deletions engine/baml-lib/ast/src/parser/datamodel.pest
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,11 @@ raw_string_literal_content_3 = @{ (!"\"###" ~ ANY)* }
raw_string_literal_content_4 = @{ (!"\"####" ~ ANY)* }
raw_string_literal_content_5 = @{ (!"\"#####" ~ ANY)* }

raw_string_start_5 = _{ (single_word)? ~ "#####\"" }
raw_string_start_4 = _{ (single_word)? ~ "####\"" }
raw_string_start_3 = _{ (single_word)? ~ "###\"" }
raw_string_start_2 = _{ (single_word)? ~ "##\"" }
raw_string_start_1 = _{ (single_word)? ~ "#\"" }
raw_string_start_5 = _{ "#####\"" }
raw_string_start_4 = _{ "####\"" }
raw_string_start_3 = _{ "###\"" }
raw_string_start_2 = _{ "##\"" }
raw_string_start_1 = _{ "#\"" }

raw_string_literal = {
(raw_string_start_5 ~ raw_string_literal_content_5 ~ "\"#####")
Expand Down
7 changes: 1 addition & 6 deletions engine/baml-lib/ast/src/parser/parse_expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,15 +534,10 @@ fn parse_config_map_key(token: Pair<'_>, diagnostics: &mut Diagnostics) -> Expre
pub(super) fn parse_raw_string(token: Pair<'_>, diagnostics: &mut Diagnostics) -> RawString {
assert_correct_parser(&token, &[Rule::raw_string_literal], diagnostics);

let mut language = None;
let mut content = None;

for current in token.into_inner() {
match current.as_rule() {
Rule::single_word => {
let contents = current.as_str().to_string();
language = Some((contents, diagnostics.span(current.as_span())));
}
Rule::raw_string_literal_content_1
| Rule::raw_string_literal_content_2
| Rule::raw_string_literal_content_3
Expand All @@ -557,7 +552,7 @@ pub(super) fn parse_raw_string(token: Pair<'_>, diagnostics: &mut Diagnostics) -
};
}
match content {
Some((content, span)) => RawString::new(content, span, language),
Some((content, span)) => RawString::new(content, span),
_ => unreachable!("Encountered impossible raw string during parsing"),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type LinkedListAlias = LinkedListAliasNode

function AliasThatPointsToRecursiveType(data: LinkedListAlias) -> LinkedListAlias {
client "openai/gpt-4o"
prompt r#"
prompt #"
Return the given linked list back:

{{ data }}
Expand All @@ -24,7 +24,7 @@ class ClassToRecAlias {

function ClassThatPointsToRecursiveClassThroughAlias(cls: ClassToRecAlias) -> ClassToRecAlias {
client "openai/gpt-4o"
prompt r#"
prompt #"
Return the given object back:

{{ cls }}
Expand All @@ -44,7 +44,7 @@ type NodeIndirection = NodeWithAliasIndirection

function RecursiveClassWithAliasIndirection(cls: NodeWithAliasIndirection) -> NodeWithAliasIndirection {
client "openai/gpt-4o"
prompt r#"
prompt #"
Return the given object back:

{{ cls }}
Expand Down
22 changes: 11 additions & 11 deletions integ-tests/baml_src/test-files/functions/output/type-aliases.baml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type Combination = Primitive | List | Graph

function PrimitiveAlias(p: Primitive) -> Primitive {
client "openai/gpt-4o"
prompt r#"
prompt #"
Return the given value back: {{ p }}

{{ ctx.output_format }}
Expand All @@ -17,7 +17,7 @@ function PrimitiveAlias(p: Primitive) -> Primitive {

function MapAlias(m: Graph) -> Graph {
client "openai/gpt-4o"
prompt r#"
prompt #"
Return the given Graph back:

{{ m }}
Expand All @@ -28,7 +28,7 @@ function MapAlias(m: Graph) -> Graph {

function NestedAlias(c: Combination) -> Combination {
client "openai/gpt-4o"
prompt r#"
prompt #"
Return the given value back:

{{ c }}
Expand All @@ -50,7 +50,7 @@ type MultipleAttrs = int @assert({{ this > 0 }}) @check(gt_ten, {{ this > 10 }})

function MergeAliasAttributes(money: int) -> MergeAttrs {
client "openai/gpt-4o"
prompt r#"
prompt #"
Return the given integer in the specified format:

{{ money }}
Expand All @@ -61,7 +61,7 @@ function MergeAliasAttributes(money: int) -> MergeAttrs {

function ReturnAliasWithMergedAttributes(money: int) -> Amount {
client "openai/gpt-4o"
prompt r#"
prompt #"
Return the given integer without additional context:

{{ money }}
Expand All @@ -72,7 +72,7 @@ function ReturnAliasWithMergedAttributes(money: int) -> Amount {

function AliasWithMultipleAttrs(money: int) -> MultipleAttrs {
client "openai/gpt-4o"
prompt r#"
prompt #"
Return the given integer without additional context:

{{ money }}
Expand All @@ -85,7 +85,7 @@ type RecursiveMapAlias = map<string, RecursiveMapAlias>

function SimpleRecursiveMapAlias(input: RecursiveMapAlias) -> RecursiveMapAlias {
client "openai/gpt-4o"
prompt r#"
prompt #"
Return the given value:

{{ input }}
Expand All @@ -98,7 +98,7 @@ type RecursiveListAlias = RecursiveListAlias[]

function SimpleRecursiveListAlias(input: RecursiveListAlias) -> RecursiveListAlias {
client "openai/gpt-4o"
prompt r#"
prompt #"
Return the given JSON array:

{{ input }}
Expand All @@ -113,7 +113,7 @@ type RecAliasThree = RecAliasOne[]

function RecursiveAliasCycle(input: RecAliasOne) -> RecAliasOne {
client "openai/gpt-4o"
prompt r#"
prompt #"
Return the given JSON array:

{{ input }}
Expand All @@ -128,7 +128,7 @@ type JsonArray = JsonValue[]

function JsonTypeAliasCycle(input: JsonValue) -> JsonValue {
client "openai/gpt-4o"
prompt r#"
prompt #"
Return the given input back:

{{ input }}
Expand All @@ -143,7 +143,7 @@ class RecursiveAliasDependency {

function TakeRecAliasDep(input: RecursiveAliasDependency) -> RecursiveAliasDependency {
client "openai/gpt-4o"
prompt r#"
prompt #"
Return the given input back:

{{ input }}
Expand Down
Loading
Loading