public static String generateMoreDigits(int minDigits, int maxDigits) {
        var content = new StringBuilder();
        content.append("[0-9]");

        if (minDigits == maxDigits && minDigits == 1) {
            return content.toString();
        }

        content.append("{")
                .append(minDigits);

        if (maxDigits != minDigits) {
            content.append(",");

            if (maxDigits != Integer.MAX_VALUE) {
                content.append(maxDigits);
            }
        }

        content.append("}");
        return content.toString();
    }
Converts a JSON Schema to a GBNF grammar to be used for structured output with llama.cpp.
It is a port of Python implementation from llama.cpp repository.
Current implementation doesn't support regex patterns, resolving $ref or fetching schemas from URLs.
The plan is to replace this with C++ implementation from llama.cpp though JNI.
model-integration/src/main/java/ai/vespa/llm/clients/JsonSchemaToGrammar.java