mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-07-16 17:47:22 +00:00
45 lines
1.5 KiB
C++
45 lines
1.5 KiB
C++
#ifndef BIERGARTEN_PIPELINE_INCLUDES_DATA_GENERATION_JSON_GRAMMARS_H_
|
|
#define BIERGARTEN_PIPELINE_INCLUDES_DATA_GENERATION_JSON_GRAMMARS_H_
|
|
|
|
/**
|
|
* @file data_generation/json_grammars.h
|
|
* @brief GBNF grammars constraining structured JSON output from
|
|
* LlamaGenerator inference calls.
|
|
*/
|
|
|
|
#include <string_view>
|
|
|
|
// GBNF grammar for structured user JSON output.
|
|
inline constexpr std::string_view kUserJsonGrammar = R"json_user(
|
|
root ::= thought-block "{" ws
|
|
"\"username\"" ws ":" ws string ws "," ws
|
|
"\"bio\"" ws ":" ws string ws "," ws
|
|
"\"activity_weight\"" ws ":" ws number ws
|
|
"}" ws
|
|
thought-block ::= [^{]*
|
|
ws ::= [ \t\n\r]*
|
|
string ::= "\"" char+ "\""
|
|
char ::= [^"\\\x7F\x00-\x1F] | [\\] escape
|
|
escape ::= ["\\/bfnrt] | "u" hex hex hex hex
|
|
hex ::= [0-9a-fA-F]
|
|
number ::= "-"? ("0" | [1-9] [0-9]*) ("." [0-9]+)?
|
|
)json_user";
|
|
|
|
// GBNF grammar for structured brewery JSON output.
|
|
inline constexpr std::string_view kBreweryJsonGrammar = R"json_brewery(
|
|
root ::= thought-block "{" ws
|
|
"\"name_en\"" ws ":" ws string ws "," ws
|
|
"\"description_en\"" ws ":" ws string ws "," ws
|
|
"\"name_local\"" ws ":" ws string ws "," ws
|
|
"\"description_local\"" ws ":" ws string ws
|
|
"}" ws
|
|
thought-block ::= [^{]*
|
|
ws ::= [ \t\n\r]*
|
|
string ::= "\"" char+ "\""
|
|
char ::= [^"\\\x7F\x00-\x1F] | [\\] escape
|
|
escape ::= ["\\/bfnrt] | "u" hex hex hex hex
|
|
hex ::= [0-9a-fA-F]
|
|
)json_brewery";
|
|
|
|
#endif // BIERGARTEN_PIPELINE_INCLUDES_DATA_GENERATION_JSON_GRAMMARS_H_
|