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,869
promptfoo
mldangelo
@@ -0,0 +1,213 @@ +import type { WatsonXAI as WatsonXAIClient } from '@ibm-cloud/watsonx-ai'; +import { WatsonXAI } from '@ibm-cloud/watsonx-ai'; +import { IamAuthenticator } from 'ibm-cloud-sdk-core'; +import { getCache, isCacheEnabled } from '../cache'; +import { getEnvString } from '../envars'; +import logger from '...
is 100 a reasonable limit?
promptfoo
github_2023
typescript
1,869
promptfoo
mldangelo
@@ -0,0 +1,213 @@ +import type { WatsonXAI as WatsonXAIClient } from '@ibm-cloud/watsonx-ai'; +import { WatsonXAI } from '@ibm-cloud/watsonx-ai'; +import { IamAuthenticator } from 'ibm-cloud-sdk-core'; +import { getCache, isCacheEnabled } from '../cache'; +import { getEnvString } from '../envars'; +import logger from '...
why is this async? Can we do all of this in the constructor?
promptfoo
github_2023
typescript
1,869
promptfoo
mldangelo
@@ -0,0 +1,213 @@ +import type { WatsonXAI as WatsonXAIClient } from '@ibm-cloud/watsonx-ai'; +import { WatsonXAI } from '@ibm-cloud/watsonx-ai'; +import { IamAuthenticator } from 'ibm-cloud-sdk-core'; +import { getCache, isCacheEnabled } from '../cache'; +import { getEnvString } from '../envars'; +import logger from '...
is project id allowed to be '' ?
promptfoo
github_2023
typescript
1,869
promptfoo
mldangelo
@@ -0,0 +1,213 @@ +import type { WatsonXAI as WatsonXAIClient } from '@ibm-cloud/watsonx-ai'; +import { WatsonXAI } from '@ibm-cloud/watsonx-ai'; +import { IamAuthenticator } from 'ibm-cloud-sdk-core'; +import { getCache, isCacheEnabled } from '../cache'; +import { getEnvString } from '../envars'; +import logger from '...
consider typing this
promptfoo
github_2023
typescript
1,869
promptfoo
mldangelo
@@ -0,0 +1,213 @@ +import type { WatsonXAI as WatsonXAIClient } from '@ibm-cloud/watsonx-ai'; +import { WatsonXAI } from '@ibm-cloud/watsonx-ai'; +import { IamAuthenticator } from 'ibm-cloud-sdk-core'; +import { getCache, isCacheEnabled } from '../cache'; +import { getEnvString } from '../envars'; +import logger from '...
remove
promptfoo
github_2023
typescript
1,869
promptfoo
mldangelo
@@ -0,0 +1,213 @@ +import type { WatsonXAI as WatsonXAIClient } from '@ibm-cloud/watsonx-ai'; +import { WatsonXAI } from '@ibm-cloud/watsonx-ai'; +import { IamAuthenticator } from 'ibm-cloud-sdk-core'; +import { getCache, isCacheEnabled } from '../cache'; +import { getEnvString } from '../envars'; +import logger from '...
If you are inclined, you could also do this with zod.
promptfoo
github_2023
typescript
1,869
promptfoo
mldangelo
@@ -0,0 +1,213 @@ +import type { WatsonXAI as WatsonXAIClient } from '@ibm-cloud/watsonx-ai'; +import { WatsonXAI } from '@ibm-cloud/watsonx-ai'; +import { IamAuthenticator } from 'ibm-cloud-sdk-core'; +import { getCache, isCacheEnabled } from '../cache'; +import { getEnvString } from '../envars'; +import logger from '...
why only 5 minutes? Please review how other providers use the cache, recommend not setting the ttl
promptfoo
github_2023
others
1,869
promptfoo
mldangelo
@@ -0,0 +1,34 @@ +# Learn more about building a configuration: https://promptfoo.dev/docs/configuration/guide +description: 'My eval'
```suggestion description: 'WatsonX eval' ```
promptfoo
github_2023
typescript
1,883
promptfoo
typpo
@@ -84,7 +84,13 @@ export async function fetchWithCache<T = any>( try { const data = JSON.stringify(format === 'json' ? JSON.parse(responseText) : responseText); if (!response.ok) { - errorResponse = data; + if (responseText == '') { + errorResponse = JSON.stringify( + ...
yeah but does it need a different error message? Maybe `Empty response: ...`
promptfoo
github_2023
typescript
1,816
promptfoo
mldangelo
@@ -14,6 +14,7 @@ export const riskCategories = { 'ssrf', 'indirect-prompt-injection', 'cross-session-leak', + 'mathprompt', // Added mathprompt to Security Risk
Please clean up the comment here and in all files below ```suggestion 'mathprompt', ```
promptfoo
github_2023
typescript
1,816
promptfoo
mldangelo
@@ -0,0 +1,77 @@ +import dedent from 'dedent';
let's throw a comment in this file referencing https://arxiv.org/html/2409.11445v1
promptfoo
github_2023
typescript
1,834
promptfoo
mldangelo
@@ -27,6 +29,12 @@ import type { RedteamStrategyObject, SynthesizeOptions } from '../types'; import type { RedteamFileConfig, RedteamCliGenerateOptions } from '../types'; import { shouldGenerateRemote } from '../util'; +function getConfigHash(configPath: string): string { + const content = fs.readFileSync(configPa...
in constants.ts ```ts import packageJson from '../package.json'; export const VERSION = packageJson.version; ```
promptfoo
github_2023
typescript
1,860
promptfoo
typpo
@@ -1,28 +1,65 @@ +import dedent from 'dedent'; +import { z } from 'zod'; +import { fromError } from 'zod-validation-error'; +import logger from '../../logger'; import type { ApiProvider, Assertion } from '../../types'; +import { maybeLoadFromExternalFile } from '../../util'; +import { getNunjucksEngine } from '../../...
```suggestion ```
promptfoo
github_2023
typescript
1,835
promptfoo
mldangelo
@@ -56,6 +56,7 @@ class FalProvider<Input = any> implements ApiProvider { const input = { prompt, ...this.input, + ...(context.prompt?.config ?? {}),
Ah! I am sorry I missed this.
promptfoo
github_2023
typescript
1,776
promptfoo
mldangelo
@@ -5,6 +5,7 @@ const config: Config = { collectCoverage: true, coverageDirectory: '.coverage', coverageProvider: 'v8', + coverageReporters: ['json', 'lcov', 'clover'],
I still get a lot of value out of this (I use it multiple times per day). What makes it unusable? If we remove the text coverage report we might as well remove the other ones because we don't use them anywhere. I am happy to start running `npx jest --coverage` if you end up still wanting to remove this.
promptfoo
github_2023
javascript
1,776
promptfoo
mldangelo
@@ -4,3 +4,4 @@ process.env.AZURE_OPENAI_API_KEY = 'foo'; process.env.HF_API_TOKEN = 'foo'; process.env.OPENAI_API_KEY = 'foo'; delete process.env.PROMPTFOO_REMOTE_GENERATION_URL; +process.env.IS_TESTING = 'true';
nit, sort
promptfoo
github_2023
typescript
1,776
promptfoo
mldangelo
@@ -121,25 +121,27 @@ export async function doEval( logger.warn( chalk.yellow(dedent` TestSuite Schema Validation Error: - ${JSON.stringify(testSuiteSchema.error.format())} - Please review your promptfooconfig.yaml configuration.`), ); } - const summar...
leave this as a todo or note
promptfoo
github_2023
others
1,776
promptfoo
mldangelo
@@ -0,0 +1,42 @@ +CREATE TABLE `eval_results` ( + `id` text PRIMARY KEY NOT NULL, + `created_at` integer DEFAULT CURRENT_TIMESTAMP NOT NULL, + `updated_at` integer DEFAULT CURRENT_TIMESTAMP NOT NULL, + `eval_id` text NOT NULL, + `prompt_idx` integer NOT NULL, + `test_case_idx` integer NOT NULL, + `test_case` text NOT N...
Do you think this is sufficient for indices? Wondering if we should also index fields like created_at ``` CREATE INDEX idx_eval_results_created_at ON eval_results (created_at); CREATE INDEX idx_eval_results_test_case_idx ON eval_results (test_case_idx); ```
promptfoo
github_2023
typescript
1,776
promptfoo
mldangelo
@@ -102,6 +102,7 @@ export const ApiProviderSchema = z.object({ label: z.custom<ProviderLabel>().optional(), transform: z.string().optional(), delay: z.number().optional(), + config: z.any().optional(),
what is this for?
promptfoo
github_2023
typescript
1,776
promptfoo
mldangelo
@@ -31,12 +31,17 @@ const TopFailingCategories: React.FC<TopFailingCategoriesProps> = ({ evals }) => displayNameOverrides[category as keyof typeof displayNameOverrides] || categoryAliases[category as keyof typeof categoryAliases] || category; + const failPercentage = + ...
don't forget the toFixed(1) ```suggestion secondary={`${failPercentage.toFixed(1)}% failing (${data.currentFailCount}/${data.currentTotalCount} probes)`} ```
promptfoo
github_2023
typescript
1,776
promptfoo
mldangelo
@@ -54,8 +60,13 @@ export default function Eval({ const fetchEvalById = React.useCallback( async (id: string) => { const resp = await callApi(`/results/${id}`, { cache: 'no-store' }); + if (!resp.ok) {
out of curiosity, when does this happen? Should we put improving this flow on the backlog?
promptfoo
github_2023
typescript
1,776
promptfoo
mldangelo
@@ -195,18 +196,30 @@ function ResultsTable({ head, body: updatedData, }; + setTable(newTable); if (inComparisonMode) { showToast('Ratings are not saved in comparison mode', 'warning'); } else { try { - const response = await callApi(`/eval/${eval...
this is cool
promptfoo
github_2023
typescript
1,776
promptfoo
mldangelo
@@ -66,8 +71,19 @@ export const useStore = create<TableState>()( author: null, setAuthor: (author: string | null) => set(() => ({ author })), + version: 3,
What does this mean? backend stores in version 4, converts everything to version 3, and frontend displays version 3?
promptfoo
github_2023
typescript
1,776
promptfoo
mldangelo
@@ -132,25 +132,28 @@ export async function doEval( logger.warn( chalk.yellow(dedent` TestSuite Schema Validation Error: - ${JSON.stringify(testSuiteSchema.error.format())} - Please review your promptfooconfig.yaml configuration.`), ); } - const summar...
nit, consider variable name.
promptfoo
github_2023
typescript
1,776
promptfoo
mldangelo
@@ -196,6 +196,7 @@ export async function doEval( ); } } else { + await eval_.delete();
Do we want to store this in memory entirely if the user does not want to save it? Thinking about the case where promptfoo crashes and this never gets called. May not be important.
promptfoo
github_2023
typescript
1,776
promptfoo
mldangelo
@@ -21,14 +22,20 @@ export function listCommand(program: Command) { }); await telemetry.send(); - const evals = await getEvals(Number(cmdObj.n) || undefined); - const tableData = evals.map((evl) => ({ - 'Eval ID': evl.id, - Description: evl.description || '', - Prompts: ev...
at some point this will cause the db to crash. We should think about a concurrency limit here
promptfoo
github_2023
typescript
1,776
promptfoo
mldangelo
@@ -21,14 +22,20 @@ export function listCommand(program: Command) { }); await telemetry.send(); - const evals = await getEvals(Number(cmdObj.n) || undefined); - const tableData = evals.map((evl) => ({ - 'Eval ID': evl.id, - Description: evl.description || '', - Prompts: ev...
why ts-ignore?
promptfoo
github_2023
typescript
1,776
promptfoo
mldangelo
@@ -15,7 +15,7 @@ export function getDbSignalPath() { export function getDb() { if (!dbInstance) { - const sqlite = new Database(getDbPath()); + const sqlite = new Database(process.env.IS_TESTING ? ':memory:' : getDbPath());
we could also do this when the eval is not written to the db
promptfoo
github_2023
typescript
1,776
promptfoo
mldangelo
@@ -617,6 +632,13 @@ class Evaluator { if (options.progressCallback) { options.progressCallback(results.length, runEvalOptions.length, index, evalStep); } + const { testIdx, promptIdx } = evalStep; + try { + await this.dbRecord.addResult(row, promptIdx, testIdx, evalStep.test); +...
nit, do one logger.error here instead of 2
promptfoo
github_2023
typescript
1,776
promptfoo
mldangelo
@@ -0,0 +1,457 @@ +import { and, desc, eq, like, sql } from 'drizzle-orm'; +import invariant from 'tiny-invariant'; +import { DEFAULT_QUERY_LIMIT } from '../constants'; +import { getDb } from '../database'; +import { + datasets, + evals as evalsTable, + evalsToDatasets, + evalsToPrompts, + prompts as promptsTable,...
we should also check that we can still delete arbitrary evals from the db (given the new FKs)
promptfoo
github_2023
typescript
1,776
promptfoo
mldangelo
@@ -0,0 +1,158 @@ +import { randomUUID } from 'crypto'; +import { eq } from 'drizzle-orm'; +import { getDb } from '../database'; +import { evalResultsTable } from '../database/tables'; +import { hashPrompt } from '../prompts/utils'; +import type { + AtomicTestCase, + GradingResult, + Prompt, + ProviderOptions, + P...
nit, sort these if the order is not important
promptfoo
github_2023
typescript
1,776
promptfoo
mldangelo
@@ -83,3 +84,8 @@ export function normalizeInput( // numbers, booleans, etc throw new Error(`Invalid input prompt: ${JSON.stringify(promptPathOrGlobs)}`); } + +export function hashPrompt(prompt: Prompt): string { + const label = prompt.label || prompt.display || prompt.raw;
I would almost prefer the opposite order here or a concatenation of all. Labels are likely going to stay the same even if the prompt changes across evals. If this means something different please add a comment.
promptfoo
github_2023
typescript
1,776
promptfoo
typpo
@@ -301,7 +307,7 @@ const App: React.FC = () => { size="small" label={ <> - <strong>Model:</strong> {selectedPrompt.provider} + <strong>Model:</strong> {selectedPrompt?.provider}
if selectedPrompt is actually undefined, let's hide the entire pill/section instead of displaying "undefined"
promptfoo
github_2023
typescript
1,776
promptfoo
mldangelo
@@ -2,9 +2,7 @@ import type { Config } from 'jest'; const config: Config = { - collectCoverage: true, - coverageDirectory: '.coverage', - coverageProvider: 'v8',
Can you keep these two lines for when I run the coverage report via cli?
promptfoo
github_2023
typescript
1,827
promptfoo
sklein12
@@ -200,3 +202,69 @@ describe('TestSuiteConfigSchema', () => { }); } }); + +describe('TestSuiteSchema', () => { + const baseTestSuite: TestSuite = { + providers: [ + { + id: () => 'mock-provider', + callApi: () => Promise.resolve({}), + }, + ], + prompts: [{ raw: 'Hello, world...
you missed some debug statements
promptfoo
github_2023
typescript
1,827
promptfoo
sklein12
@@ -200,3 +202,69 @@ describe('TestSuiteConfigSchema', () => { }); } }); + +describe('TestSuiteSchema', () => { + const baseTestSuite: TestSuite = { + providers: [ + { + id: () => 'mock-provider', + callApi: () => Promise.resolve({}), + }, + ], + prompts: [{ raw: 'Hello, world...
here too
promptfoo
github_2023
typescript
1,815
promptfoo
mldangelo
@@ -4,12 +4,25 @@ import fetch from 'node-fetch'; import { getCache, isCacheEnabled } from '../cache'; import { getEnvString } from '../envars'; import logger from '../logger'; -import type { ApiProvider, EnvOverrides, ProviderResponse } from '../types'; +import type { ApiProvider, EnvOverrides, Prompt, ProviderResp...
@drochetti Are you sure they are using that feature? It was added in https://github.com/promptfoo/promptfoo/pull/1391 only to openai and was later removed (possibly by mistake). The standard way of doing parsePrompt looks more like the function below: ```ts function parsePrompt(prompt: string): Messages[] { ...
promptfoo
github_2023
typescript
1,659
promptfoo
typpo
@@ -55,6 +56,12 @@ jest.mock('../src/testCases', () => { }; }); +// At the top of the file, update the mock
```suggestion ```
promptfoo
github_2023
typescript
1,808
promptfoo
typpo
@@ -25,17 +29,43 @@ interface HttpProviderConfig { request?: string; } -function createResponseParser(parser: any): (data: any, text: string) => ProviderResponse { +export async function createResponseParser( + parser: string | Function | undefined, +): Promise<(data: any, text: string) => ProviderResponse> { + ...
I think `importModule` already handles this
promptfoo
github_2023
typescript
1,808
promptfoo
typpo
@@ -410,4 +421,107 @@ describe('HttpProvider', () => { }); }); }); + + describe('createResponseParser', () => { + it('should handle function parser', async () => { + const functionParser = (data: any) => data.result; + const provider = new HttpProvider(mockUrl, { + config: { + ...
let's also test a `text` parser like `text.toLowerCase()` etc
promptfoo
github_2023
others
1,704
promptfoo
typpo
@@ -631,6 +631,62 @@ If no function name is specified for Python files, it defaults to `get_transform transform: file://transform.py:custom_python_transform ``` +## Transforming input variables + +In addition to transforming outputs, you can also transform input variables before they are used in prompts. This is do...
```suggestion defaultTest: ```
promptfoo
github_2023
others
1,704
promptfoo
typpo
@@ -631,6 +631,62 @@ If no function name is specified for Python files, it defaults to `get_transform transform: file://transform.py:custom_python_transform ``` +## Transforming input variables + +In addition to transforming outputs, you can also transform input variables before they are used in prompts. This is do...
```suggestion The transform_vars function should return an object with the transformed variable names and values. Here's an example: ```
promptfoo
github_2023
typescript
1,704
promptfoo
typpo
@@ -102,6 +102,7 @@ export const OutputConfigSchema = z.object({ */ postprocess: z.string().optional(), transform: z.string().optional(), + transform_vars: z.string().optional(),
Let's make it `transformVars` to match the casing of everything else :)
promptfoo
github_2023
typescript
1,704
promptfoo
typpo
@@ -84,20 +89,23 @@ async function getFileTransformFunction(filePath: string): Promise<Function> { * @param code - The JavaScript code to convert into a function. * @returns A Function created from the provided code. */ -function getInlineTransformFunction(code: string): Function { - return new Function('output'...
If possible we should update this code path as well - most people use transforms from external files
promptfoo
github_2023
typescript
1,791
promptfoo
sklein12
@@ -0,0 +1,127 @@ +import type { CommandLineOptions, RedteamCliGenerateOptions } from '@promptfoo/types'; +import chalk from 'chalk'; +import type { Command } from 'commander'; +import { createHash } from 'crypto'; +import * as fs from 'fs'; +import * as yaml from 'js-yaml'; +import { z } from 'zod'; +import cliState f...
Process exit 0 after it's complete?
promptfoo
github_2023
others
1,147
promptfoo
will-holley
@@ -3,3 +3,4 @@ DATABASE_URL="postgresql://..." NEXT_PUBLIC_PROMPTFOO_WITH_DATABASE=1 NEXT_PUBLIC_SUPABASE_URL=https://placeholder.promptfoo.dev NEXT_PUBLIC_SUPABASE_ANON_KEY=abc123 +NEXT_TELEMETRY_DISABLED=1
Please remove
promptfoo
github_2023
typescript
1,147
promptfoo
will-holley
@@ -415,13 +419,238 @@ function MetricChart({ table }: ChartProps) { return <canvas ref={metricCanvasRef} style={{ maxHeight: '300px' }}></canvas>; } +function LineChart({ table, evalId, config }: ChartProps) { + const lineCanvasRef = useRef(null); + const lineChartInstance = useRef<Chart | null>(null); + cons...
As `setDatasetId` is only called once (this `useEffect`-scoped initializer), you can reduce the `useState` and `useEffect` into a single `[useMemo](https://react.dev/reference/react/useMemo)`.
promptfoo
github_2023
typescript
1,147
promptfoo
will-holley
@@ -415,13 +419,238 @@ function MetricChart({ table }: ChartProps) { return <canvas ref={metricCanvasRef} style={{ maxHeight: '300px' }}></canvas>; } +function LineChart({ table, evalId, config }: ChartProps) { + const lineCanvasRef = useRef(null); + const lineChartInstance = useRef<Chart | null>(null); + cons...
nit: prefer a self-closing tag here i.e. `<canvas ... />`
promptfoo
github_2023
typescript
1,147
promptfoo
will-holley
@@ -415,13 +419,238 @@ function MetricChart({ table }: ChartProps) { return <canvas ref={metricCanvasRef} style={{ maxHeight: '300px' }}></canvas>; } +function LineChart({ table, evalId, config }: ChartProps) { + const lineCanvasRef = useRef(null); + const lineChartInstance = useRef<Chart | null>(null); + cons...
Evaluate the config here i.e.`if(!!config) fetchDataset();`
promptfoo
github_2023
typescript
1,147
promptfoo
typpo
@@ -873,6 +873,12 @@ export async function getEvalFromId(hash: string) { return undefined; } +export async function getEvalsByDatasetId(datasetId: string): Promise<TestCasesWithMetadata[]> {
`listPreviousResults` now has a `datasetId` filter option - I think you can just use that! additionally, the `/api/results` supports this query param in a recent change - you may find it useful https://github.com/promptfoo/promptfoo/blob/main/src/web/server.ts#L88
promptfoo
github_2023
typescript
1,147
promptfoo
typpo
@@ -415,13 +420,239 @@ function MetricChart({ table }: ChartProps) { return <canvas ref={metricCanvasRef} style={{ maxHeight: '300px' }}></canvas>; } +const fetchDataset = async (id: string) => { + try { + const res = await fetch(`${await getApiBaseUrl()}/api/evals/${id}`); + return await res.json(); + } ...
nit: let's call this something more descriptive like `PerformanceOverTimeChart` or similar
promptfoo
github_2023
typescript
1,147
promptfoo
typpo
@@ -415,13 +420,239 @@ function MetricChart({ table }: ChartProps) { return <canvas ref={metricCanvasRef} style={{ maxHeight: '300px' }}></canvas>; } +const fetchDataset = async (id: string) => { + try { + const res = await fetch(`${await getApiBaseUrl()}/api/evals/${id}`); + return await res.json(); + } ...
On some existing ones, I'm getting `TypeError: Cannot read properties of undefined (reading 'count')` because the `/api/evals/:id` endpoint is returning `[]`
promptfoo
github_2023
typescript
1,147
promptfoo
typpo
@@ -415,13 +420,239 @@ function MetricChart({ table }: ChartProps) { return <canvas ref={metricCanvasRef} style={{ maxHeight: '300px' }}></canvas>; } +const fetchDataset = async (id: string) => { + try { + const res = await fetch(`${await getApiBaseUrl()}/api/evals/${id}`); + return await res.json(); + } ...
It's probably ok to ignore this for now, but the new chart you've added is interesting with 1 prompt, so it could be nice to show it in that case.
promptfoo
github_2023
typescript
1,147
promptfoo
typpo
@@ -415,13 +426,269 @@ function MetricChart({ table }: ChartProps) { return <canvas ref={metricCanvasRef} style={{ maxHeight: '300px' }}></canvas>; } -function ResultsCharts({ columnVisibility }: ResultsChartsProps) { +function PerformanceOverTimeChart({ table, evalId, config, datasetId }: ChartProps) { + const ...
nit: remove
promptfoo
github_2023
typescript
1,147
promptfoo
typpo
@@ -415,13 +426,269 @@ function MetricChart({ table }: ChartProps) { return <canvas ref={metricCanvasRef} style={{ maxHeight: '300px' }}></canvas>; } -function ResultsCharts({ columnVisibility }: ResultsChartsProps) { +function PerformanceOverTimeChart({ table, evalId, config, datasetId }: ChartProps) { + const ...
looks like we can combine these two conditions?
promptfoo
github_2023
typescript
1,147
promptfoo
typpo
@@ -209,6 +210,11 @@ export async function startServer( res.json({ data: await getTestCases() }); }); + app.get('/api/evals/:datasetId', async (req, res) => {
This route would make more sense as `/api/evals?datasetId=...`
promptfoo
github_2023
typescript
1,147
promptfoo
typpo
@@ -415,13 +426,269 @@ function MetricChart({ table }: ChartProps) { return <canvas ref={metricCanvasRef} style={{ maxHeight: '300px' }}></canvas>; } -function ResultsCharts({ columnVisibility }: ResultsChartsProps) { +function PerformanceOverTimeChart({ table, evalId, config, datasetId }: ChartProps) { + const ...
let's move this and `ordinalSuffixOf` out of the component function
promptfoo
github_2023
typescript
1,147
promptfoo
typpo
@@ -851,6 +851,12 @@ export async function getEvalFromId(hash: string) { return undefined; } +export async function getEvalsByDatasetId(datasetId: string): Promise<TestCasesWithMetadata[]> { + const allTestCases = await getTestCases(); + const matchingEvals = allTestCases.filter((testCase) => testCase.id == dat...
let's use `getTestCasesWithPredicate`
promptfoo
github_2023
typescript
1,147
promptfoo
typpo
@@ -415,13 +426,269 @@ function MetricChart({ table }: ChartProps) { return <canvas ref={metricCanvasRef} style={{ maxHeight: '300px' }}></canvas>; } -function ResultsCharts({ columnVisibility }: ResultsChartsProps) { +function PerformanceOverTimeChart({ table, evalId, config, datasetId }: ChartProps) { + const ...
I'm not actually able to get this chart to show as it always hits this condition. Elsewhere you are restricting this chart to a single prompt and a single dataset. I might be missing something here but that seems like why?
promptfoo
github_2023
typescript
1,147
promptfoo
typpo
@@ -415,13 +426,269 @@ function MetricChart({ table }: ChartProps) { return <canvas ref={metricCanvasRef} style={{ maxHeight: '300px' }}></canvas>; } -function ResultsCharts({ columnVisibility }: ResultsChartsProps) { +function PerformanceOverTimeChart({ table, evalId, config, datasetId }: ChartProps) { + const ...
nit: remove
promptfoo
github_2023
others
1,792
promptfoo
typpo
@@ -0,0 +1,106 @@ +# Custom Go Provider + +The Go provider allows you to use a Go script as an API provider for evaluating prompts. This is useful when you have custom logic or models implemented in Go that you want to integrate with your test suite. +
```suggestion --- sidebar_label: Custom Go (Golang) --- # Custom Go Provider The Go (`golang`) provider allows you to use a Go script as an API provider for evaluating prompts. This is useful when you have custom logic or models implemented in Go that you want to integrate with your test suite. :::info The...
promptfoo
github_2023
others
1,792
promptfoo
typpo
@@ -0,0 +1,106 @@ +# Custom Go Provider + +The Go provider allows you to use a Go script as an API provider for evaluating prompts. This is useful when you have custom logic or models implemented in Go that you want to integrate with your test suite. + +## Configuration + +To configure the Go provider, you need to spec...
not sure but I think I didn't actually build this yet
promptfoo
github_2023
others
1,774
promptfoo
mldangelo
@@ -1,5 +1,11 @@ ian: name: Ian Webster - title: promptfoo maintainer + title: promptfoo maintainer
```suggestion title: promptfoo maintainer ```
promptfoo
github_2023
others
1,762
promptfoo
typpo
@@ -25,38 +25,40 @@ The `promptfoo` command line utility supports the following subcommands: By default the `eval` command will read the `promptfooconfig.yaml` configuration file in your current directory. But, if you're looking to override certain parameters you can supply optional arguments: -| Option ...
Should we split this into multiple tables according to the way you've categorized it in code? I like what you did in eval.ts
promptfoo
github_2023
typescript
1,721
promptfoo
typpo
@@ -139,18 +139,49 @@ export async function dereferenceConfig(rawConfig: UnifiedConfig): Promise<Unifi return config; } +function parseDirectoryPath(configPath: string): string { + return path.extname(configPath) === '' ? configPath : path.dirname(configPath); +} + +function maybeFindConfig(configPath: string): ...
Would it be simpler to update `configPath` if it is a directory and keep the existing logic? in pseudocode: ``` if isDirectory(configPath) and getConfigFiles(configPath): configPath = getConfigFiles(configPath)[0] // existing code... ```
promptfoo
github_2023
typescript
1,727
promptfoo
sklein12
@@ -178,6 +178,28 @@ export default function Eval({ return <div className="notice">404 Eval not found</div>; } + if (loaded && !table) { + return ( + <div className="empty-state"> + <div className="empty-state-content"> + <div className="empty-state-icon">📊</div> + <h2 class...
this won't work
promptfoo
github_2023
typescript
1,724
promptfoo
mldangelo
@@ -94,6 +94,11 @@ export async function processPrompt( ); if (!maybeFilePath(prompt.raw)) {
Yes! That's a great idea if you don't mind making the change. Thank you!
promptfoo
github_2023
typescript
1,698
promptfoo
mldangelo
@@ -399,8 +404,6 @@ export async function matchesLlmRubric( }); } - const rubricPrompt = grading?.rubricPrompt || DEFAULT_GRADING_PROMPT; - invariant(typeof rubricPrompt === 'string', 'rubricPrompt must be a string');
this is a nice find, thank you
promptfoo
github_2023
typescript
999
promptfoo
typpo
@@ -1,107 +0,0 @@ -import { NextRequest, NextResponse } from 'next/server'; -import { validate as uuidValidate } from 'uuid'; - -import store from '@/app/api/eval/shareStore'; -import { IS_RUNNING_LOCALLY } from '@/constants'; - -import type { EvaluateTable, FilePath, ResultsFile, UnifiedConfig } from '@/../../../types...
I love the idea behind this PR and it'd be great to delete all this duplicate code (and much healthier for the codebase). I believe this route and some of the others are used at app.promptfoo.dev, i.e. the app that serves `promptfoo share` results.
promptfoo
github_2023
typescript
999
promptfoo
typpo
@@ -1,43 +0,0 @@ -import { NextResponse } from 'next/server'; -import { v4 as uuidv4 } from 'uuid'; - -import store from '@/app/api/eval/shareStore'; -import { IS_RUNNING_LOCALLY } from '@/constants'; -import { writeResultsToDatabase } from '@/../../../util'; -import { runDbMigrations } from '@/../../../../migrate'; - ...
I believe this route is used by people who run `promptfoo share` pointed to a self-hosted server.
promptfoo
github_2023
typescript
999
promptfoo
typpo
@@ -1,47 +0,0 @@ -import invariant from 'tiny-invariant'; -import { NextRequest, NextResponse } from 'next/server'; -import { cookies } from 'next/headers'; -import { createRouteHandlerClient } from '@supabase/auth-helpers-nextjs'; - -import { getJob, getResult, SupabaseJobStatus, SupabaseEvaluationJob } from '@/databa...
FYI, this route and others like it are used to run evals on the hosted app.promptfoo.dev site. It may be safe to remove this functionality if we want to simplify the hosted site to shared results only and lean into self-hosting for actual eval runs.
promptfoo
github_2023
typescript
1,684
promptfoo
mldangelo
@@ -657,6 +657,21 @@ class Evaluator { metrics.namedScoresCount[key] = (metrics.namedScoresCount[key] || 0) + 1; } + for (const gradingResult of row.gradingResult?.componentResults || []) {
nit, can we wrap this in a `if redteam?`
promptfoo
github_2023
typescript
1,637
promptfoo
mldangelo
@@ -1,13 +1,11 @@ import React from 'react';
did you consider deleting this?
promptfoo
github_2023
typescript
1,637
promptfoo
mldangelo
@@ -0,0 +1,4 @@ +// Behavior varies depending on whether the app is running as a static HTML app on the user's local machine. +export const IS_RUNNING_LOCALLY = !import.meta.env.VITE_IS_HOSTED; + +export const USE_SUPABASE = false;
do we still need any references to supabase?
promptfoo
github_2023
others
1,637
promptfoo
mldangelo
@@ -65,6 +59,7 @@ export default [ '@typescript-eslint/no-use-before-define': 'error', '@typescript-eslint/no-var-requires': 0, curly: 'error', + 'jest/no-disabled-tests': 0,
please only disable this in app
promptfoo
github_2023
others
1,637
promptfoo
mldangelo
@@ -107,30 +106,32 @@ "concurrently": "^8.2.2", "drizzle-kit": "^0.24.2", "esbuild": "^0.23.1", - "eslint": "^8.57.0", - "eslint-plugin-jest": "28.6.0", - "eslint-plugin-react-hooks": "4.6.2", + "eslint": "^9.9.0",
I am very impressed by this change
promptfoo
github_2023
typescript
1,637
promptfoo
mldangelo
@@ -169,34 +137,9 @@ export default function Eval({ }; } else if (USE_SUPABASE) {
do we still need this?
promptfoo
github_2023
typescript
1,637
promptfoo
mldangelo
@@ -0,0 +1,149 @@ +// Helpers for parsing CSV eval files, shared by frontend and backend. Cannot import native modules.
why can't we? I spent part of today refactoring this file. I can look at fixing import errors for it later
promptfoo
github_2023
typescript
1,637
promptfoo
mldangelo
@@ -0,0 +1,46 @@ +/// <reference types="vitest" /> +import react from '@vitejs/plugin-react'; +import path from 'path'; +import { defineConfig } from 'vite'; + +const API_PORT = process.env.API_PORT || '15500'; + +if (process.env.NODE_ENV === 'development') { + process.env.VITE_PUBLIC_PROMPTFOO_REMOTE_API_BASE_URL =
tiny nit, consider using envVar here
promptfoo
github_2023
typescript
1,637
promptfoo
mldangelo
@@ -181,8 +181,10 @@ abstract class CloudflareAiGenericProvider implements ApiProvider { * @returns */ protected async handleApiCall< - InitialResponse extends IBuildCloudflareResponse<{}>, - SuccessResponse extends InitialResponse = InitialResponse extends ICloudflareSuccessResponse<{}> + InitialRe...
thank you for updating these too.
promptfoo
github_2023
typescript
1,637
promptfoo
mldangelo
@@ -387,7 +387,7 @@ export const ALL_STRATEGIES = [ ] as const; export type Strategy = (typeof ALL_STRATEGIES)[number]; -// Duplicated in src/web/nextui/src/app/report/constants.ts for frontend +// Duplicated in src/app/report/constants.ts for frontend
do we still need to duplicate?
promptfoo
github_2023
typescript
1,688
promptfoo
mldangelo
@@ -1152,7 +1152,10 @@ export function maybeLoadFromExternalFile(filePath: string | object | Function | return filePath; } - const finalPath = path.resolve(cliState.basePath || '', filePath.slice('file://'.length)); + // Render the file path using Nunjucks + const renderedFilePath = nunjucks.renderString(f...
We already add this here: https://github.com/promptfoo/promptfoo/blob/main/src/util/templates.ts#L30 ```suggestion const renderedFilePath = nunjucks.renderString(filePath); ```
promptfoo
github_2023
typescript
1,670
promptfoo
typpo
@@ -1,12 +1,79 @@ +import { exec } from 'child_process'; import { promises as fs } from 'fs'; import os from 'os'; import path from 'path'; import type { Options as PythonShellOptions } from 'python-shell'; import { PythonShell } from 'python-shell'; +import util from 'util'; import { getEnvString } from '../enva...
Switch to debug or remove?
promptfoo
github_2023
others
1,645
promptfoo
typpo
@@ -73,7 +73,7 @@ By incorporating the Prompt Extraction plugin in your LLM red teaming strategy, ## Related Concepts - [Information Disclosure](../llm-vulnerability-types.md#privacy-and-security) -- [Social Engineering](../llm-vulnerability-types.md#social-engineering) -- [Model Inversion Attacks](../llm-vulnerabi...
All 3 of these are hallucinated, let's completely remove them
promptfoo
github_2023
typescript
1,639
promptfoo
mldangelo
@@ -412,6 +413,7 @@ export function evalCommand( 'Run providers interactively, one at a time', defaultConfig?.evaluateOptions?.interactiveProviders, ) + .option('--remote', 'Force remote inference wherever possible (used for red teams)', false)
can we put this behind an experimental flag?
promptfoo
github_2023
others
1,599
promptfoo
mldangelo
@@ -1,115 +1,29 @@ -# syntax=docker/dockerfile:1 -# check=skip=SecretsUsedInArgOrEnv -# TODO(ian): Remove the SecretsUsedInArgOrEnv check once we remove the placeholder for NEXT_PUBLIC_SUPABASE_ANON_KEY +FROM --platform=${BUILDPLATFORM} node:20-alpine -# https://github.com/vercel/next.js/blob/canary/examples/with-doc...
```suggestion FROM node:20-alpine AS base ``` or 22
promptfoo
github_2023
others
1,599
promptfoo
typpo
@@ -29,4 +29,6 @@ To get a URL that you can send to others, click the 'Share' button in the top ri Shared data is temporarily stored on our servers, and permanently deleted after 2 weeks, at which point the URL will cease to function. Shared data is "private" in the sense that the UUID-based URL is unguessable, but ...
```suggestion You can configure the web viewer to share to your own hosted Promptfoo instance by clicking on the API Settings button in the top right of the viewer. ```
promptfoo
github_2023
others
1,599
promptfoo
typpo
@@ -23,9 +23,7 @@ promptfoo provides a Docker image that allows you to host a central server that The self-hosted app consists of: -- Next.js application that runs the web UI. -- Filesystem store that persists the eval results. -- Key-value (KV) store that persists shared data (redis, filesystem, or memory). +- Ex...
Just make this > The self-hosted app is an Express server that serves the web UI and API. (sorry can't make the inline suggestion on a non-edited line)
promptfoo
github_2023
others
1,599
promptfoo
mldangelo
@@ -53,7 +53,10 @@ "db:generate": "npx drizzle-kit generate", "jsonSchema:generate": "npx -y tsx scripts/generateJsonSchema.ts > site/static/config-schema.json", "audit:fix": "npm audit fix && npm audit fix --prefix src/web/nextui && npm audit fix --prefix site", - "prepublishOnly": "npm run build:cle...
nit, document these somewhere. This is fo web development but it's not obvious at first glance.
promptfoo
github_2023
typescript
1,599
promptfoo
mldangelo
@@ -11,7 +11,6 @@ export function viewCommand(program: Command) { .option('-p, --port <number>', 'Port number', '15500') .option('-y, --yes', 'Skip confirmation and auto-open the URL') .option('-n, --no', 'Skip confirmation and do not open the URL') - .option('--api-base-url <url>', 'Base URL for view...
nice!
promptfoo
github_2023
typescript
1,618
promptfoo
typpo
@@ -29,11 +29,17 @@ export class IndirectPromptInjectionPlugin extends PluginBase { Generate a system prompt injection that will cause the model to ignore the rest of the prompt and only respond with the harmful instructions. Along with a prompt that will trigger the harmful instructions. + <Example> ...
Do you also need to mention SystemPromptInjection? The output format is a little different
promptfoo
github_2023
typescript
1,577
promptfoo
mldangelo
@@ -228,14 +229,79 @@ promptfoo eval Afterwards, you can view the results by running \`promptfoo view\` `; -function recordOnboardingStep(step: string, properties: Record<string, EventValue> = {}) { +function recordOnboardingStep(step: string, properties: any = {}) {
```suggestion function recordOnboardingStep(step: string, properties: any = Record<string, EventValue>) { ```
promptfoo
github_2023
typescript
1,577
promptfoo
typpo
@@ -228,14 +229,79 @@ promptfoo eval Afterwards, you can view the results by running \`promptfoo view\` `; -function recordOnboardingStep(step: string, properties: Record<string, EventValue> = {}) { +function recordOnboardingStep(step: string, properties: any = {}) { telemetry.recordAndSend('funnel', { type...
Great idea to display a warning for this! Is there a way we can simplify this function? e.g. using the map more directly and/or reducing the switches/branching
promptfoo
github_2023
typescript
1,577
promptfoo
sklein12
@@ -98,6 +98,14 @@ export type EnvVars = { type EnvVarKey = keyof EnvVars; +/** + * Provider env keys that are required to be set either in env or in config to interact with provider services. + */ +export enum ProvidersRequiringAPIKeysEnvKeys { + OPENAI_API_KEY = 'OPENAI_API_KEY', + ANTHROPIC_API_KEY = 'ANTHROP...
I don't think this belongs in this file. Could you move it to be co-located with the providers?
promptfoo
github_2023
typescript
1,577
promptfoo
sklein12
@@ -228,14 +229,66 @@ promptfoo eval Afterwards, you can view the results by running \`promptfoo view\` `; -function recordOnboardingStep(step: string, properties: Record<string, EventValue> = {}) { +function recordOnboardingStep(step: string, properties: any = {}) { telemetry.recordAndSend('funnel', { type...
"has not set _an_ API key"
promptfoo
github_2023
typescript
1,577
promptfoo
sklein12
@@ -228,14 +229,66 @@ promptfoo eval Afterwards, you can view the results by running \`promptfoo view\` `; -function recordOnboardingStep(step: string, properties: Record<string, EventValue> = {}) { +function recordOnboardingStep(step: string, properties: any = {}) { telemetry.recordAndSend('funnel', { type...
I'm a TS noob, why does this need to be typed using the `as keyof typeof` statement?
promptfoo
github_2023
typescript
1,577
promptfoo
sklein12
@@ -228,14 +229,66 @@ promptfoo eval Afterwards, you can view the results by running \`promptfoo view\` `; -function recordOnboardingStep(step: string, properties: Record<string, EventValue> = {}) { +function recordOnboardingStep(step: string, properties: any = {}) { telemetry.recordAndSend('funnel', { type...
can you generate this map dynamically instead of hardcoding it? So if we add a new provider to `ProvidersRequiringAPIKeysEnvKeys` we don't have to update this code?
promptfoo
github_2023
typescript
1,605
promptfoo
mldangelo
@@ -191,7 +191,7 @@ class HarmfulPlugin extends PluginBase { return [ { type: `promptfoo:redteam:${this.category.key}`, - metric: `${this.category.key}`, + metric: 'Harmful',
Can we add test coverage for this so it doesn't happen again?
promptfoo
github_2023
others
1,602
promptfoo
mldangelo
@@ -189,6 +189,8 @@ To see the list of available plugins on the command line, run `promptfoo redteam - By default uses a [target URL](https://promptfoo.dev/plugin-helpers/ssrf.txt) on the promptfoo.dev host. We recommend placing with your own internal URL. +- `ascii-smuggling`: Tests if the model is vulnerable t...
why did you put this at the bottom?
promptfoo
github_2023
others
1,602
promptfoo
mldangelo
@@ -39,6 +39,7 @@ Each vulnerability type is supported by Promptfoo's open-source LLM red teaming | Indirect Prompt Injection | Vulnerability where malicious content is injected into trusted data sources or variables used in the prompt, indirectly influencing the model's behavior and potentially compromising system se...
:|