Upload dispatcher.gbnf with huggingface_hub
Browse files- dispatcher.gbnf +38 -0
dispatcher.gbnf
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# GBNF Grammar for FunctionGemma-Delia Dispatcher
|
| 2 |
+
# Forces the model to output EXACTLY: thought + tool_call + EOS
|
| 3 |
+
# Prevents infinite JSON loops and hallucinated parameters
|
| 4 |
+
#
|
| 5 |
+
# Usage with Ollama:
|
| 6 |
+
# ollama run functiongemma-delia --grammar "$(cat dispatcher.gbnf)"
|
| 7 |
+
#
|
| 8 |
+
# Usage with llama.cpp:
|
| 9 |
+
# ./main -m model.gguf --grammar-file dispatcher.gbnf -p "..."
|
| 10 |
+
|
| 11 |
+
# Root rule: thought block followed by exactly one tool call, then stop
|
| 12 |
+
root ::= thought-block tool-call eos
|
| 13 |
+
|
| 14 |
+
# Thought block: optional reasoning before the tool call
|
| 15 |
+
thought-block ::= "thought\n" thought-content "\n"
|
| 16 |
+
thought-content ::= [^\n<]+
|
| 17 |
+
|
| 18 |
+
# Tool call structure: XML wrapper around JSON
|
| 19 |
+
tool-call ::= "<tool_call>" tool-json "</tool_call>"
|
| 20 |
+
|
| 21 |
+
# Tool JSON: dispatcher tools only have name + reasoning
|
| 22 |
+
tool-json ::= "{" ws name-field "," ws arguments-field ws "}"
|
| 23 |
+
|
| 24 |
+
# Name field: one of the four dispatcher tools
|
| 25 |
+
name-field ::= "\"name\"" ws ":" ws tool-name
|
| 26 |
+
tool-name ::= "\"call_coder\"" | "\"call_reviewer\"" | "\"call_planner\"" | "\"call_executor\""
|
| 27 |
+
|
| 28 |
+
# Arguments field: ONLY reasoning parameter allowed
|
| 29 |
+
arguments-field ::= "\"arguments\"" ws ":" ws "{" ws reasoning-field ws "}"
|
| 30 |
+
reasoning-field ::= "\"reasoning\"" ws ":" ws reasoning-value
|
| 31 |
+
reasoning-value ::= "\"" reasoning-chars "\""
|
| 32 |
+
reasoning-chars ::= [^"\\]* ( "\\" ["\\/bfnrt] [^"\\]* )*
|
| 33 |
+
|
| 34 |
+
# End of sequence token
|
| 35 |
+
eos ::= "<eos>" | "<end_of_turn>"
|
| 36 |
+
|
| 37 |
+
# Whitespace (optional)
|
| 38 |
+
ws ::= [ \t\n]*
|