Skip to content

[Feature]: Support JSON Schema from llama.cpp #798

Open
@m0nsky

Description

@m0nsky

Background & Description

I was working on a C# class -> GBNF converter, and came across this:

https://github.com/ggerganov/llama.cpp/blob/master/grammars/README.md#json-schemas--gbnf

Here's an example, thanks to this reddit post.

Example JSON:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "reply": {"type": "string"},
    "mood": {"type": "string"},
    "intent": {"type": "string"}
  },
  "required": ["reply", "mood", "intent"]
}

Example output:

 User: I gave you a cookie.

Please respond in JSON format with your reply, mood, and intent:
{"reply": "Thank you for the cookie! It's delicious!", "mood": "Happy", "intent": "Express gratitude" }

API & Usage

No response

How to implement

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions