@@ -641,7 +641,7 @@ def generate_gbnf_grammar(
641
641
642
642
fields_joined = r' "," ' .join (model_rule_parts )
643
643
if fields_joined != "" :
644
- model_rule = rf'{ model_name } ::= "{{" { fields_joined } ws "}}" '
644
+ model_rule = rf'{ model_name } ::= "{{" { fields_joined } '
645
645
else :
646
646
model_rule = rf'{ model_name } ::= "{{" "}}"'
647
647
@@ -650,10 +650,12 @@ def generate_gbnf_grammar(
650
650
model_rule += '"\\ n" ws "}"'
651
651
model_rule += '"\\ n" triple-quoted-string'
652
652
has_special_string = True
653
- if has_markdown_code_block :
653
+ elif has_markdown_code_block :
654
654
model_rule += '"\\ n" ws "}"'
655
655
model_rule += '"\\ n" markdown-code-block'
656
656
has_special_string = True
657
+ else :
658
+ model_rule += ' ws "}"'
657
659
all_rules = [model_rule ] + nested_rules
658
660
659
661
return all_rules , has_special_string
@@ -764,8 +766,8 @@ def generate_gbnf_grammar_from_pydantic_models(
764
766
model_rules [
765
767
0
766
768
] += rf' "," ws "\"{ request_heartbeat_field_name } \"" ":" ws boolean '
767
- if not has_special_string :
768
- model_rules [0 ] += r' ws "}"'
769
+ # if not has_special_string:
770
+ # model_rules[0] += r' ws "}"'
769
771
770
772
all_rules .extend (model_rules )
771
773
0 commit comments