Skip to content

Commit 8755129

Browse files
[Doc] Add comments for JSONSchemaToEBNF. (#430)
This PR adds more precise comments for `JSONSchemaToEBNF`. Signed-off-by: Yuchuan <[email protected]>
1 parent 2fefe24 commit 8755129

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

cpp/json_schema_converter.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ enum class JSONFormat : int {
2323
/*!
2424
* \brief Convert JSON schema string to EBNF grammar string.
2525
* \param schema The JSON schema string.
26+
* \param any_whitespace Whether to ignore the indentation restrictions, and allow any whitespace.
27+
* Default: true.
2628
* \param indent The number of spaces for indentation. If set to std::nullopt, the output will be
2729
* in one line. Default: 2.
2830
* \param separators Two separators used in the schema: comma and colon. Examples: {",", ":"},
@@ -34,10 +36,13 @@ enum class JSONFormat : int {
3436
* schema. This is equivalent to setting unevaluatedProperties and unevaluatedItems to false.
3537
* This helps LLM to generate accurate output in the grammar-guided generation with JSON
3638
* schema. Default: true.
37-
* \param json_format Define the root format of the object. If it's JSONFormat::kJSON,
38-
* then it will generate a fully JSON-style grammar. If it's JSONFormat::kXML, then it will
39-
* generate a grammar with the root format is XML-style, while the inner format is JSON-style.
40-
* Default: JSONFormat::kJSON.
39+
* \param max_whitespace_cnt The maximum number of whitespace characters for the whitespace
40+
* which is used for indentation or JSON elements separation when any_whitespace is True. If
41+
* std::nullopt, it means unlimited. Default: std::nullopt.
42+
* \param json_format Define the root
43+
* format of the object. If it's JSONFormat::kJSON, then it will generate a fully JSON-style
44+
* grammar. If it's JSONFormat::kXML, then it will generate a grammar with the root format is
45+
* XML-style, while the inner format is JSON-style. Default: JSONFormat::kJSON.
4146
* \returns The EBNF grammar string.
4247
*/
4348

@@ -54,6 +59,8 @@ std::string JSONSchemaToEBNF(
5459
/*!
5560
* \brief Convert JSON schema string to EBNF grammar string.
5661
* \param schema The JSON schema object.
62+
* \param any_whitespace Whether to ignore the indentation restrictions, and allow any whitespace.
63+
* Default: true.
5764
* \param indent The number of spaces for indentation. If set to std::nullopt, the output will be
5865
* in one line. Default: 2.
5966
* \param separators Two separators used in the schema: comma and colon. Examples: {",", ":"},
@@ -65,6 +72,9 @@ std::string JSONSchemaToEBNF(
6572
* schema. This is equivalent to setting unevaluatedProperties and unevaluatedItems to false.
6673
* This helps LLM to generate accurate output in the grammar-guided generation with JSON
6774
* schema. Default: true.
75+
* \param max_whitespace_cnt The maximum number of whitespace characters for the whitespace
76+
* which is used for indentation or JSON elements separation when any_whitespace is True. If
77+
* std::nullopt, it means unlimited. Default: std::nullopt.
6878
* \param json_format Define the root format of the object. If it's JSONFormat::kJSON,
6979
* then it will generate a fully JSON-style grammar. If it's JSONFormat::kXML, then it will
7080
* generate a grammar with the root format is XML-style, while the inner format is JSON-style.

0 commit comments

Comments
 (0)