@@ -641,7 +641,7 @@ def generate_gbnf_grammar(
641641
642642 fields_joined = r' "," ' .join (model_rule_parts )
643643 if fields_joined != "" :
644- model_rule = rf'{ model_name } ::= "{{" { fields_joined } ws "}}" '
644+ model_rule = rf'{ model_name } ::= "{{" { fields_joined } '
645645 else :
646646 model_rule = rf'{ model_name } ::= "{{" "}}"'
647647
@@ -650,10 +650,12 @@ def generate_gbnf_grammar(
650650 model_rule += '"\\ n" ws "}"'
651651 model_rule += '"\\ n" triple-quoted-string'
652652 has_special_string = True
653- if has_markdown_code_block :
653+ elif has_markdown_code_block :
654654 model_rule += '"\\ n" ws "}"'
655655 model_rule += '"\\ n" markdown-code-block'
656656 has_special_string = True
657+ else :
658+ model_rule += ' ws "}"'
657659 all_rules = [model_rule ] + nested_rules
658660
659661 return all_rules , has_special_string
@@ -764,8 +766,8 @@ def generate_gbnf_grammar_from_pydantic_models(
764766 model_rules [
765767 0
766768 ] += 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 "}"'
769771
770772 all_rules .extend (model_rules )
771773
0 commit comments