Implementation:Promptfoo Promptfoo Prompt Suggestions
| Knowledge Sources | |
|---|---|
| Domains | Prompt_Engineering, LLM_Integration |
| Last Updated | 2026-02-14 07:45 GMT |
Overview
Concrete tool for generating prompt variants by calling an LLM to suggest alternative phrasings of a given prompt.
Description
The Prompt_Suggestions module (suggestions.ts) provides the generatePrompts() function that uses the default OpenAI suggestions provider to create prompt variants. Given an input prompt, it sends it to the LLM with a system message requesting variants, and returns the generated alternatives along with token usage statistics.
Usage
Called from the web UI or CLI when users request automatic prompt suggestions or improvements.
Code Reference
Source Location
- Repository: Promptfoo_Promptfoo
- File: src/suggestions.ts
- Lines: 1-50
Signature
export async function generatePrompts(
prompt: string,
_num: number,
): Promise<GeneratePromptsOutput>
Import
import { generatePrompts } from './suggestions';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| prompt | string | Yes | The original prompt to generate variants for |
| _num | number | Yes | Number of variants requested (currently returns 1) |
Outputs
| Name | Type | Description |
|---|---|---|
| prompts | string[] | Array of generated prompt variants |
| error | string | Error message if generation failed |
| tokensUsed | TokenUsage | Token consumption statistics |
Usage Examples
import { generatePrompts } from './suggestions';
const result = await generatePrompts('Summarize the following text: {{text}}', 1);
if (result.prompts) {
console.log('Suggested variant:', result.prompts[0]);
}
console.log('Tokens used:', result.tokensUsed);