DotPrompt
A high-performance, native Elixir compiler for the DotPrompt language.
Installation
The package can be installed by adding dot_prompt to your list of dependencies in mix.exs:
def deps do
[
{:dot_prompt, "~> 1.0.0"}
]
endUsage
Compilation
{:ok, result} = DotPrompt.compile("my_prompt", %{name: "John"})
IO.puts(result.prompt)Rendering
{:ok, result} = DotPrompt.render("my_prompt", %{name: "John"}, %{weather: "sunny"})
IO.puts(result.prompt)Schema Extraction
{:ok, schema} = DotPrompt.schema("my_prompt")Configuration
You can configure the prompts directory in your config/config.exs:
config :dot_prompt,
prompts_dir: "priv/prompts"Features
- Fragments: Reusable prompt snippets.
- Vary Blocks: A/B testing and variety in prompts.
- Conditional Logic:
ifandcaseblocks. - Dynamic Fragments: Resolving fragments at runtime.
- Response Contracts: Declare expected response formats.