Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

docusaurus.mdc 10 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
  1. ---
  2. description: Guidelines for updating Docusaurus documentation following best practices
  3. globs: 'site/docs/**/*.md,site/docs/**/*.mdx,site/blog/**/*.md,site/blog/**/*.mdx,site/src/pages/**/*.md,site/src/pages/**/*.mdx'
  4. alwaysApply: false
  5. ---
  6. # Docusaurus Documentation Guidelines
  7. Files: "site/docs/**/\*.md,site/docs/**/_.mdx,site/blog/\*\*/_.md,site/blog/**/\*.mdx,site/src/pages/**/_.md,site/src/pages/\*\*/_.mdx"
  8. This rule provides guidance for updating and maintaining Docusaurus documentation in the promptfoo project, ensuring consistency and best practices.
  9. ## Core Principles
  10. ### Minimal Edits
  11. - Prioritize minimal edits when updating existing documentation
  12. - Avoid creating entirely new sections or rewriting substantial portions
  13. - Focus edits on improving grammar, spelling, clarity, fixing typos, and structural improvements where needed
  14. - Do not modify existing headings (h1, h2, h3, etc.) as they are often linked externally
  15. ### Progressive Disclosure
  16. - Structure content to reveal information progressively
  17. - Begin with essential actions and information, then provide deeper context as necessary
  18. - Organize information from most important to least important
  19. ### Action-Oriented Language
  20. - Clearly outline actionable steps users should take
  21. - Use concise and direct language
  22. - Prefer active voice over passive voice
  23. - Use imperative mood for instructions (e.g., "Install the package" instead of "You should install the package")
  24. ## Terminology and Naming Conventions
  25. ### Preferred Terms
  26. - Use "eval" instead of "evaluation" in all documentation
  27. - When referring to command line usage, use `npx promptfoo eval` rather than `npx promptfoo evaluation`
  28. - Maintain consistency with this terminology across all examples, code blocks, and explanations
  29. ### Project Name Capitalization
  30. - The project name can be written as either "Promptfoo" (capitalized) or "promptfoo" (lowercase) depending on context
  31. - Use "Promptfoo" (capitalized) at the beginning of sentences or in headings
  32. - Use "promptfoo" (lowercase) in code examples, terminal commands, or when referring to the package name
  33. - Be consistent with the chosen capitalization within each document or section
  34. ## Front Matter and SEO
  35. Docusaurus automatically adds metadata to pages for search engines and social media sharing. Use front matter at the top of markdown files to optimize these elements.
  36. ### Required Front Matter Fields
  37. - `title`: The page title shown in search results and browser tabs (can differ from the main heading)
  38. - `description`: A concise summary of the page content (ideally 150-160 characters)
  39. ### Optional Front Matter Fields
  40. - `image`: Path to a thumbnail image for social media cards
  41. - `keywords`: Array of relevant search terms related to the page content
  42. - `sidebar_position`: Control the order of items in the sidebar navigation
  43. ### Examples:
  44. #### Markdown Pages
  45. ```markdown
  46. ---
  47. title: Configuring Promptfoo for Multiple Models
  48. description: Learn how to set up evaluations across different LLM providers with consistent metrics
  49. image: /img/docs/multi-model-comparison.png
  50. keywords: [benchmarking, llm comparison, model evaluation, gpt-4, claude]
  51. sidebar_position: 3
  52. ---
  53. # Comparing Multiple LLM Models
  54. ```
  55. #### React Pages
  56. When creating React pages, add SEO metadata in the Layout component:
  57. ```jsx
  58. import Layout from '@theme/Layout';
  59. function CustomPage() {
  60. return (
  61. <Layout
  62. title="Custom Page Title"
  63. description="Description that will go into a meta tag in <head>"
  64. keywords={['keyword1', 'keyword2']}
  65. >
  66. <main>{/* Page content */}</main>
  67. </Layout>
  68. );
  69. }
  70. ```
  71. ### SEO Best Practices
  72. - Keep titles under 60 characters for optimal display in search results
  73. - Write description meta tags between 150-160 characters
  74. - Include relevant keywords naturally in both title and description
  75. - Use unique titles and descriptions for each page
  76. - For image thumbnails, use 1200×630 pixels for optimal social media display
  77. ## Code Block Formatting
  78. ### Code Block Titles
  79. - Only add a title attribute to code blocks that represent complete, runnable files
  80. - Do not add titles to code fragments, partial examples, or snippets that aren't meant to be used as standalone files
  81. - This rule applies to all code blocks regardless of language (YAML, JavaScript, TypeScript, Python, etc.)
  82. #### Examples of properly titled complete files:
  83. ```yaml title="promptfooconfig.yaml"
  84. # Complete YAML configuration file
  85. description: Basic evaluation setup
  86. prompts:
  87. - file://prompts/my-prompt.txt
  88. providers:
  89. - openai:gpt-4
  90. ```
  91. ```javascript title="example.js"
  92. // Complete JavaScript file
  93. const promptfoo = require('promptfoo');
  94. async function runEval() {
  95. const results = await promptfoo.evaluate({
  96. prompts: ['Hello, world'],
  97. providers: ['openai:gpt-4'],
  98. });
  99. console.log(results);
  100. }
  101. runEval();
  102. ```
  103. ```python title="example.py"
  104. # Complete Python file
  105. from promptfoo import Evaluator
  106. evaluator = Evaluator(
  107. prompts=["Hello, world"],
  108. providers=["openai:gpt-4"]
  109. )
  110. results = evaluator.evaluate()
  111. print(results)
  112. ```
  113. #### Examples of untitled code fragments:
  114. ```yaml
  115. # YAML fragment
  116. prompts:
  117. - 'What is the capital of {{country}}?'
  118. ```
  119. ```javascript
  120. // JavaScript fragment
  121. const score = results.getScore();
  122. ```
  123. ```python
  124. # Python fragment
  125. data = {"input": "example"}
  126. ```
  127. ### Code Block Highlighting
  128. - Use special comment directives to highlight specific lines in code blocks
  129. - Available directives:
  130. - `highlight-next-line`: Highlights the line immediately after the comment
  131. - `highlight-start` and `highlight-end`: Highlight all lines between these two comments
  132. - Line numbers: You can highlight specific line numbers using `{1,4-6,8}` after the language
  133. - Never remove existing highlight directives when editing a document
  134. - Preserve the original author's intent by maintaining their highlighting
  135. #### Examples:
  136. Highlighting the next line:
  137. ```javascript
  138. // highlight-next-line
  139. const result = calculateScore(input);
  140. console.log(result);
  141. ```
  142. Highlighting a range:
  143. ```javascript
  144. function example() {
  145. // highlight-start
  146. const a = 1;
  147. const b = 2;
  148. return a + b;
  149. // highlight-end
  150. }
  151. ```
  152. Highlighting specific lines:
  153. ```javascript {1,3-5}
  154. import { evaluate } from 'promptfoo';
  155. const config = {
  156. prompts: ['Hello'],
  157. providers: ['openai:gpt-4'],
  158. };
  159. ```
  160. ### Code Block Best Practices
  161. - Always specify the language for syntax highlighting
  162. - Use meaningful titles for code blocks when appropriate
  163. - Keep code examples concise and focused
  164. - Ensure code examples are correct and up-to-date
  165. - Include comments in code examples where helpful
  166. ## Admonitions
  167. Docusaurus supports special callout blocks called admonitions. Use these to highlight important information.
  168. ### Admonition Types
  169. - `note`: General information
  170. - `tip`: Useful advice
  171. - `info`: Additional details
  172. - `warning`: Important caution
  173. - `danger`: Critical warning
  174. ### Admonition Syntax
  175. - Create admonitions by wrapping content with three colons `:::` followed by the type
  176. - Always include empty lines before and after the content inside admonitions (especially when using Prettier)
  177. - You can include Markdown formatting within admonitions
  178. ### Examples:
  179. ```markdown
  180. :::note
  181. Some **content** with _Markdown_ `syntax`.
  182. :::
  183. :::tip
  184. Some **content** with _Markdown_ `syntax`.
  185. :::
  186. :::info
  187. Some **content** with _Markdown_ `syntax`.
  188. :::
  189. :::warning
  190. Some **content** with _Markdown_ `syntax`.
  191. :::
  192. :::danger
  193. Some **content** with _Markdown_ `syntax`.
  194. :::
  195. ```
  196. ### Prettier Compatibility
  197. When using Prettier to format Markdown files, always include empty lines around admonition content:
  198. ```markdown
  199. <!-- Correct usage with Prettier -->
  200. :::note
  201. Hello world
  202. :::
  203. <!-- Incorrect usage with Prettier -->
  204. :::note
  205. Hello world
  206. :::
  207. ```
  208. Without empty lines, Prettier might reformat admonitions to invalid syntax, breaking the rendering.
  209. ## Documentation Structure
  210. ### Backlinks
  211. - Search the codebase to provide accurate and relevant backlinks within the documentation
  212. - Include references to specific files, functions, or concepts
  213. - Ensure backlinks are relevant to the current section
  214. ### Related Concepts
  215. - End each documentation section with a concise 'See Also' or 'Related Concepts' heading
  216. - Link to related documentation or concepts
  217. - Format the 'See Also' section consistently:
  218. ```markdown
  219. ## See Also
  220. - [Related Topic 1](mdc:../path/to/related-topic-1.md)
  221. - [Related Topic 2](mdc:../path/to/related-topic-2.md)
  222. - [External Resource](mdc:https://example.com)
  223. ```
  224. ## Content Guidelines
  225. ### Writing Style
  226. - Use clear, concise language
  227. - Maintain a consistent tone throughout the documentation
  228. - Write for an international audience (avoid idioms, colloquialisms, and culturally specific references)
  229. - Spell out acronyms on first use, followed by the acronym in parentheses
  230. ### Examples
  231. - Include practical examples where appropriate
  232. - Make examples realistic and applicable to common use cases
  233. - When showing configuration examples, include all necessary fields
  234. - Demonstrate both basic and advanced usage when relevant
  235. ### Visual Elements
  236. - Use diagrams, screenshots, or illustrations to explain complex concepts
  237. - Ensure images have appropriate alt text for accessibility
  238. - Maintain a consistent visual style across all documentation
  239. - Optimize images for web display
  240. ## Documentation Maintenance
  241. ### Versioning
  242. - Be aware of documentation versioning when making changes
  243. - Ensure changes are appropriate for the current version
  244. - Document version-specific features or changes clearly
  245. ### Reviewing Changes
  246. - Preview changes before submitting
  247. - Check for broken links or formatting issues
  248. - Ensure code examples work as expected
  249. - Verify that changes adhere to these guidelines
  250. ## Example Format
  251. ### Good Documentation Section
  252. ````markdown
  253. ## Using Configuration Files
  254. To use a configuration file with promptfoo, create a `promptfooconfig.yaml` file in your project root:
  255. ```yaml title="promptfooconfig.yaml"
  256. # yaml-language-server: $schema=https://promptfoo.dev/config-schema.json
  257. description: Basic evaluation setup
  258. prompts:
  259. - file://prompts/my-prompt.txt
  260. providers:
  261. - openai:gpt-4
  262. tests:
  263. - vars:
  264. input: 'Hello world'
  265. assert:
  266. - type: contains
  267. value: greeting
  268. ```
  269. ````
  270. Run your evaluation with:
  271. ```bash
  272. npx promptfoo@latest eval
  273. ```
  274. The evaluation will use the configuration from your `promptfooconfig.yaml` file.
  275. ## See Also
  276. - [Configuration Reference](mdc:../reference/configuration.md)
  277. - [Command Line Interface](mdc:../reference/cli.md)
  278. - [Provider Options](mdc:../reference/providers.md)
  279. ```
  280. ```
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...