|
| 1 | +# Environment configuration reference |
| 2 | + |
| 3 | +Environments are configured by creating a `config.js` that exposes an object that satisfies the |
| 4 | +`EnvironmentConfig` interface. This document covers all the possible options in `EnvironmentConfig` |
| 5 | +and what they do. |
| 6 | + |
| 7 | +## Required properties |
| 8 | + |
| 9 | +These properties all have to be specified in order for the environment to function |
| 10 | + |
| 11 | +### `displayName` |
| 12 | + |
| 13 | +Human-readable name that will be shown in eval reports about this environment. |
| 14 | + |
| 15 | +### `id` |
| 16 | + |
| 17 | +Unique ID for the environment. If ommitted, one will be generated from the `displayName`. |
| 18 | + |
| 19 | +### `clientSideFramework` |
| 20 | + |
| 21 | +ID of the client-side framework that the environment will be running, for example `angular`. |
| 22 | + |
| 23 | +### `ratings` |
| 24 | + |
| 25 | +An array defining the ratings that will be executed as a part of the evaluation. |
| 26 | +The ratings determine what score that will be assigned to the test run. |
| 27 | +Currently we support the following types of ratings: |
| 28 | + |
| 29 | +- `PerBuildRating` - assigns a score based on the build result of the generated code, e.g. |
| 30 | + "Does it build on the first run?" or "Does it build after X repair attempts?" |
| 31 | +- `PerFileRating` - assigns a score based on the content of individual files generated by the LLM. |
| 32 | + Can be run either against all file types by setting the `filter` to |
| 33 | + `PerFileRatingContentType.UNKNOWN` or against specific files. |
| 34 | +- `LLMBasedRating` - rates the generated code by asking an LLM to assign a score to it, |
| 35 | + e.g. "Does this app match the specified prompts?" |
| 36 | + |
| 37 | +### `packageManager` |
| 38 | + |
| 39 | +Name of the package manager to use to install dependencies for the evaluated code. |
| 40 | +Supports `npm`, `pnpm` and `yarn`. Defaults to `npm`. |
| 41 | + |
| 42 | +### `generationSystemPrompt` |
| 43 | + |
| 44 | +Relative path to the system instructions that should be passed to the LLM when generating code. |
| 45 | + |
| 46 | +### `repairSystemPrompt` |
| 47 | + |
| 48 | +Relative path to the system instructions that should be passed to the LLM when repairing failures. |
| 49 | + |
| 50 | +### `executablePrompts` |
| 51 | + |
| 52 | +Configures the prompts that should be evaluated against the environment. Can contain either strings |
| 53 | +which represent glob patterns pointing to text files with the prompt's text |
| 54 | +(e.g. `./prompts/**/*.md`) or `MultiStepPrompt` objects ([see below](#multi-step-prompts)). |
| 55 | +The prompts can be shared between environments |
| 56 | +(e.g. `executablePrompts: ['../some-other-env/prompts/**/*.md']`). |
| 57 | + |
| 58 | +### `classifyPrompts` |
| 59 | + |
| 60 | +When enabled, the system prompts for this environment won't be included in the final report. |
| 61 | +This is useful when evaluating confidential code. |
| 62 | + |
| 63 | +### `skipInstall` |
| 64 | + |
| 65 | +Whether to skip installing dependencies during the eval run. This can be useful if you've already |
| 66 | +ensured that all dependencies are installed through something like pnpm workspaces. |
| 67 | + |
| 68 | +### Prompt templating |
| 69 | + |
| 70 | +Prompts are typically stored in `.md` files. We support the following template syntax inside of |
| 71 | +these files in order to augment the prompt and reduce boilerplate: |
| 72 | + |
| 73 | +- `{{> embed file='../path/to/file.md' }}` - embeds the content of the specified file in the |
| 74 | + current one. |
| 75 | +- `{{> contextFiles '**/*.foo' }}` - specifies files that should be passed to the LLM as context |
| 76 | + when the prompt is executed. Should be a comma-separated string of glob pattern **within** the |
| 77 | + environments project code. E.g. `{{> contextFiles '**/*.ts, **/*.html' }}` will pass all `.ts` |
| 78 | + and `.html` files as context. |
| 79 | +- `{{CLIENT_SIDE_FRAMEWORK_NAME}}` - insert the name of the client-side framework of the current |
| 80 | + environment. |
| 81 | +- `{{FULL_STACK_FRAMEWORK_NAME}}` - insert the name of the full-stack framework of the current |
| 82 | + environment. |
| 83 | + |
| 84 | +### Prompt-specific ratings |
| 85 | + |
| 86 | +If you want to run a set of ratings against a specific prompt, you can set an object literal |
| 87 | +in the `executablePrompts` array, instead of a string: |
| 88 | + |
| 89 | +```ts |
| 90 | +executablePrompts: [ |
| 91 | + // Runs only with the environment-level ratings. |
| 92 | + './prompts/foo/*.md', |
| 93 | + |
| 94 | + // Runs the ratings specific to the `contact-form.md`, as well as the environment-level ones. |
| 95 | + { |
| 96 | + path: './prompts/bar/contact-form.md', |
| 97 | + ratings: contactFormSpecificRatings, |
| 98 | + }, |
| 99 | +]; |
| 100 | +``` |
| 101 | + |
| 102 | +### Multi-step prompts |
| 103 | + |
| 104 | +Multi-step prompts are prompts meant to evaluate workflows made up of one or more stages. |
| 105 | +Steps execute one after another **inside the same directory**, but are rated individually and |
| 106 | +snapshots after each step are stored in the final report. You can create a multi-step prompt by |
| 107 | +passing an instrance of the `MultiStepPrompt` class into the `executablePrompts` array, for example: |
| 108 | + |
| 109 | +```ts |
| 110 | +executablePrompts: [ |
| 111 | + new MultiStepPrompt('./prompts/about-page', { |
| 112 | + 'step-1': ratingsForFirstStep, |
| 113 | + 'step-2': [...ratingsForFirstStep, ratingsForSecondStep], |
| 114 | + }), |
| 115 | +]; |
| 116 | +``` |
| 117 | + |
| 118 | +The first parameter is the directory from which to resolve the individual step prompts. |
| 119 | +All files in the directory **have to be named `step-{number}.md`**, for example: |
| 120 | + |
| 121 | +**my-env/prompts/about-page/step-1.md:** |
| 122 | + |
| 123 | +``` |
| 124 | +Create an "About us" page. |
| 125 | +``` |
| 126 | + |
| 127 | +**my-env/prompts/about-page/step-2.md:** |
| 128 | + |
| 129 | +``` |
| 130 | +Add a contact form to the "About us" page |
| 131 | +``` |
| 132 | + |
| 133 | +**my-env/prompts/about-page/step-3.md:** |
| 134 | + |
| 135 | +``` |
| 136 | +Make it so submitting the contact form redirects the user back to the homepage. |
| 137 | +``` |
| 138 | + |
| 139 | +The second parameter of `MultiStepPrompt` defines ratings that should be run only against specific |
| 140 | +steps. The key is the name of the step (e.g. `step-2`) while the value are the ratings that should |
| 141 | +run against it. |
| 142 | + |
| 143 | +## Optional properties |
| 144 | + |
| 145 | +These properties aren't required for the environment to run, but can be used to configure it further. |
| 146 | + |
| 147 | +### `sourceDirectory` |
| 148 | + |
| 149 | +Project into which the LLM-generated files will be placed, built, executed and evaluated. |
| 150 | +Can be an entire project or a handful of files that will be merged with the |
| 151 | +`projectTemplate` ([see below](#projecttemplate)) |
| 152 | + |
| 153 | +### `projectTemplate` |
| 154 | + |
| 155 | +Used for reducing the boilerplate when setting up an environment, `projectTemplate` specifies the |
| 156 | +path of the project template that will be merged together with the files from `sourceDirectory` to |
| 157 | +create the final project structure that the evaluation will run against. |
| 158 | + |
| 159 | +For example, if the config has `projectTemplate: './templates/angular', sourceDirectory: './project'`, |
| 160 | +the eval runner will copy the files from `./templates/angular` into the output directory |
| 161 | +and then apply the files from `./project` on top of them, merging directories and replacing |
| 162 | +overlapping files. |
| 163 | + |
| 164 | +### `fullStackFramework` |
| 165 | + |
| 166 | +Name of the full-stack framework that is used in the evaluation, in addition to the |
| 167 | +`clientSideFramework`. If omitted, the `fullStackFramework` will be set to the same value as |
| 168 | +the `clientSideFramework`. |
| 169 | + |
| 170 | +### `mcpServers` |
| 171 | + |
| 172 | +IDs of Model Context Protocol servers that will be started and exposed to the LLM as a part of |
| 173 | +the evaluation. |
| 174 | + |
| 175 | +### `buildCommand` |
| 176 | + |
| 177 | +Command used to build the generated code as a part of the evaluation. |
| 178 | +Defaults to `<package manager> run build`. |
| 179 | + |
| 180 | +### `serveCommand` |
| 181 | + |
| 182 | +Command used to start a local dev server as a part of the evaluation. |
| 183 | +Defaults to `<package manager> run start --port 0`. |
0 commit comments