Managing and rendering prompts in Instructor
Prompt
addon provides a powerful and flexible way to manage your prompts. It supports
multiple template engines (Twig, Blade), prompt metadata, variable injection, and validation.
template libraries
in your app. Library is just a collection of
prompt templates which is stored under a specific directory. Library can have a nested structure, which allows
you to organize your prompts in a way that makes sense for your application.
Library properties are specified in config/prompt.php
configuration file.
where you can define:
templateEngine
- template engine used for prompts in this library,resourcePath
- path to prompt templates,cachePath
- path to compiled templates,extension
- file extension for prompt templates,frontMatterTags
- start and end tags for front matter,frontMatterFormat
- format of front matter (yaml, json, toml),metadata
- engine-specific configuration.system
- prompt templates used by Instructor itself,demo-twig
- demo prompt templates using Twig template engine,demo-blade
- demo prompt templates using Blade template engine.Prompt::using
or Prompt::make
methods. Here’s how you can use them:
make()
syntax:
Prompt
class to convert XML template into a sequence of messages: