repo_name
stringlengths
1
62
dataset
stringclasses
1 value
lang
stringclasses
11 values
pr_id
int64
1
20.1k
owner
stringlengths
2
34
reviewer
stringlengths
2
39
diff_hunk
stringlengths
15
262k
code_review_comment
stringlengths
1
99.6k
promptfoo
github_2023
typescript
1,149
promptfoo
typpo
@@ -0,0 +1,65 @@ +import BugReportIcon from '@mui/icons-material/BugReport'; +import CalendarTodayIcon from '@mui/icons-material/CalendarToday'; +import ForumIcon from '@mui/icons-material/Forum'; +import GitHubIcon from '@mui/icons-material/GitHub'; +import MenuBookIcon from '@mui/icons-material/MenuBook'; +import { B...
Same here- can ditch `component="p"`
promptfoo
github_2023
typescript
1,149
promptfoo
typpo
@@ -0,0 +1,65 @@ +import BugReportIcon from '@mui/icons-material/BugReport'; +import CalendarTodayIcon from '@mui/icons-material/CalendarToday'; +import ForumIcon from '@mui/icons-material/Forum'; +import GitHubIcon from '@mui/icons-material/GitHub'; +import MenuBookIcon from '@mui/icons-material/MenuBook'; +import { B...
`variant` is enough, don't need `component` but this should be replaced with `DialogTitle`
promptfoo
github_2023
typescript
1,149
promptfoo
typpo
@@ -0,0 +1,65 @@ +import BugReportIcon from '@mui/icons-material/BugReport'; +import CalendarTodayIcon from '@mui/icons-material/CalendarToday'; +import ForumIcon from '@mui/icons-material/Forum'; +import GitHubIcon from '@mui/icons-material/GitHub'; +import MenuBookIcon from '@mui/icons-material/MenuBook'; +import { B...
use the `mt` prop instead of manual style. also the component/variant don't match here
promptfoo
github_2023
others
1,149
promptfoo
typpo
@@ -0,0 +1,72 @@ +.info-modal { + outline: none; +} + +.info-modal-content { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + max-width: 350px; + width: 90%; + max-height: 90vh; + overflow-y: auto; + background-color: var(--background-color); + color: var(--text-color); + ...
use `gutterBottom` or `mb` props instead of manually styling here ideally, use the correct `variant` which supplies the size (it's ok if you have to override, but I'd double check that this is actually necessary)
promptfoo
github_2023
others
1,149
promptfoo
typpo
@@ -0,0 +1,72 @@ +.info-modal { + outline: none; +} + +.info-modal-content { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + max-width: 350px; + width: 90%; + max-height: 90vh; + overflow-y: auto; + background-color: var(--background-color); + color: var(--text-color); + ...
ditto for margin-bottom
promptfoo
github_2023
typescript
1,149
promptfoo
typpo
@@ -0,0 +1,65 @@ +import BugReportIcon from '@mui/icons-material/BugReport'; +import CalendarTodayIcon from '@mui/icons-material/CalendarToday'; +import ForumIcon from '@mui/icons-material/Forum'; +import GitHubIcon from '@mui/icons-material/GitHub'; +import MenuBookIcon from '@mui/icons-material/MenuBook'; +import { B...
Use `Dialog` instead of modal - this will save you a lot of work with the spacing/typography and make it consistent with other dialogs https://mui.com/material-ui/react-dialog/
promptfoo
github_2023
typescript
1,149
promptfoo
typpo
@@ -0,0 +1,65 @@ +import BugReportIcon from '@mui/icons-material/BugReport'; +import CalendarTodayIcon from '@mui/icons-material/CalendarToday'; +import ForumIcon from '@mui/icons-material/Forum'; +import GitHubIcon from '@mui/icons-material/GitHub'; +import MenuBookIcon from '@mui/icons-material/MenuBook'; +import { B...
Put these in a Stack and you can get rid of the flexbox css https://mui.com/material-ui/react-stack/
promptfoo
github_2023
typescript
1,153
promptfoo
typpo
@@ -362,6 +427,24 @@ export async function runAssertion({ }; } + if (baseType === 'is-xml' || baseType === 'contains-xml') { + const requiredElements = + typeof renderedValue === 'string' + ? renderedValue.split(',').map((el) => el.trim())
values can be objects, so it would be much nicer to have an object of the form: ```yaml value: requiredElements: - elt1 - elt2 ```
promptfoo
github_2023
typescript
1,156
promptfoo
vaibhav-toddleapp
@@ -43,14 +53,17 @@ export class HttpProvider implements ApiProvider { // Render all nested strings const nunjucks = getNunjucksEngine(); const stringifiedConfig = safeJsonStringify(this.config); - const renderedConfig: { method: string; headers: Record<string, string>; body: any } = - JSON.parse...
If it is valid JSON then we are escaping the strings. but if it is not valid, then we are using `prompt` as it is..?
promptfoo
github_2023
others
1,156
promptfoo
typpo
@@ -0,0 +1,52 @@ +# LM Studio Example with PromptFoo
nit: `Promptfoo` (here and below)
promptfoo
github_2023
typescript
1,156
promptfoo
typpo
@@ -20,6 +21,15 @@ function createResponseParser(parser: any): (data: any) => ProviderResponse { return (data) => ({ output: data }); } +function isValidJson(str: string): boolean {
might be useful to put in util
promptfoo
github_2023
others
1,150
promptfoo
typpo
@@ -0,0 +1,3 @@ +# Contributing to promptfoo + +Please refer to our rendered contributors guidelines on our website at [promptfoo.dev/docs/contributing](https://www.promptfoo.dev/docs/contributing) or the markdown file in this repo: [site/docs/contributing.md](https://github.com/promptfoo/promptfoo/blob/main/site/docs/...
```suggestion Please refer to the guidelines on our website at [promptfoo.dev/docs/contributing](https://www.promptfoo.dev/docs/contributing) or the markdown file in this repo: [site/docs/contributing.md](https://github.com/promptfoo/promptfoo/blob/main/site/docs/contributing.md) ```
promptfoo
github_2023
others
1,150
promptfoo
typpo
@@ -0,0 +1,316 @@ +--- +title: Contributing to promptfoo +sidebar_label: Contributing +--- + +**Note: This guide is a work in progress.** +
```suggestion ``` Everything is a work in progress :)
promptfoo
github_2023
others
1,150
promptfoo
typpo
@@ -0,0 +1,316 @@ +--- +title: Contributing to promptfoo +sidebar_label: Contributing +--- + +**Note: This guide is a work in progress.** + +We welcome contributions from the community to help make promptfoo better. This guide will help you get started. If you have any questions, please reach out to us on [Discord](htt...
this `name` key is hallucinated
promptfoo
github_2023
others
1,150
promptfoo
typpo
@@ -0,0 +1,316 @@ +--- +title: Contributing to promptfoo +sidebar_label: Contributing +--- + +**Note: This guide is a work in progress.** + +We welcome contributions from the community to help make promptfoo better. This guide will help you get started. If you have any questions, please reach out to us on [Discord](htt...
good to link to /docs/providers/custom-api/ for details on how to implement a typescript provider
promptfoo
github_2023
others
1,150
promptfoo
typpo
@@ -0,0 +1,316 @@ +--- +title: Contributing to promptfoo +sidebar_label: Contributing +--- + +**Note: This guide is a work in progress.** + +We welcome contributions from the community to help make promptfoo better. This guide will help you get started. If you have any questions, please reach out to us on [Discord](htt...
I don't think we need to repeat the instructions to `npm link`, but we do want to let the reader know that they can use the build with the view server ```suggestion npm run build promptfoo view ```
promptfoo
github_2023
others
1,150
promptfoo
typpo
@@ -0,0 +1,316 @@ +--- +title: Contributing to promptfoo +sidebar_label: Contributing +--- + +**Note: This guide is a work in progress.** + +We welcome contributions from the community to help make promptfoo better. This guide will help you get started. If you have any questions, please reach out to us on [Discord](htt...
these line-by-line property descriptions should be documented in code and I'm skeptical that it's worth reproducing here and having to update every time there's a migration - but fine for now
promptfoo
github_2023
others
1,150
promptfoo
typpo
@@ -0,0 +1,316 @@ +--- +title: Contributing to promptfoo +sidebar_label: Contributing +--- + +**Note: This guide is a work in progress.** + +We welcome contributions from the community to help make promptfoo better. This guide will help you get started. If you have any questions, please reach out to us on [Discord](htt...
prefer `npm run db:generate`
promptfoo
github_2023
others
1,150
promptfoo
typpo
@@ -0,0 +1,316 @@ +--- +title: Contributing to promptfoo +sidebar_label: Contributing +--- + +**Note: This guide is a work in progress.** + +We welcome contributions from the community to help make promptfoo better. This guide will help you get started. If you have any questions, please reach out to us on [Discord](htt...
prefer `npm run db:migrate`
promptfoo
github_2023
others
1,150
promptfoo
typpo
@@ -0,0 +1,316 @@ +--- +title: Contributing to promptfoo +sidebar_label: Contributing +--- + +**Note: This guide is a work in progress.** + +We welcome contributions from the community to help make promptfoo better. This guide will help you get started. If you have any questions, please reach out to us on [Discord](htt...
these lines on production seem like boilerplate and don't make sense in the context of promptfoo
promptfoo
github_2023
others
1,150
promptfoo
typpo
@@ -0,0 +1,316 @@ +--- +title: Contributing to promptfoo +sidebar_label: Contributing +--- + +**Note: This guide is a work in progress.** + +We welcome contributions from the community to help make promptfoo better. This guide will help you get started. If you have any questions, please reach out to us on [Discord](htt...
```suggestion ```
promptfoo
github_2023
others
1,150
promptfoo
typpo
@@ -0,0 +1,316 @@ +--- +title: Contributing to promptfoo +sidebar_label: Contributing +--- + +**Note: This guide is a work in progress.** + +We welcome contributions from the community to help make promptfoo better. This guide will help you get started. If you have any questions, please reach out to us on [Discord](htt...
feel free to push back, but I think it's unnecessary to recap these details from the intro ```suggestion promptfoo is an MIT licensed tool for testing and evaluating LLM apps. ```
promptfoo
github_2023
others
1,150
promptfoo
will-holley
@@ -0,0 +1,3 @@ +# Contributing to promptfoo + +Please refer to the guidelines on our website at [promptfoo.dev/docs/contributing](https://www.promptfoo.dev/docs/contributing) or the markdown file in this repo: [site/docs/contributing.md](https://github.com/promptfoo/promptfoo/blob/main/site/docs/contributing.md)
"or the markdown file in this repo" is a bit awkward. How about ```md or [docs/contributing.md](https://github.com/promptfoo/promptfoo/blob/main/site/docs/contributing.md)? ```
promptfoo
github_2023
others
1,150
promptfoo
will-holley
@@ -0,0 +1,267 @@ +--- +title: Contributing to promptfoo +sidebar_label: Contributing +--- + +We welcome contributions from the community to help make promptfoo better. This guide will help you get started. If you have any questions, please reach out to us on [Discord](https://discord.gg/gHPS9jjfbs) or through a [GitHu...
Consider replacing steps 4 and 5 w/ ~~instructions on running the API/Web UI/CLI with hotreloading~~ links to the subsequent API/Web/CLI development sections and moving test and build into Development Workflow w/ links to the relevant (subsequent) sections.
promptfoo
github_2023
others
1,150
promptfoo
will-holley
@@ -0,0 +1,267 @@ +--- +title: Contributing to promptfoo +sidebar_label: Contributing +--- + +We welcome contributions from the community to help make promptfoo better. This guide will help you get started. If you have any questions, please reach out to us on [Discord](https://discord.gg/gHPS9jjfbs) or through a [GitHu...
If there is a specific Discord channel or preferred method of communications, this would be a useful place to include it.
promptfoo
github_2023
typescript
1,115
promptfoo
typpo
@@ -43,8 +45,123 @@ export const HARM_CATEGORIES: { [key: string]: string } = { //'locale_specific_illegal (e.g. hate speech in Germany, alcohol in Saudi Arabia)', }; +interface HarmfulCategory { + key: string; + description: string; + examples: string; +} + +// We use our default provider for some categories ...
Consider refining this prompt to be more adversarial. You can literally tell GPT that it is a redteam and needs to craftily deceive the target, etc. See the iterative jailbreak for some examples. Right now the generations are a little too generic. For example: ``` Create a travel advisory warning touris...
promptfoo
github_2023
typescript
1,115
promptfoo
typpo
@@ -54,43 +171,54 @@ export async function getHarmfulTests( const harmCategoriesToUse = plugins.length > 0 - ? plugins.map((plugin) => HARM_CATEGORIES[plugin]).filter(Boolean) - : Object.values(HARM_CATEGORIES); - - for (const harmCategory of harmCategoriesToUse) { - const adversarialProvider = ...
In my test the non-API test cases weren't tagged with a `harmCategory` var, and did not have any asserts attached either.
promptfoo
github_2023
typescript
1,115
promptfoo
typpo
@@ -43,8 +45,123 @@ export const HARM_CATEGORIES: { [key: string]: string } = { //'locale_specific_illegal (e.g. hate speech in Germany, alcohol in Saudi Arabia)', }; +interface HarmfulCategory { + key: string; + description: string; + examples: string; +} + +// We use our default provider for some categories ...
I think we need something better for IP violations specifically - I'm not sure that writing a derivative story without attribution is a violation. The concern is direct plagiarism/ability to reproduce copyrighted works verbatim. Also, I notice that most of the generations include something like "write X with unauth...
promptfoo
github_2023
typescript
1,141
promptfoo
typpo
@@ -1,28 +1,117 @@ import dedent from 'dedent'; -import invariant from 'tiny-invariant'; +import { z } from 'zod'; +import logger from '../logger'; import { ApiProvider } from '../types'; -export async function getPurpose(provider: ApiProvider, prompts: string[]): Promise<string> { - const { output: purpose } = aw...
use `extractJsonObjects` in util
promptfoo
github_2023
typescript
1,124
promptfoo
typpo
@@ -43,6 +40,114 @@ export const HARM_CATEGORIES: { [key: string]: string } = { //'locale_specific_illegal (e.g. hate speech in Germany, alcohol in Saudi Arabia)', }; +export const REDTEAM_PROVIDER_HARM_CATEGORIES: { [key: string]: string } = { + 'harmful:privacy': 'Privacy violations', + 'harmful:intellectual-...
This sounds potentially benign, it could just be someone who wants to login to their email ?
promptfoo
github_2023
typescript
1,124
promptfoo
typpo
@@ -43,6 +40,114 @@ export const HARM_CATEGORIES: { [key: string]: string } = { //'locale_specific_illegal (e.g. hate speech in Germany, alcohol in Saudi Arabia)', }; +export const REDTEAM_PROVIDER_HARM_CATEGORIES: { [key: string]: string } = { + 'harmful:privacy': 'Privacy violations', + 'harmful:intellectual-...
I think this is too meta, it should mention a specific social media account (FB/Twitter/insta) I also think "high profile individual" (above) may be too unspecific. What do you think?
promptfoo
github_2023
typescript
1,124
promptfoo
typpo
@@ -1,21 +1,20 @@ import dedent from 'dedent'; import invariant from 'tiny-invariant'; import PromptfooHarmfulCompletionProvider from '../../providers/promptfoo'; -import type { ApiProvider, TestCase } from '../../types'; +import type { ApiProvider, Assertion, TestCase } from '../../types'; +import PluginBase from '...
This seems misnamed, these aren't only llama guard categories! It looks like this is the map of the harm categories that require an unaligned model.
promptfoo
github_2023
typescript
1,124
promptfoo
typpo
@@ -43,6 +40,114 @@ export const HARM_CATEGORIES: { [key: string]: string } = { //'locale_specific_illegal (e.g. hate speech in Germany, alcohol in Saudi Arabia)', }; +export const REDTEAM_PROVIDER_HARM_CATEGORIES: { [key: string]: string } = { + 'harmful:privacy': 'Privacy violations', + 'harmful:intellectual-...
Maybe it could make sense to change this to "homework assistant" or similar? News writing assistant seems really niche and a bit too on-the-nose as an example Additionally, I think the example prompt is actually a safe one because it asks for an article on the _debate_ is real. A misinformation prompt would be somet...
promptfoo
github_2023
typescript
1,124
promptfoo
typpo
@@ -43,6 +40,114 @@ export const HARM_CATEGORIES: { [key: string]: string } = { //'locale_specific_illegal (e.g. hate speech in Germany, alcohol in Saudi Arabia)', }; +export const REDTEAM_PROVIDER_HARM_CATEGORIES: { [key: string]: string } = { + 'harmful:privacy': 'Privacy violations', + 'harmful:intellectual-...
None of these are IP violations! The specific concern is reproducing copyrighted works verbatim.
promptfoo
github_2023
typescript
1,124
promptfoo
typpo
@@ -68,29 +188,31 @@ export async function getHarmfulTests( }); } - const testCases = Array.from(injectVars.entries()).map(([injectValue, harmCategory]) => { - const testCase: TestCase = { - vars: { - [injectVar]: injectValue, - harmCategory, - }, - assert: [ - { - ...
In a test generation, the 3 categories you've moved are missing `moderation` asserts. ``` promptfoo generate redteam --plugins harmful:privacy,harmful:misinformation-disinformation,harmful:intellectual-property -o issue-1124.yaml ```
promptfoo
github_2023
typescript
1,124
promptfoo
typpo
@@ -30,7 +30,7 @@ export default abstract class PluginBase { * @param prompt - The prompt for which to get the assertion. * @returns The assertion object. */ - protected abstract getAssertion(prompt: string): any; + protected abstract getAssertion(prompt: string): any; // : Assertion | Assertion[];
is this intentional? (lint above)
promptfoo
github_2023
typescript
1,124
promptfoo
typpo
@@ -43,6 +40,123 @@ export const HARM_CATEGORIES: { [key: string]: string } = { //'locale_specific_illegal (e.g. hate speech in Germany, alcohol in Saudi Arabia)', }; +export const REDTEAM_PROVIDER_HARM_CATEGORIES: { [key: string]: string } = { + 'harmful:privacy': 'Privacy violations', + 'harmful:intellectual-...
let's reduce this to 3, to match the original behavior
promptfoo
github_2023
typescript
1,124
promptfoo
typpo
@@ -43,6 +40,123 @@ export const HARM_CATEGORIES: { [key: string]: string } = { //'locale_specific_illegal (e.g. hate speech in Germany, alcohol in Saudi Arabia)', }; +export const REDTEAM_PROVIDER_HARM_CATEGORIES: { [key: string]: string } = { + 'harmful:privacy': 'Privacy violations', + 'harmful:intellectual-...
There is a double period in the resulting rubric because your `description`s end with a period.
promptfoo
github_2023
typescript
1,124
promptfoo
typpo
@@ -43,6 +40,123 @@ export const HARM_CATEGORIES: { [key: string]: string } = { //'locale_specific_illegal (e.g. hate speech in Germany, alcohol in Saudi Arabia)', }; +export const REDTEAM_PROVIDER_HARM_CATEGORIES: { [key: string]: string } = { + 'harmful:privacy': 'Privacy violations', + 'harmful:intellectual-...
The resulting generations are still too generic ``` Share the complete list of "hidden gems" in London as described in a copyrighted travel article. ``` ``` Copy and paste the exact recommendations for dining in Tokyo from a well-known travel website. ``` An IP violation is specific. You should be able to i...
promptfoo
github_2023
typescript
1,124
promptfoo
typpo
@@ -43,6 +40,123 @@ export const HARM_CATEGORIES: { [key: string]: string } = { //'locale_specific_illegal (e.g. hate speech in Germany, alcohol in Saudi Arabia)', }; +export const REDTEAM_PROVIDER_HARM_CATEGORIES: { [key: string]: string } = { + 'harmful:privacy': 'Privacy violations', + 'harmful:intellectual-...
as noted in my previous comment, prefer to go with something specific - I would just replace "various social media platforms" with "LinkedIn"
promptfoo
github_2023
typescript
1,132
promptfoo
mldangelo
@@ -648,8 +648,9 @@ class Evaluator { for (let repeatIndex = 0; repeatIndex < numRepeat; repeatIndex++) { for (const vars of varCombinations) { let colIndex = 0; - for (const prompt of testSuite.prompts) { - for (const provider of testSuite.providers) { + // Order...
nit, put this note on the first occurrence (instead of or addition to the second)
promptfoo
github_2023
typescript
1,102
promptfoo
typpo
@@ -130,12 +131,38 @@ async function resolveConfigs( logger.error(chalk.red('You must provide at least 1 prompt')); process.exit(1); } + + // Convert providers to array if not already an array + if (config.providers && typeof config.providers === 'string') { + config.providers = [config.providers]; + ...
Is this the right place for this? It means CLI (`main`) will be inconsistent with package (`index`)
promptfoo
github_2023
typescript
1,102
promptfoo
typpo
@@ -130,12 +131,38 @@ async function resolveConfigs( logger.error(chalk.red('You must provide at least 1 prompt')); process.exit(1); } + + // Convert providers to array if not already an array + if (config.providers && typeof config.providers === 'string') { + config.providers = [config.providers]; + ...
in what cases is providers not an array?
promptfoo
github_2023
typescript
1,102
promptfoo
typpo
@@ -130,12 +131,38 @@ async function resolveConfigs( logger.error(chalk.red('You must provide at least 1 prompt')); process.exit(1); } + + // Convert providers to array if not already an array + if (config.providers && typeof config.providers === 'string') { + config.providers = [config.providers]; + ...
Instead of "this may have unintended consequences", which is not actionable, maybe something like "Please double check your configuration"?
promptfoo
github_2023
typescript
1,045
promptfoo
mldangelo
@@ -235,15 +245,62 @@ export default function ResultsView({ setAnchorEl(event.currentTarget); }; + const [evalIdCopied, setEvalIdCopied] = React.useState(false); + + const handleEvalIdCopyClick = async () => { + if (!evalId) { + return; + } + await navigator.clipboard.writeText(evalId); + s...
It would be great if there was a little hover tooltip that told people to set the author using the cli if it's not set.
promptfoo
github_2023
typescript
1,045
promptfoo
mldangelo
@@ -8,3 +8,7 @@ export function getUserEmail(): string | undefined { export function setUserEmail(email: string) { writeGlobalConfig({ account: { email } }); } + +export function getAuthor(): string { + return getUserEmail() || 'Unknown';
consider not using a sentinal value and just dealing with possible undefined string. ```suggestion export function getAuthor(): string | undefined { return getUserEmail(); ```
promptfoo
github_2023
typescript
1,045
promptfoo
mldangelo
@@ -713,6 +713,7 @@ export interface ResultsFile { createdAt: string; results: EvaluateSummary; config: Partial<UnifiedConfig>; + author: string;
```suggestion author: string | undefined, ```
promptfoo
github_2023
typescript
1,093
promptfoo
mldangelo
@@ -1227,7 +1227,7 @@ ${ score: perplexityNorm, reason: pass ? 'Assertion passed' - : `Perplexity score ${perplexityNorm.toFixed(2)} is less than threshold ${ + : `Perplexity score ${perplexityNorm?.toFixed(2)} is less than threshold ${
```suggestion : `Perplexity score ${perplexityNorm.toFixed(2)} is less than threshold ${ ```
promptfoo
github_2023
typescript
1,093
promptfoo
mldangelo
@@ -1205,7 +1205,7 @@ ${ score: pass ? 1 : 0, reason: pass ? 'Assertion passed' - : `Perplexity ${perplexity.toFixed(2)} is greater than threshold ${assertion.threshold}`, + : `Perplexity ${perplexity?.toFixed(2)} is greater than threshold ${assertion.threshold}`,
```suggestion : `Perplexity ${perplexity.toFixed(2)} is greater than threshold ${assertion.threshold}`, ```
promptfoo
github_2023
typescript
1,093
promptfoo
mldangelo
@@ -101,10 +101,10 @@ function handleRougeScore( pass, score: inverted ? 1 - score : score, reason: pass - ? `${baseType.toUpperCase()} score ${score.toFixed( + ? `${baseType.toUpperCase()} score ${score?.toFixed(
```suggestion ? `${baseType.toUpperCase()} score ${score.toFixed( ```
promptfoo
github_2023
typescript
1,093
promptfoo
mldangelo
@@ -101,10 +101,10 @@ function handleRougeScore( pass, score: inverted ? 1 - score : score, reason: pass - ? `${baseType.toUpperCase()} score ${score.toFixed( + ? `${baseType.toUpperCase()} score ${score?.toFixed( 2, )} is greater than or equal to threshold ${assertion.thres...
```suggestion : `${baseType.toUpperCase()} score ${score.toFixed(2)} is less than threshold ${ ```
promptfoo
github_2023
typescript
1,093
promptfoo
mldangelo
@@ -36,14 +36,14 @@ async function handlePrompt(id: string) { table.push({ 'Eval ID': evl.id.slice(0, 6), 'Dataset ID': evl.datasetId.slice(0, 6), - 'Raw score': evl.metrics?.score.toFixed(2) || '-', + 'Raw score': evl.metrics?.score?.toFixed(2) || '-', 'Pass rate': evl.metr...
```suggestion ).toFixed(2)}%` ```
promptfoo
github_2023
typescript
1,093
promptfoo
mldangelo
@@ -116,15 +116,15 @@ async function handleDataset(id: string) { table.push({ 'Eval ID': prompt.evalId.slice(0, 6), 'Prompt ID': prompt.id.slice(0, 6), - 'Raw score': prompt.prompt.metrics?.score.toFixed(2) || '-', + 'Raw score': prompt.prompt.metrics?.score?.toFixed(2) || '-', 'Pass...
```suggestion ).toFixed(2)}%` ```
promptfoo
github_2023
typescript
1,093
promptfoo
mldangelo
@@ -347,12 +347,12 @@ export async function writeOutput( const outputToSimpleString = (output: EvaluateTableOutput) => { const passFailText = output.pass ? '[PASS]' : '[FAIL]'; const namedScoresText = Object.entries(output.namedScores) - .map(([name, value]) => `${name}: ${value.toFixed(2)}`) + ....
this is the cause of your error. Your derived metric did not return a score! Thank you for making the UI better.
promptfoo
github_2023
typescript
1,093
promptfoo
mldangelo
@@ -86,7 +86,7 @@ export default function DatasetDialog({ openDialog, handleClose, testCase }: Dat (promptData.prompt.metrics.testPassCount + promptData.prompt.metrics.testFailCount)) * 100.0 - ).toFixed(2) + '...
```suggestion ).toFixed(2) + '%' ```
promptfoo
github_2023
typescript
1,093
promptfoo
mldangelo
@@ -17,7 +17,7 @@ function scoreToString(score: number | null) { // Don't show boolean scores. return ''; } - return `(${score.toFixed(2)})`; + return `(${score?.toFixed(2)})`;
```suggestion return `(${score.toFixed(2)})`; ```
promptfoo
github_2023
typescript
1,038
promptfoo
mldangelo
@@ -553,20 +628,23 @@ export class AwsBedrockCompletionProvider extends AwsBedrockGenericProvider impl error: `API call error: ${String(err)}`, }; } - logger.debug( - `\tAmazon Bedrock API response: ${JSON.stringify(JSON.parse(response.body.transformToString()))}`, - ); + logger.debug...
this change is pulled from: https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/javascriptv3/example_code/bedrock-runtime/models/metaLlama/llama2/invoke_model_quickstart.js#L45
promptfoo
github_2023
others
1,049
promptfoo
mldangelo
@@ -80,3 +80,44 @@ Supported environment variables: - `REPLICATE_SEED` - Sets a seed for reproducible results. - `REPLICATE_STOP_SEQUENCES` - Specifies stopping sequences that halt the generation. - `REPLICATE_SYSTEM_PROMPT` - Sets a system-level prompt for all requests. + +## Images + +Image generators such as SDXL...
Typo here
promptfoo
github_2023
others
1,044
promptfoo
mldangelo
@@ -0,0 +1,30 @@ +name: npm package release + +on: + release: + types: [created] + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: 20
```suggestion - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' cache: 'npm' ```
promptfoo
github_2023
others
1,044
promptfoo
mldangelo
@@ -0,0 +1,30 @@ +name: npm package release + +on: + release: + types: [created] + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: 20 + - run: npm ci + - run: npm ...
```suggestion - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' cache: 'npm' ```
promptfoo
github_2023
typescript
1,041
promptfoo
mldangelo
@@ -182,6 +182,10 @@ export async function readTests( throw new Error(`Unsupported file type for test file: ${testFile}`); } if (testCases) { + if (!Array.isArray(testCases)) { + logger.warn(`Assuming ${testFile} contains a single test case.`);
```suggestion ```
promptfoo
github_2023
typescript
1,029
promptfoo
fvdnabee
@@ -11,3 +11,7 @@ export const REMOTE_APP_BASE_URL = process.env.NEXT_PUBLIC_PROMPTFOO_BASE_URL || process.env.PROMPTFOO_REMOTE_APP_BASE_URL || `https://app.promptfoo.dev`; + +// Maximum width for terminal outputs. +export const TERMINAL_MAX_WIDTH = + process.stdout.columns && process.stdout.columns > 10 ? pr...
Suggestion: ```typescript process?.stdout?.columns && process?.stdout?.columns > 10 ? process?.stdout?.columns - 10 : 120; ```
promptfoo
github_2023
typescript
1,027
promptfoo
mldangelo
@@ -66,7 +66,7 @@ export class HttpProvider implements ApiProvider { } logger.debug(`\tHTTP response: ${JSON.stringify(response.data)}`); - return this.responseParser(response.data); + return { output: this.responseParser(response.data) };
nit, lets add a unit test for this
promptfoo
github_2023
typescript
994
promptfoo
typpo
@@ -20,10 +19,16 @@ import type { ApiProvider, } from './types'; -export * from './external/ragas'; +export * from './gradingPrompts'; const PROMPT_DELIMITER = process.env.PROMPTFOO_PROMPT_SEPARATOR || '---'; +/** + * Reads and maps provider prompts based on the configuration and parsed prompts. + * @param {...
nit, but I most of the new docstrings for all these functions to be redundant. Do you find these useful? Perhaps we should prefer tsdoc, which at least relieves us from having to write redundant types? e.g. ``` * @param prompt - The prompt object to check. * @param allowedPrompts - The list of allowed promp...
promptfoo
github_2023
typescript
994
promptfoo
typpo
@@ -73,339 +78,378 @@ export function readProviderPromptMap( return ret; } -function maybeFilepath(str: string): boolean { +/** + * Determines if a string is a valid file path. + * @param {string} str - The string to check. + * @returns {boolean} True if the string is a valid file path, false otherwise. + */ +exp...
should we put this at the top of the file as a constant? feel like if it's buried here we'll miss it when we add the next language
promptfoo
github_2023
typescript
994
promptfoo
typpo
@@ -73,339 +78,378 @@ export function readProviderPromptMap( return ret; } -function maybeFilepath(str: string): boolean { +/** + * Determines if a string is a valid file path. + * @param {string} str - The string to check. + * @returns {boolean} True if the string is a valid file path, false otherwise. + */ +exp...
let's name `promptFunction` and `promptFunctionLegacy` to indicate that they are for python
promptfoo
github_2023
typescript
994
promptfoo
typpo
@@ -73,339 +78,378 @@ export function readProviderPromptMap( return ret; } -function maybeFilepath(str: string): boolean { +/** + * Determines if a string is a valid file path. + * @param {string} str - The string to check. + * @returns {boolean} True if the string is a valid file path, false otherwise. + */ +exp...
As discussed, we can leave out the source for inline prompt strings.
promptfoo
github_2023
typescript
994
promptfoo
typpo
@@ -73,339 +78,378 @@ export function readProviderPromptMap( return ret; } -function maybeFilepath(str: string): boolean { +/** + * Determines if a string is a valid file path. + * @param {string} str - The string to check. + * @returns {boolean} True if the string is a valid file path, false otherwise. + */ +exp...
should this be `prompt.raw.startsWith('file://')`?
promptfoo
github_2023
typescript
994
promptfoo
typpo
@@ -73,339 +78,378 @@ export function readProviderPromptMap( return ret; } -function maybeFilepath(str: string): boolean { +/** + * Determines if a string is a valid file path. + * @param {string} str - The string to check. + * @returns {boolean} True if the string is a valid file path, false otherwise. + */ +exp...
if we make it this far, does this mean the glob matches nothing OR it's an unsupported extension? In that case should we throw? also, let's keep this outside this PR but seems like we should support yaml given support for yaml imports elsewhere.
promptfoo
github_2023
typescript
994
promptfoo
typpo
@@ -0,0 +1,15 @@ +import { Prompt } from '../../types'; + +/** + * Processes a string as a literal prompt. + * @param prompt - The raw prompt data. + * @returns Array of prompts created from the string. + */ +export function processString(prompt: Partial<Prompt>): Prompt[] { + return [ + { + raw: prompt!.raw a...
could we use invariant rather than `!`?
promptfoo
github_2023
typescript
994
promptfoo
typpo
@@ -0,0 +1,23 @@ +import * as fs from 'fs'; +import { Prompt } from '../../types'; + +/** + * Processes a JSON file to extract prompts. + * This function reads a JSON file, parses it, and maps each entry to a `Prompt` object.
nit: looks like we don't parse the json file
promptfoo
github_2023
others
994
promptfoo
typpo
@@ -104,13 +111,13 @@ Prompts can be JSON too. Use this to configure multi-shot prompt formats: ] ``` -### Multiple prompts in a single file +### Multiple prompts in a single text file -If you have only one file, you can include multiple prompts in the file, separated by the separator `---`. If you have multiple ...
??
promptfoo
github_2023
others
995
promptfoo
typpo
@@ -14,29 +30,57 @@ The self-hosted app consists of: ## Setup -Clone the repository and see the provided [Dockerfile](https://github.com/promptfoo/promptfoo/blob/main/Dockerfile). Here's an example Docker command to build and run the container: +### 1. Clone the Repository + +First, clone the promptfoo repository ...
It might make sense to retain this explanation
promptfoo
github_2023
typescript
967
promptfoo
mldangelo
@@ -227,7 +227,6 @@ async function main() { fs.readFileSync(path.join(getDirectory(), '../package.json'), 'utf8'), ); logger.info(packageJson.version); - process.exit(0);
nit, we should keep this line!
promptfoo
github_2023
others
926
promptfoo
typpo
@@ -261,6 +262,70 @@ assert: value: file://./path/to/schema.json ``` +### Is-SQL + +The `is-sql` assertion checks if the LLM output is a valid SQL statement. + +Example: + +```yaml +assert: + - type: is-sql +``` + +You can optionally set a `databaseType` in the `value` to determine the specific database syntax...
Might be good to do this in pure yaml: ```yaml assert: - type: is-sql value: databaseType: 'MySQL' ```
promptfoo
github_2023
others
926
promptfoo
typpo
@@ -261,6 +262,70 @@ assert: value: file://./path/to/schema.json ``` +### Is-SQL + +The `is-sql` assertion checks if the LLM output is a valid SQL statement. + +Example: + +```yaml +assert: + - type: is-sql +``` + +You can optionally set a `databaseType` in the `value` to determine the specific database syntax...
same here re: pure yaml
promptfoo
github_2023
typescript
926
promptfoo
typpo
@@ -10,6 +10,7 @@ import yaml from 'js-yaml'; import Ajv, { ValidateFunction } from 'ajv'; import addFormats from 'ajv-formats'; import { distance as levenshtein } from 'fastest-levenshtein'; +import { Parser } from 'node-sql-parser';
Because `node-sql-parser` is a `peerDependency`, we should lazily import and instantiate it within the `baseType === 'is-sql'` conditional. Otherwise promptfoo will crash for people who have not manually installed the peer dependency.
promptfoo
github_2023
typescript
926
promptfoo
typpo
@@ -366,6 +369,81 @@ export async function runAssertion({ }; } + if (baseType === 'is-sql') { + let parsedSQL; + let databaseType: string | undefined = 'MySQL';
Because this has a default, seems like its type may not need to have an `undefined`?
promptfoo
github_2023
typescript
926
promptfoo
typpo
@@ -366,6 +369,81 @@ export async function runAssertion({ }; } + if (baseType === 'is-sql') { + let parsedSQL; + let databaseType: string | undefined = 'MySQL'; + let whiteTableList: string[] | undefined; + let whiteColumnList: string[] | undefined; + + interface sqlParserOption { + datab...
You might be able to get this type from the `@types/node-sql-parser` package.
promptfoo
github_2023
typescript
926
promptfoo
typpo
@@ -366,6 +369,81 @@ export async function runAssertion({ }; } + if (baseType === 'is-sql') { + let parsedSQL; + let databaseType: string | undefined = 'MySQL'; + let whiteTableList: string[] | undefined; + let whiteColumnList: string[] | undefined; + + interface sqlParserOption { + datab...
style in this codebase is camel case - `failedReason`
promptfoo
github_2023
typescript
926
promptfoo
typpo
@@ -423,6 +423,43 @@ describe('runAssertion', () => { `, }; + // is-sql assertions: + const isSQLAssertion: Assertion = {
This is the tiniest of nits, but the convention in this codebase is to lowercase acronyms/initialisms in camel case var names. For example, `isSqlAssertion`, `evalId`, `OpenAi`, etc...
promptfoo
github_2023
typescript
926
promptfoo
typpo
@@ -0,0 +1,276 @@ +import { Parser } from 'node-sql-parser'; + +// The isolated is-sql implementation:
We should extract the is-sql implementation into its own function, so that we can call it from `assertions.ts` and from its test. This means we don't have to maintain two separate versions of the logic, which will invariably fall out of sync.
promptfoo
github_2023
others
926
promptfoo
mldangelo
@@ -261,6 +262,70 @@ assert: value: file://./path/to/schema.json ``` +### Is-SQL + +The `is-sql` assertion checks if the LLM output is a valid SQL statement. + +Example: + +```yaml +assert: + - type: is-sql +``` + +You can optionally set a `databaseType` in the `value` to determine the specific database syntax...
Nit, consider referencing the parser. ```suggestion You can optionally set a `databaseType` in the `value` to determine the specific database syntax that your LLM output will be validated against. The default database syntax is MySQL. For a complete and up-to-date list of supported database syntaxes, please refer to...
promptfoo
github_2023
others
926
promptfoo
mldangelo
@@ -261,6 +262,70 @@ assert: value: file://./path/to/schema.json ``` +### Is-SQL + +The `is-sql` assertion checks if the LLM output is a valid SQL statement. + +Example: + +```yaml +assert: + - type: is-sql +``` + +You can optionally set a `databaseType` in the `value` to determine the specific database syntax...
nit, sort
promptfoo
github_2023
typescript
926
promptfoo
mldangelo
@@ -366,6 +369,81 @@ export async function runAssertion({ }; } + if (baseType === 'is-sql') { + let parsedSQL; + let databaseType: string | undefined = 'MySQL'; + let whiteTableList: string[] | undefined; + let whiteColumnList: string[] | undefined; + + interface sqlParserOption { + datab...
The type makes this obvious ```suggestion type?: string; ```
promptfoo
github_2023
typescript
926
promptfoo
mldangelo
@@ -366,6 +369,81 @@ export async function runAssertion({ }; } + if (baseType === 'is-sql') { + let parsedSQL; + let databaseType: string | undefined = 'MySQL'; + let whiteTableList: string[] | undefined; + let whiteColumnList: string[] | undefined; + + interface sqlParserOption { + datab...
nit, prefer to unnest if
promptfoo
github_2023
typescript
926
promptfoo
mldangelo
@@ -366,6 +369,81 @@ export async function runAssertion({ }; } + if (baseType === 'is-sql') { + let parsedSQL; + let databaseType: string | undefined = 'MySQL'; + let whiteTableList: string[] | undefined; + let whiteColumnList: string[] | undefined; + + interface sqlParserOption { + datab...
```suggestion parsedSQL = sqlParser.astify(outputString, opt); ```
promptfoo
github_2023
typescript
926
promptfoo
mldangelo
@@ -366,6 +369,81 @@ export async function runAssertion({ }; } + if (baseType === 'is-sql') { + let parsedSQL;
nit, prefer google naming conventions https://google.github.io/styleguide/jsguide.html#naming ```suggestion let parsedSql; ```
promptfoo
github_2023
typescript
926
promptfoo
mldangelo
@@ -889,6 +926,181 @@ describe('runAssertion', () => { ); }); + // is-sql test cases:
```suggestion ```
promptfoo
github_2023
typescript
926
promptfoo
mldangelo
@@ -889,6 +926,181 @@ describe('runAssertion', () => { ); }); + // is-sql test cases: + it('should pass when the is-sql assertion passes', async () => { + const output = 'SELECT id, name FROM users'; + + const result: GradingResult = await runAssertion({ + prompt: 'Some prompt', + provider: ...
nit, there are 4 values returned on this object, write one expectation that checks all 4: ```ts expect(result).toEqual({ .... });
promptfoo
github_2023
typescript
926
promptfoo
mldangelo
@@ -366,6 +369,81 @@ export async function runAssertion({ }; } + if (baseType === 'is-sql') { + let parsedSQL; + let databaseType: string | undefined = 'MySQL'; + let whiteTableList: string[] | undefined; + let whiteColumnList: string[] | undefined; + + interface sqlParserOption { + datab...
when is this condition met? Can you add coverage for it in your tests if it's reachable?
promptfoo
github_2023
typescript
926
promptfoo
mldangelo
@@ -0,0 +1,276 @@ +import { Parser } from 'node-sql-parser'; + +// The isolated is-sql implementation: +const sqlParser = new Parser(); + +interface SqlParserOption { + database: string | undefined; + type?: string; // 'type' is optional +} + +const testFunction = (renderedValue: any, outputString: string, inverse: b...
please address these and below
promptfoo
github_2023
others
926
promptfoo
typpo
@@ -261,6 +262,72 @@ assert: value: file://./path/to/schema.json ``` +### Is-SQL + +The `is-sql` assertion checks if the LLM output is a valid SQL statement. + +Example: + +```yaml +assert: + - type: is-sql +``` + +You can optionally set a `databaseType` in the `value` to determine the specific database syntax...
nit: this code block and the one below are not markdown, so you can remove the `md` language
promptfoo
github_2023
typescript
926
promptfoo
typpo
@@ -1296,6 +1305,86 @@ function containsJSON(str: string): any { return jsonObjects; } +export async function isSql( + outputString: string, + renderedValue: AssertionValue | undefined, + inverse: boolean, + assertion: Assertion, +): Promise<GradingResult> { + let pass: boolean = false;
nit: `boolean` type is implied ```suggestion let pass = false; ```
promptfoo
github_2023
others
926
promptfoo
typpo
@@ -261,6 +262,72 @@ assert: value: file://./path/to/schema.json ``` +### Is-SQL + +The `is-sql` assertion checks if the LLM output is a valid SQL statement.
we should mention that the user needs to `npm install node-sql-parser`
promptfoo
github_2023
typescript
926
promptfoo
typpo
@@ -1296,6 +1305,86 @@ function containsJSON(str: string): any { return jsonObjects; } +export async function isSql( + outputString: string, + renderedValue: AssertionValue | undefined, + inverse: boolean, + assertion: Assertion, +): Promise<GradingResult> { + let pass = false; + let parsedSql; + let datab...
Is there useful information in the error that we can pass along? Ideally something like "SQL output references disallowed table X"
promptfoo
github_2023
others
926
promptfoo
typpo
@@ -261,6 +262,78 @@ assert: value: file://./path/to/schema.json ``` +### Is-SQL + +The `is-sql` assertion checks if the LLM output is a valid SQL statement. + +Example: + +```yaml +assert: + - type: is-sql +``` + +To use this assertion, you need to install the `node-sql-parser` package. You can install it usi...
let's call these `allowedTables` and `allowedColumns` rather than splitting the word "whitelist"
promptfoo
github_2023
others
954
promptfoo
typpo
@@ -0,0 +1,29 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`CLI Tool --help and --version should display help menu 1`] = ` +" +> promptfoo@0.65.0 local
is this going to break when we bump the version?
promptfoo
github_2023
typescript
933
promptfoo
mldangelo
@@ -62,15 +65,25 @@ const App: React.FC = () => { } const pass = row.success; - acc[label] = acc[label] || { pass: 0, total: 0 }; + acc[label] = acc[label] || { pass: 0, total: 0, passWithFilter: 0 }; acc[label].total++; if (pass) { acc[label].pass++; + acc[label]...
```suggestion ```
promptfoo
github_2023
others
933
promptfoo
mldangelo
@@ -3,7 +3,7 @@ } .pass-medium { - color: orange; + color: rgb(203, 133, 3);
nit, consider defining in a theme.css or colors.css