Skip to content

Commit

Permalink
✨ feat: update options and concurrency settings for tests
Browse files Browse the repository at this point in the history
Enhanced CLI commands, added test max concurrency constant.
  • Loading branch information
pelikhan committed Feb 10, 2025
1 parent 13cb79c commit e697408
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/src/content/docs/reference/cli/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Usage: genaiscript test list [options]
List available tests in workspace
Options:
--redteam run red team tests
--redteam list red team tests
-g, --groups <groups...> groups to include or exclude. Use :! prefix to
exclude
-h, --help display help for command
Expand Down
6 changes: 4 additions & 2 deletions packages/cli/src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
EMOJI_FAIL,
TEST_RUNS_DIR_NAME,
PROMPTFOO_REMOTE_API_PORT,
PROMPTFOO_TEST_MAX_CONCURRENCY,
} from "../../core/src/constants"
import { promptFooDriver } from "../../core/src/default_prompts"
import { serializeError } from "../../core/src/error"
Expand Down Expand Up @@ -196,6 +197,7 @@ npx --yes genaiscript@${CORE_VERSION} test view
configurations.push({ script, configuration: fn })
}

const promptFooVersion = options.promptfooVersion || PROMPTFOO_VERSION
const results: PromptScriptTestResult[] = []
// Execute each configuration and gather results
for (const config of configurations) {
Expand All @@ -205,12 +207,12 @@ npx --yes genaiscript@${CORE_VERSION} test view
const cmd = "npx"
const args = [
"--yes",
`promptfoo@${options.promptfooVersion || PROMPTFOO_VERSION}`,
`promptfoo@${promptFooVersion}`,
"eval",
"--config",
configuration,
"--max-concurrency",
"1",
String(PROMPTFOO_TEST_MAX_CONCURRENCY),
"--no-progress-bar",
]
if (options.cache) args.push("--cache")
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export const PROMPTFOO_CACHE_PATH = ".genaiscript/cache/tests"
export const PROMPTFOO_CONFIG_DIR = ".genaiscript/config/tests"
export const PROMPTFOO_REMOTE_API_PORT = 15500
export const PROMPTFOO_REDTEAM_NUM_TESTS = 5
export const PROMPTFOO_TEST_MAX_CONCURRENCY = 1

export const RUNS_DIR_NAME = "runs"
export const CONVERTS_DIR_NAME = "converts"
Expand Down

0 comments on commit e697408

Please sign in to comment.