Gabriella439/grace

A prompt engineering functional programming language

What it solves

Grace is a domain-specific language (DSL) designed specifically for prompting models. It simplifies the creation of complex prompt chains and the auto-generation of structured data from LLMs by integrating model interaction directly into the language syntax.

How it works

Grace treats prompting as a first-class citizen. It uses a built-in prompt function that can return structured data based on type annotations. The language's type checker can reason backwards from how the output is used in the subsequent code to automatically infer the necessary JSON schema to constrain the model's output, often allowing the user to omit the prompt text itself if the type is descriptive enough.

Additionally, Grace supports "code generation" via the import prompt keyword, which asks a model to generate a Grace expression or function of a specific type that can then be executed within the same program.

Who it’s for

Developers who want a more programmatic, type-safe way to build prompt chains and LLM-driven applications without manually managing JSON schemas or boilerplate code.

Highlights

  • Integrated Model Support: Model prompting is built directly into the language, requiring no external imports or dependencies.
  • Type-Driven Prompting: Uses type annotations to automatically generate JSON schemas for model constraints.
  • Type Inference: Infers the required output format based on how the result is used in the loop or variable assignment.
  • Turing-Complete Code Generation: Ability to generate and execute Grace code on the fly using LLMs.
  • Interactive Environment: Provides both a browser-based playground and a command-line REPL.

Related

  • Project
  • Project
  • Project
  • Project