promptfoo 0.65.2 → 0.67.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -9
- package/dist/package.json +9 -7
- package/dist/src/accounts.d.ts +3 -0
- package/dist/src/accounts.d.ts.map +1 -0
- package/dist/src/accounts.js +14 -0
- package/dist/src/accounts.js.map +1 -0
- package/dist/src/assertions.d.ts.map +1 -1
- package/dist/src/assertions.js +18 -47
- package/dist/src/assertions.js.map +1 -1
- package/dist/src/cache.d.ts.map +1 -1
- package/dist/src/cache.js +3 -3
- package/dist/src/cache.js.map +1 -1
- package/dist/src/commands/config.d.ts +3 -0
- package/dist/src/commands/config.d.ts.map +1 -0
- package/dist/src/commands/config.js +50 -0
- package/dist/src/commands/config.js.map +1 -0
- package/dist/src/commands/delete.js +1 -1
- package/dist/src/commands/delete.js.map +1 -1
- package/dist/src/commands/export.d.ts.map +1 -1
- package/dist/src/commands/export.js +1 -1
- package/dist/src/commands/export.js.map +1 -1
- package/dist/src/commands/import.js +1 -1
- package/dist/src/commands/import.js.map +1 -1
- package/dist/src/commands/list.d.ts.map +1 -1
- package/dist/src/commands/list.js +2 -2
- package/dist/src/commands/list.js.map +1 -1
- package/dist/src/commands/show.d.ts.map +1 -1
- package/dist/src/commands/show.js +2 -2
- package/dist/src/commands/show.js.map +1 -1
- package/dist/src/csv.d.ts.map +1 -1
- package/dist/src/csv.js +0 -1
- package/dist/src/csv.js.map +1 -1
- package/dist/src/database.d.ts.map +1 -1
- package/dist/src/database.js +5 -5
- package/dist/src/database.js.map +1 -1
- package/dist/src/esm.d.ts.map +1 -1
- package/dist/src/esm.js +1 -1
- package/dist/src/esm.js.map +1 -1
- package/dist/src/evaluator.d.ts +18 -0
- package/dist/src/evaluator.d.ts.map +1 -1
- package/dist/src/evaluator.js +44 -26
- package/dist/src/evaluator.js.map +1 -1
- package/dist/src/feedback.d.ts.map +1 -1
- package/dist/src/feedback.js +2 -2
- package/dist/src/feedback.js.map +1 -1
- package/dist/src/fetch.d.ts.map +1 -1
- package/dist/src/fetch.js.map +1 -1
- package/dist/src/globalConfig.d.ts +17 -0
- package/dist/src/globalConfig.d.ts.map +1 -0
- package/dist/src/globalConfig.js +100 -0
- package/dist/src/globalConfig.js.map +1 -0
- package/dist/src/googleSheets.d.ts.map +1 -1
- package/dist/src/googleSheets.js +6 -6
- package/dist/src/googleSheets.js.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -4
- package/dist/src/index.js.map +1 -1
- package/dist/src/integrations/langfuse.js +1 -1
- package/dist/src/integrations/langfuse.js.map +1 -1
- package/dist/src/main.js +55 -28
- package/dist/src/main.js.map +1 -1
- package/dist/src/matchers.d.ts.map +1 -1
- package/dist/src/matchers.js +19 -18
- package/dist/src/matchers.js.map +1 -1
- package/dist/src/migrate.d.ts.map +1 -1
- package/dist/src/migrate.js +2 -2
- package/dist/src/migrate.js.map +1 -1
- package/dist/src/onboarding.d.ts.map +1 -1
- package/dist/src/onboarding.js +3 -3
- package/dist/src/onboarding.js.map +1 -1
- package/dist/src/prompts/constants.d.ts +3 -0
- package/dist/src/prompts/constants.d.ts.map +1 -0
- package/dist/src/prompts/constants.js +16 -0
- package/dist/src/prompts/constants.js.map +1 -0
- package/dist/src/prompts/external/ragas.d.ts.map +1 -0
- package/dist/src/prompts/external/ragas.js.map +1 -0
- package/dist/src/{prompts.d.ts → prompts/grading.d.ts} +7 -4
- package/dist/src/prompts/grading.d.ts.map +1 -0
- package/dist/src/prompts/grading.js +119 -0
- package/dist/src/prompts/grading.js.map +1 -0
- package/dist/src/prompts/index.d.ts +25 -0
- package/dist/src/prompts/index.d.ts.map +1 -0
- package/dist/src/prompts/index.js +143 -0
- package/dist/src/prompts/index.js.map +1 -0
- package/dist/src/prompts/processors/javascript.d.ts +9 -0
- package/dist/src/prompts/processors/javascript.d.ts.map +1 -0
- package/dist/src/prompts/processors/javascript.js +22 -0
- package/dist/src/prompts/processors/javascript.js.map +1 -0
- package/dist/src/prompts/processors/json.d.ts +12 -0
- package/dist/src/prompts/processors/json.d.ts.map +1 -0
- package/dist/src/prompts/processors/json.js +48 -0
- package/dist/src/prompts/processors/json.js.map +1 -0
- package/dist/src/prompts/processors/jsonl.d.ts +9 -0
- package/dist/src/prompts/processors/jsonl.d.ts.map +1 -0
- package/dist/src/prompts/processors/jsonl.js +48 -0
- package/dist/src/prompts/processors/jsonl.js.map +1 -0
- package/dist/src/prompts/processors/python.d.ts +31 -0
- package/dist/src/prompts/processors/python.d.ts.map +1 -0
- package/dist/src/prompts/processors/python.js +96 -0
- package/dist/src/prompts/processors/python.js.map +1 -0
- package/dist/src/prompts/processors/string.d.ts +8 -0
- package/dist/src/prompts/processors/string.d.ts.map +1 -0
- package/dist/src/prompts/processors/string.js +23 -0
- package/dist/src/prompts/processors/string.js.map +1 -0
- package/dist/src/prompts/processors/text.d.ts +9 -0
- package/dist/src/prompts/processors/text.d.ts.map +1 -0
- package/dist/src/prompts/processors/text.js +47 -0
- package/dist/src/prompts/processors/text.js.map +1 -0
- package/dist/src/prompts/processors/yaml.d.ts +13 -0
- package/dist/src/prompts/processors/yaml.d.ts.map +1 -0
- package/dist/src/prompts/processors/yaml.js +55 -0
- package/dist/src/prompts/processors/yaml.js.map +1 -0
- package/dist/src/prompts/utils.d.ts +29 -0
- package/dist/src/prompts/utils.d.ts.map +1 -0
- package/dist/src/prompts/utils.js +143 -0
- package/dist/src/prompts/utils.js.map +1 -0
- package/dist/src/providers/anthropic.d.ts +1 -0
- package/dist/src/providers/anthropic.d.ts.map +1 -1
- package/dist/src/providers/anthropic.js +11 -3
- package/dist/src/providers/anthropic.js.map +1 -1
- package/dist/src/providers/azureopenai.d.ts.map +1 -1
- package/dist/src/providers/azureopenai.js +1 -1
- package/dist/src/providers/azureopenai.js.map +1 -1
- package/dist/src/providers/azureopenaiUtil.d.ts.map +1 -1
- package/dist/src/providers/azureopenaiUtil.js +2 -2
- package/dist/src/providers/azureopenaiUtil.js.map +1 -1
- package/dist/src/providers/bam.d.ts.map +1 -1
- package/dist/src/providers/bam.js +1 -1
- package/dist/src/providers/bam.js.map +1 -1
- package/dist/src/providers/bedrock.d.ts +1 -0
- package/dist/src/providers/bedrock.d.ts.map +1 -1
- package/dist/src/providers/bedrock.js +21 -4
- package/dist/src/providers/bedrock.js.map +1 -1
- package/dist/src/providers/cloudflare-ai.d.ts +1 -1
- package/dist/src/providers/cloudflare-ai.d.ts.map +1 -1
- package/dist/src/providers/cloudflare-ai.js +1 -1
- package/dist/src/providers/cloudflare-ai.js.map +1 -1
- package/dist/src/providers/cohere.d.ts.map +1 -1
- package/dist/src/providers/cohere.js.map +1 -1
- package/dist/src/providers/defaults.d.ts +9 -3
- package/dist/src/providers/defaults.d.ts.map +1 -1
- package/dist/src/providers/defaults.js +22 -3
- package/dist/src/providers/defaults.js.map +1 -1
- package/dist/src/providers/http.d.ts.map +1 -1
- package/dist/src/providers/http.js +2 -2
- package/dist/src/providers/http.js.map +1 -1
- package/dist/src/providers/huggingface.d.ts +1 -1
- package/dist/src/providers/huggingface.d.ts.map +1 -1
- package/dist/src/providers/huggingface.js +1 -1
- package/dist/src/providers/huggingface.js.map +1 -1
- package/dist/src/providers/llama.d.ts.map +1 -1
- package/dist/src/providers/llama.js.map +1 -1
- package/dist/src/providers/localai.d.ts.map +1 -1
- package/dist/src/providers/localai.js +1 -1
- package/dist/src/providers/localai.js.map +1 -1
- package/dist/src/providers/mistral.d.ts.map +1 -1
- package/dist/src/providers/mistral.js +1 -1
- package/dist/src/providers/mistral.js.map +1 -1
- package/dist/src/providers/ollama.d.ts.map +1 -1
- package/dist/src/providers/ollama.js +2 -2
- package/dist/src/providers/ollama.js.map +1 -1
- package/dist/src/providers/openai.d.ts +1 -1
- package/dist/src/providers/openai.d.ts.map +1 -1
- package/dist/src/providers/openai.js +2 -2
- package/dist/src/providers/openai.js.map +1 -1
- package/dist/src/providers/palm.d.ts.map +1 -1
- package/dist/src/providers/palm.js +1 -1
- package/dist/src/providers/palm.js.map +1 -1
- package/dist/src/providers/portkey.d.ts +1 -1
- package/dist/src/providers/portkey.d.ts.map +1 -1
- package/dist/src/providers/portkey.js.map +1 -1
- package/dist/src/providers/promptfoo.d.ts.map +1 -1
- package/dist/src/providers/promptfoo.js.map +1 -1
- package/dist/src/providers/pythonCompletion.d.ts.map +1 -1
- package/dist/src/providers/pythonCompletion.js +3 -3
- package/dist/src/providers/pythonCompletion.js.map +1 -1
- package/dist/src/providers/replicate.d.ts.map +1 -1
- package/dist/src/providers/replicate.js +2 -2
- package/dist/src/providers/replicate.js.map +1 -1
- package/dist/src/providers/scriptCompletion.d.ts.map +1 -1
- package/dist/src/providers/scriptCompletion.js +1 -1
- package/dist/src/providers/scriptCompletion.js.map +1 -1
- package/dist/src/providers/vertex.d.ts +13 -1
- package/dist/src/providers/vertex.d.ts.map +1 -1
- package/dist/src/providers/vertex.js +80 -18
- package/dist/src/providers/vertex.js.map +1 -1
- package/dist/src/providers/vertexUtil.d.ts +1 -0
- package/dist/src/providers/vertexUtil.d.ts.map +1 -1
- package/dist/src/providers/vertexUtil.js +11 -1
- package/dist/src/providers/vertexUtil.js.map +1 -1
- package/dist/src/providers/voyage.d.ts.map +1 -1
- package/dist/src/providers/voyage.js.map +1 -1
- package/dist/src/providers/webhook.d.ts.map +1 -1
- package/dist/src/providers/webhook.js +1 -1
- package/dist/src/providers/webhook.js.map +1 -1
- package/dist/src/providers.d.ts +4 -3
- package/dist/src/providers.d.ts.map +1 -1
- package/dist/src/providers.js +31 -20
- package/dist/src/providers.js.map +1 -1
- package/dist/src/python/wrapper.d.ts.map +1 -1
- package/dist/src/python/wrapper.js +1 -1
- package/dist/src/python/wrapper.js.map +1 -1
- package/dist/src/python/wrapper.py +8 -3
- package/dist/src/redteam/constants.d.ts +1 -1
- package/dist/src/redteam/constants.d.ts.map +1 -1
- package/dist/src/redteam/constants.js +2 -2
- package/dist/src/redteam/constants.js.map +1 -1
- package/dist/src/redteam/getCompetitorTests.d.ts +2 -2
- package/dist/src/redteam/getCompetitorTests.d.ts.map +1 -1
- package/dist/src/redteam/getCompetitorTests.js +1 -8
- package/dist/src/redteam/getCompetitorTests.js.map +1 -1
- package/dist/src/redteam/getHallucinationTests.d.ts +2 -2
- package/dist/src/redteam/getHallucinationTests.d.ts.map +1 -1
- package/dist/src/redteam/getHallucinationTests.js +1 -8
- package/dist/src/redteam/getHallucinationTests.js.map +1 -1
- package/dist/src/redteam/getHarmfulTests.d.ts +9 -6
- package/dist/src/redteam/getHarmfulTests.d.ts.map +1 -1
- package/dist/src/redteam/getHarmfulTests.js +6 -3
- package/dist/src/redteam/getHarmfulTests.js.map +1 -1
- package/dist/src/redteam/getHijackingTests.d.ts +2 -2
- package/dist/src/redteam/getHijackingTests.d.ts.map +1 -1
- package/dist/src/redteam/getHijackingTests.js +1 -8
- package/dist/src/redteam/getHijackingTests.js.map +1 -1
- package/dist/src/redteam/getOverconfidenceTests.d.ts +2 -2
- package/dist/src/redteam/getOverconfidenceTests.d.ts.map +1 -1
- package/dist/src/redteam/getOverconfidenceTests.js +1 -8
- package/dist/src/redteam/getOverconfidenceTests.js.map +1 -1
- package/dist/src/redteam/getPiiTests.d.ts +4 -2
- package/dist/src/redteam/getPiiTests.d.ts.map +1 -1
- package/dist/src/redteam/getPiiTests.js +8 -11
- package/dist/src/redteam/getPiiTests.js.map +1 -1
- package/dist/src/redteam/getPoliticalStatementsTests.d.ts +2 -2
- package/dist/src/redteam/getPoliticalStatementsTests.d.ts.map +1 -1
- package/dist/src/redteam/getPoliticalStatementsTests.js +1 -8
- package/dist/src/redteam/getPoliticalStatementsTests.js.map +1 -1
- package/dist/src/redteam/getUnderconfidenceTests.d.ts +2 -2
- package/dist/src/redteam/getUnderconfidenceTests.d.ts.map +1 -1
- package/dist/src/redteam/getUnderconfidenceTests.js +1 -8
- package/dist/src/redteam/getUnderconfidenceTests.js.map +1 -1
- package/dist/src/redteam/getUnintendedContractTests.d.ts +2 -2
- package/dist/src/redteam/getUnintendedContractTests.d.ts.map +1 -1
- package/dist/src/redteam/getUnintendedContractTests.js +1 -8
- package/dist/src/redteam/getUnintendedContractTests.js.map +1 -1
- package/dist/src/redteam/index.d.ts +5 -3
- package/dist/src/redteam/index.d.ts.map +1 -1
- package/dist/src/redteam/index.js +34 -35
- package/dist/src/redteam/index.js.map +1 -1
- package/dist/src/redteam/iterative.d.ts +3 -0
- package/dist/src/redteam/iterative.d.ts.map +1 -1
- package/dist/src/redteam/iterative.js +12 -5
- package/dist/src/redteam/iterative.js.map +1 -1
- package/dist/src/share.d.ts.map +1 -1
- package/dist/src/share.js +1 -1
- package/dist/src/share.js.map +1 -1
- package/dist/src/suggestions.d.ts.map +1 -1
- package/dist/src/suggestions.js.map +1 -1
- package/dist/src/table.d.ts.map +1 -1
- package/dist/src/table.js +1 -1
- package/dist/src/table.js.map +1 -1
- package/dist/src/telemetry.d.ts.map +1 -1
- package/dist/src/telemetry.js +3 -3
- package/dist/src/telemetry.js.map +1 -1
- package/dist/src/testCases.d.ts.map +1 -1
- package/dist/src/testCases.js +9 -5
- package/dist/src/testCases.js.map +1 -1
- package/dist/src/types.d.ts +5 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/updates.d.ts.map +1 -1
- package/dist/src/updates.js +2 -2
- package/dist/src/updates.js.map +1 -1
- package/dist/src/util.d.ts +1 -3
- package/dist/src/util.d.ts.map +1 -1
- package/dist/src/util.js +44 -53
- package/dist/src/util.js.map +1 -1
- package/dist/src/web/nextui/404/index.html +1 -1
- package/dist/src/web/nextui/404.html +1 -1
- package/dist/src/web/nextui/_next/static/chunks/2-f562fcee36045aca.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/94-c07f30271fa4d8e4.js +32 -0
- package/dist/src/web/nextui/_next/static/chunks/app/auth/login/{page-c4a2650ac3a0ecd9.js → page-d932a73274f0f175.js} +1 -1
- package/dist/src/web/nextui/_next/static/chunks/app/auth/signup/{page-dd18caf3100d8d0e.js → page-7a8f35189f8bc5b8.js} +1 -1
- package/dist/src/web/nextui/_next/static/chunks/app/datasets/page-9712a72be5b92b81.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/app/eval/[id]/{page-40b89e739dc45119.js → page-35bb69e87d17a291.js} +1 -1
- package/dist/src/web/nextui/_next/static/chunks/app/eval/{page-16d9d50aa8dc0520.js → page-aef3aed32af8d4d7.js} +1 -1
- package/dist/src/web/nextui/_next/static/chunks/app/layout-c6a855ac7037db70.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/app/progress/{page-00b5c3308a81af12.js → page-751105ef02d00993.js} +1 -1
- package/dist/src/web/nextui/_next/static/chunks/app/prompts/page-689202b79a6b6a92.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/app/report/page-4b1c00ce9ee1f5ab.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/app/setup/page-544af5b41c35d73a.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/{webpack-c469fe135043664b.js → webpack-d1a82d85a184970b.js} +1 -1
- package/dist/src/web/nextui/_next/static/css/451beaa5570cb9d3.css +1 -0
- package/dist/src/web/nextui/_next/static/css/{51a17e8edcdfdbb2.css → b76f1739b5a14901.css} +1 -1
- package/dist/src/web/nextui/_next/static/css/dab5d695b3657d59.css +1 -0
- package/dist/src/web/nextui/_next/static/css/e9f25719d0b14939.css +1 -0
- package/dist/src/web/nextui/_next/static/css/edcd6f0b6c902fde.css +1 -0
- package/dist/src/web/nextui/auth/login/index.html +1 -1
- package/dist/src/web/nextui/auth/login/index.txt +6 -6
- package/dist/src/web/nextui/auth/signup/index.html +1 -1
- package/dist/src/web/nextui/auth/signup/index.txt +6 -6
- package/dist/src/web/nextui/datasets/index.html +1 -1
- package/dist/src/web/nextui/datasets/index.txt +6 -6
- package/dist/src/web/nextui/eval/index.html +1 -1
- package/dist/src/web/nextui/eval/index.txt +8 -8
- package/dist/src/web/nextui/index.html +1 -1
- package/dist/src/web/nextui/index.txt +5 -5
- package/dist/src/web/nextui/progress/index.html +1 -1
- package/dist/src/web/nextui/progress/index.txt +6 -6
- package/dist/src/web/nextui/prompts/index.html +1 -1
- package/dist/src/web/nextui/prompts/index.txt +6 -6
- package/dist/src/web/nextui/report/index.html +1 -1
- package/dist/src/web/nextui/report/index.txt +8 -8
- package/dist/src/web/nextui/setup/index.html +2 -2
- package/dist/src/web/nextui/setup/index.txt +9 -9
- package/dist/src/web/server.d.ts.map +1 -1
- package/dist/src/web/server.js +10 -10
- package/dist/src/web/server.js.map +1 -1
- package/package.json +9 -7
- package/dist/src/external/ragas.d.ts.map +0 -1
- package/dist/src/external/ragas.js.map +0 -1
- package/dist/src/prompts.d.ts.map +0 -1
- package/dist/src/prompts.js +0 -391
- package/dist/src/prompts.js.map +0 -1
- package/dist/src/web/nextui/_next/static/chunks/2-83f58953fd015451.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/371-0554dc4f28404020.js +0 -32
- package/dist/src/web/nextui/_next/static/chunks/app/datasets/page-9426b519d4be1fdb.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/app/layout-dfda5ed5ef745c2d.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/app/prompts/page-ee610cffca4b965b.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/app/report/page-7699a16d46de673c.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/app/setup/page-e1c49ea6fe7c04c5.js +0 -1
- package/dist/src/web/nextui/_next/static/css/15e7b41f5e8a79bf.css +0 -1
- package/dist/src/web/nextui/_next/static/css/16c1dd82fc87c9d7.css +0 -1
- package/dist/src/web/nextui/_next/static/css/51f7d6933894a4f8.css +0 -1
- package/dist/src/web/nextui/_next/static/css/85bfc598653c1699.css +0 -1
- /package/dist/src/{external → prompts/external}/ragas.d.ts +0 -0
- /package/dist/src/{external → prompts/external}/ragas.js +0 -0
- /package/dist/src/web/nextui/_next/static/{S3D5Fr7gOoSz0gy8y6ZaU → m-VSM7eKSuIZDyA_tnwFX}/_buildManifest.js +0 -0
- /package/dist/src/web/nextui/_next/static/{S3D5Fr7gOoSz0gy8y6ZaU → m-VSM7eKSuIZDyA_tnwFX}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.readPrompts = exports.processPrompt = exports.readProviderPromptMap = void 0;
|
|
21
|
+
const glob_1 = require("glob");
|
|
22
|
+
const tiny_invariant_1 = __importDefault(require("tiny-invariant"));
|
|
23
|
+
const logger_1 = __importDefault(require("../logger"));
|
|
24
|
+
const javascript_1 = require("./processors/javascript");
|
|
25
|
+
const json_1 = require("./processors/json");
|
|
26
|
+
const jsonl_1 = require("./processors/jsonl");
|
|
27
|
+
const python_1 = require("./processors/python");
|
|
28
|
+
const string_1 = require("./processors/string");
|
|
29
|
+
const text_1 = require("./processors/text");
|
|
30
|
+
const yaml_1 = require("./processors/yaml");
|
|
31
|
+
const utils_1 = require("./utils");
|
|
32
|
+
__exportStar(require("./grading"), exports);
|
|
33
|
+
/**
|
|
34
|
+
* Reads and maps provider prompts based on the configuration and parsed prompts.
|
|
35
|
+
* @param config - The configuration object.
|
|
36
|
+
* @param parsedPrompts - Array of parsed prompts.
|
|
37
|
+
* @returns A map of provider IDs to their respective prompts.
|
|
38
|
+
*/
|
|
39
|
+
function readProviderPromptMap(config, parsedPrompts) {
|
|
40
|
+
const ret = {};
|
|
41
|
+
if (!config.providers) {
|
|
42
|
+
return ret;
|
|
43
|
+
}
|
|
44
|
+
const allPrompts = [];
|
|
45
|
+
for (const prompt of parsedPrompts) {
|
|
46
|
+
allPrompts.push(prompt.label);
|
|
47
|
+
}
|
|
48
|
+
if (typeof config.providers === 'string') {
|
|
49
|
+
return { [config.providers]: allPrompts };
|
|
50
|
+
}
|
|
51
|
+
if (typeof config.providers === 'function') {
|
|
52
|
+
return { 'Custom function': allPrompts };
|
|
53
|
+
}
|
|
54
|
+
for (const provider of config.providers) {
|
|
55
|
+
if (typeof provider === 'object') {
|
|
56
|
+
// It's either a ProviderOptionsMap or a ProviderOptions
|
|
57
|
+
if (provider.id) {
|
|
58
|
+
const rawProvider = provider;
|
|
59
|
+
(0, tiny_invariant_1.default)(rawProvider.id, 'You must specify an `id` on the Provider when you override options.prompts');
|
|
60
|
+
ret[rawProvider.id] = rawProvider.prompts || allPrompts;
|
|
61
|
+
if (rawProvider.label) {
|
|
62
|
+
ret[rawProvider.label] = rawProvider.prompts || allPrompts;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
const rawProvider = provider;
|
|
67
|
+
const originalId = Object.keys(rawProvider)[0];
|
|
68
|
+
const providerObject = rawProvider[originalId];
|
|
69
|
+
const id = providerObject.id || originalId;
|
|
70
|
+
ret[id] = rawProvider[originalId].prompts || allPrompts;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return ret;
|
|
75
|
+
}
|
|
76
|
+
exports.readProviderPromptMap = readProviderPromptMap;
|
|
77
|
+
/**
|
|
78
|
+
* Processes a raw prompt based on its content type and path.
|
|
79
|
+
* @param prompt - The raw prompt data.
|
|
80
|
+
* @param basePath - Base path for file resolution.
|
|
81
|
+
* @param maxRecursionDepth - Maximum recursion depth for globbing.
|
|
82
|
+
* @returns Promise resolving to an array of processed prompts.
|
|
83
|
+
*/
|
|
84
|
+
async function processPrompt(prompt, basePath = '', maxRecursionDepth = 1) {
|
|
85
|
+
(0, tiny_invariant_1.default)(typeof prompt.raw === 'string', `prompt.raw must be a string, but got ${JSON.stringify(prompt.raw)}`);
|
|
86
|
+
if (!(0, utils_1.maybeFilePath)(prompt.raw)) {
|
|
87
|
+
return (0, string_1.processString)(prompt);
|
|
88
|
+
}
|
|
89
|
+
const { extension, functionName, isPathPattern, promptPath, } = (0, utils_1.parsePathOrGlob)(basePath, prompt.raw);
|
|
90
|
+
if (isPathPattern && maxRecursionDepth > 0) {
|
|
91
|
+
const globbedPath = (0, glob_1.globSync)(promptPath.replace(/\\/g, '/'), {
|
|
92
|
+
windowsPathsNoEscape: true,
|
|
93
|
+
});
|
|
94
|
+
logger_1.default.debug(`Expanded prompt ${prompt.raw} to ${promptPath} and then to ${JSON.stringify(globbedPath)}`);
|
|
95
|
+
const prompts = [];
|
|
96
|
+
for (const globbedFilePath of globbedPath) {
|
|
97
|
+
const processedPrompts = await processPrompt({ raw: globbedFilePath }, basePath, maxRecursionDepth - 1);
|
|
98
|
+
prompts.push(...processedPrompts);
|
|
99
|
+
}
|
|
100
|
+
return prompts;
|
|
101
|
+
}
|
|
102
|
+
if (extension === '.json') {
|
|
103
|
+
return (0, json_1.processJsonFile)(promptPath, prompt);
|
|
104
|
+
}
|
|
105
|
+
if (extension === '.jsonl') {
|
|
106
|
+
return (0, jsonl_1.processJsonlFile)(promptPath, prompt);
|
|
107
|
+
}
|
|
108
|
+
if (['.js', '.cjs', '.mjs'].includes(extension)) {
|
|
109
|
+
return (0, javascript_1.processJsFile)(promptPath, prompt, functionName);
|
|
110
|
+
}
|
|
111
|
+
if (extension === '.py') {
|
|
112
|
+
return (0, python_1.processPythonFile)(promptPath, prompt, functionName);
|
|
113
|
+
}
|
|
114
|
+
if (extension === '.txt') {
|
|
115
|
+
return (0, text_1.processTxtFile)(promptPath, prompt);
|
|
116
|
+
}
|
|
117
|
+
if (['.yml', '.yaml'].includes(extension)) {
|
|
118
|
+
return (0, yaml_1.processYamlFile)(promptPath, prompt);
|
|
119
|
+
}
|
|
120
|
+
return [];
|
|
121
|
+
}
|
|
122
|
+
exports.processPrompt = processPrompt;
|
|
123
|
+
/**
|
|
124
|
+
* Reads and processes prompts from a specified path or glob pattern.
|
|
125
|
+
* @param promptPathOrGlobs - The path or glob pattern.
|
|
126
|
+
* @param basePath - Base path for file resolution.
|
|
127
|
+
* @returns Promise resolving to an array of processed prompts.
|
|
128
|
+
*/
|
|
129
|
+
async function readPrompts(promptPathOrGlobs, basePath = '') {
|
|
130
|
+
logger_1.default.debug(`Reading prompts from ${JSON.stringify(promptPathOrGlobs)}`);
|
|
131
|
+
const promptPartials = (0, utils_1.normalizeInput)(promptPathOrGlobs);
|
|
132
|
+
const prompts = [];
|
|
133
|
+
for (const prompt of promptPartials) {
|
|
134
|
+
const promptBatch = await processPrompt(prompt, basePath);
|
|
135
|
+
if (promptBatch.length === 0) {
|
|
136
|
+
throw new Error(`There are no prompts in ${JSON.stringify(prompt.raw)}`);
|
|
137
|
+
}
|
|
138
|
+
prompts.push(...promptBatch);
|
|
139
|
+
}
|
|
140
|
+
return prompts;
|
|
141
|
+
}
|
|
142
|
+
exports.readPrompts = readPrompts;
|
|
143
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/prompts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,+BAAgC;AAChC,oEA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O,EAAE,CAAC;AACZ,CAAC;AAhED,sCAgEC;AAED;;;;;GAKG;AACI,KAAK,UAAU,WAAW,CAC/B,iBAAiF,EACjF,WAAmB,EAAE;IAErB,gBAAM,CAAC,KAAK,CAAC,wBAAwB,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;IAE1E,MAAM,cAAc,GAAsB,IAAA,sBAAc,EAAC,iBAAiB,CAAC,CAAC;IAC5E,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,MAAM,IAAI,cAAc,EAAE,CAAC;QACpC,MAAM,WAAW,GAAG,MAAM,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC1D,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,2BAA2B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC3E,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAhBD,kCAgBC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Prompt } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Processes a JavaScript file to import and execute a module function as a prompt.
|
|
4
|
+
* @param filePath - Path to the JavaScript file.
|
|
5
|
+
* @param functionName - Optional function name to execute.
|
|
6
|
+
* @returns Promise resolving to an array of prompts.
|
|
7
|
+
*/
|
|
8
|
+
export declare function processJsFile(filePath: string, prompt: Partial<Prompt>, functionName: string | undefined): Promise<Prompt[]>;
|
|
9
|
+
//# sourceMappingURL=javascript.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"javascript.d.ts","sourceRoot":"","sources":["../../../../src/prompts/processors/javascript.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,EACvB,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,OAAO,CAAC,MAAM,EAAE,CAAC,CASnB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processJsFile = void 0;
|
|
4
|
+
const esm_1 = require("../../esm");
|
|
5
|
+
/**
|
|
6
|
+
* Processes a JavaScript file to import and execute a module function as a prompt.
|
|
7
|
+
* @param filePath - Path to the JavaScript file.
|
|
8
|
+
* @param functionName - Optional function name to execute.
|
|
9
|
+
* @returns Promise resolving to an array of prompts.
|
|
10
|
+
*/
|
|
11
|
+
async function processJsFile(filePath, prompt, functionName) {
|
|
12
|
+
const promptFunction = await (0, esm_1.importModule)(filePath, functionName);
|
|
13
|
+
return [
|
|
14
|
+
{
|
|
15
|
+
raw: String(promptFunction),
|
|
16
|
+
label: prompt.label ? prompt.label : functionName ? `${filePath}:${functionName}` : filePath,
|
|
17
|
+
function: promptFunction,
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
}
|
|
21
|
+
exports.processJsFile = processJsFile;
|
|
22
|
+
//# sourceMappingURL=javascript.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"javascript.js","sourceRoot":"","sources":["../../../../src/prompts/processors/javascript.ts"],"names":[],"mappings":";;;AAAA,mCAAyC;AAGzC;;;;;GAKG;AACI,KAAK,UAAU,aAAa,CACjC,QAAgB,EAChB,MAAuB,EACvB,YAAgC;IAEhC,MAAM,cAAc,GAAG,MAAM,IAAA,kBAAY,EAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IAClE,OAAO;QACL;YACE,GAAG,EAAE,MAAM,CAAC,cAAc,CAAC;YAC3B,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,QAAQ,IAAI,YAAY,EAAE,CAAC,CAAC,CAAC,QAAQ;YAC5F,QAAQ,EAAE,cAAc;SACzB;KACF,CAAC;AACJ,CAAC;AAbD,sCAaC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Prompt } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Processes a JSON file to extract prompts.
|
|
4
|
+
* This function reads a JSON file and converts it to a `Prompt` object.
|
|
5
|
+
*
|
|
6
|
+
* @param filePath - The path to the JSON file.
|
|
7
|
+
* @param prompt - The raw prompt data, used for labeling.
|
|
8
|
+
* @returns An array of one `Prompt` object.
|
|
9
|
+
* @throws Will throw an error if the file cannot be read.
|
|
10
|
+
*/
|
|
11
|
+
export declare function processJsonFile(filePath: string, prompt: Partial<Prompt>): Prompt[];
|
|
12
|
+
//# sourceMappingURL=json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../../src/prompts/processors/json.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CASnF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.processJsonFile = void 0;
|
|
27
|
+
const fs = __importStar(require("fs"));
|
|
28
|
+
/**
|
|
29
|
+
* Processes a JSON file to extract prompts.
|
|
30
|
+
* This function reads a JSON file and converts it to a `Prompt` object.
|
|
31
|
+
*
|
|
32
|
+
* @param filePath - The path to the JSON file.
|
|
33
|
+
* @param prompt - The raw prompt data, used for labeling.
|
|
34
|
+
* @returns An array of one `Prompt` object.
|
|
35
|
+
* @throws Will throw an error if the file cannot be read.
|
|
36
|
+
*/
|
|
37
|
+
function processJsonFile(filePath, prompt) {
|
|
38
|
+
const fileContents = fs.readFileSync(filePath, 'utf8');
|
|
39
|
+
// NOTE: We do not validate if this is a valid JSON file.
|
|
40
|
+
return [
|
|
41
|
+
{
|
|
42
|
+
raw: fileContents,
|
|
43
|
+
label: prompt.label || `${filePath}: ${fileContents}`,
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
exports.processJsonFile = processJsonFile;
|
|
48
|
+
//# sourceMappingURL=json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../../../src/prompts/processors/json.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAGzB;;;;;;;;GAQG;AACH,SAAgB,eAAe,CAAC,QAAgB,EAAE,MAAuB;IACvE,MAAM,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACvD,yDAAyD;IACzD,OAAO;QACL;YACE,GAAG,EAAE,YAAY;YACjB,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,GAAG,QAAQ,KAAK,YAAY,EAAE;SACtD;KACF,CAAC;AACJ,CAAC;AATD,0CASC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Prompt } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Processes a JSONL file to extract prompts.
|
|
4
|
+
* @param filePath - Path to the JSONL file.
|
|
5
|
+
* @param prompt - The raw prompt data.
|
|
6
|
+
* @returns Array of prompts extracted from the file.
|
|
7
|
+
*/
|
|
8
|
+
export declare function processJsonlFile(filePath: string, prompt: Partial<Prompt>): Prompt[];
|
|
9
|
+
//# sourceMappingURL=jsonl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonl.d.ts","sourceRoot":"","sources":["../../../../src/prompts/processors/jsonl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAYpF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.processJsonlFile = void 0;
|
|
27
|
+
const fs = __importStar(require("fs"));
|
|
28
|
+
/**
|
|
29
|
+
* Processes a JSONL file to extract prompts.
|
|
30
|
+
* @param filePath - Path to the JSONL file.
|
|
31
|
+
* @param prompt - The raw prompt data.
|
|
32
|
+
* @returns Array of prompts extracted from the file.
|
|
33
|
+
*/
|
|
34
|
+
function processJsonlFile(filePath, prompt) {
|
|
35
|
+
const fileContent = fs.readFileSync(filePath, 'utf-8');
|
|
36
|
+
const jsonLines = fileContent.split(/\r?\n/).filter((line) => line.length > 0);
|
|
37
|
+
const containsMultiple = jsonLines.length > 1;
|
|
38
|
+
return jsonLines.map((json) => ({
|
|
39
|
+
raw: json,
|
|
40
|
+
label: containsMultiple
|
|
41
|
+
? prompt.label
|
|
42
|
+
? `${prompt.label}: ${json}`
|
|
43
|
+
: `${filePath}: ${json}`
|
|
44
|
+
: prompt.label || `${filePath}`,
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
exports.processJsonlFile = processJsonlFile;
|
|
48
|
+
//# sourceMappingURL=jsonl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonl.js","sourceRoot":"","sources":["../../../../src/prompts/processors/jsonl.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAGzB;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,QAAgB,EAAE,MAAuB;IACxE,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACvD,MAAM,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC/E,MAAM,gBAAgB,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IAC9C,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC9B,GAAG,EAAE,IAAI;QACT,KAAK,EAAE,gBAAgB;YACrB,CAAC,CAAC,MAAM,CAAC,KAAK;gBACZ,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,KAAK,IAAI,EAAE;gBAC5B,CAAC,CAAC,GAAG,QAAQ,KAAK,IAAI,EAAE;YAC1B,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI,GAAG,QAAQ,EAAE;KAClC,CAAC,CAAC,CAAC;AACN,CAAC;AAZD,4CAYC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Prompt, ApiProvider } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Python prompt function. Runs a specific function from the python file.
|
|
4
|
+
* @param promptPath - Path to the Python file.
|
|
5
|
+
* @param functionName - Function name to execute.
|
|
6
|
+
* @param context - Context for the prompt.
|
|
7
|
+
* @returns The prompts
|
|
8
|
+
*/
|
|
9
|
+
export declare const pythonPromptFunction: (filePath: string, functionName: string, context: {
|
|
10
|
+
vars: Record<string, string | object>;
|
|
11
|
+
provider?: ApiProvider;
|
|
12
|
+
}) => Promise<any>;
|
|
13
|
+
/**
|
|
14
|
+
* Legacy Python prompt function. Runs the whole python file.
|
|
15
|
+
* @param filePath - Path to the Python file.
|
|
16
|
+
* @param context - Context for the prompt.
|
|
17
|
+
* @returns The prompts
|
|
18
|
+
*/
|
|
19
|
+
export declare const pythonPromptFunctionLegacy: (filePath: string, context: {
|
|
20
|
+
vars: Record<string, string | object>;
|
|
21
|
+
provider?: ApiProvider;
|
|
22
|
+
}) => Promise<string>;
|
|
23
|
+
/**
|
|
24
|
+
* Processes a Python file to extract or execute a function as a prompt.
|
|
25
|
+
* @param filePath - Path to the Python file.
|
|
26
|
+
* @param prompt - The raw prompt data.
|
|
27
|
+
* @param functionName - Optional function name to execute.
|
|
28
|
+
* @returns Array of prompts extracted or executed from the file.
|
|
29
|
+
*/
|
|
30
|
+
export declare function processPythonFile(filePath: string, prompt: Partial<Prompt>, functionName: string | undefined): Prompt[];
|
|
31
|
+
//# sourceMappingURL=python.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"python.d.ts","sourceRoot":"","sources":["../../../../src/prompts/processors/python.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAGvD;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,aACrB,MAAM,gBACF,MAAM,WACX;IACP,IAAI,EAAE,OAAO,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IACtC,QAAQ,CAAC,EAAE,WAAW,CAAC;CACxB,iBAWF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,aAC3B,MAAM,WACP;IACP,IAAI,EAAE,OAAO,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IACtC,QAAQ,CAAC,EAAE,WAAW,CAAC;CACxB,oBAWF,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,EACvB,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,MAAM,EAAE,CAeV"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.processPythonFile = exports.pythonPromptFunctionLegacy = exports.pythonPromptFunction = void 0;
|
|
30
|
+
const fs = __importStar(require("fs"));
|
|
31
|
+
const python_shell_1 = require("python-shell");
|
|
32
|
+
const logger_1 = __importDefault(require("../../logger"));
|
|
33
|
+
const wrapper_1 = require("../../python/wrapper");
|
|
34
|
+
const util_1 = require("../../util");
|
|
35
|
+
/**
|
|
36
|
+
* Python prompt function. Runs a specific function from the python file.
|
|
37
|
+
* @param promptPath - Path to the Python file.
|
|
38
|
+
* @param functionName - Function name to execute.
|
|
39
|
+
* @param context - Context for the prompt.
|
|
40
|
+
* @returns The prompts
|
|
41
|
+
*/
|
|
42
|
+
const pythonPromptFunction = async (filePath, functionName, context) => {
|
|
43
|
+
return (0, wrapper_1.runPython)(filePath, functionName, [
|
|
44
|
+
{
|
|
45
|
+
...context,
|
|
46
|
+
provider: {
|
|
47
|
+
id: context.provider?.id,
|
|
48
|
+
label: context.provider?.label,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
]);
|
|
52
|
+
};
|
|
53
|
+
exports.pythonPromptFunction = pythonPromptFunction;
|
|
54
|
+
/**
|
|
55
|
+
* Legacy Python prompt function. Runs the whole python file.
|
|
56
|
+
* @param filePath - Path to the Python file.
|
|
57
|
+
* @param context - Context for the prompt.
|
|
58
|
+
* @returns The prompts
|
|
59
|
+
*/
|
|
60
|
+
const pythonPromptFunctionLegacy = async (filePath, context) => {
|
|
61
|
+
const options = {
|
|
62
|
+
mode: 'text',
|
|
63
|
+
pythonPath: process.env.PROMPTFOO_PYTHON || 'python',
|
|
64
|
+
args: [(0, util_1.safeJsonStringify)(context)],
|
|
65
|
+
};
|
|
66
|
+
logger_1.default.debug(`Executing python prompt script ${filePath}`);
|
|
67
|
+
const results = (await python_shell_1.PythonShell.run(filePath, options)).join('\n');
|
|
68
|
+
logger_1.default.debug(`Python prompt script ${filePath} returned: ${results}`);
|
|
69
|
+
return results;
|
|
70
|
+
};
|
|
71
|
+
exports.pythonPromptFunctionLegacy = pythonPromptFunctionLegacy;
|
|
72
|
+
/**
|
|
73
|
+
* Processes a Python file to extract or execute a function as a prompt.
|
|
74
|
+
* @param filePath - Path to the Python file.
|
|
75
|
+
* @param prompt - The raw prompt data.
|
|
76
|
+
* @param functionName - Optional function name to execute.
|
|
77
|
+
* @returns Array of prompts extracted or executed from the file.
|
|
78
|
+
*/
|
|
79
|
+
function processPythonFile(filePath, prompt, functionName) {
|
|
80
|
+
const fileContent = fs.readFileSync(filePath, 'utf-8');
|
|
81
|
+
return [
|
|
82
|
+
{
|
|
83
|
+
raw: fileContent,
|
|
84
|
+
label: prompt.label
|
|
85
|
+
? prompt.label
|
|
86
|
+
: functionName
|
|
87
|
+
? `${filePath}:${functionName}`
|
|
88
|
+
: `${filePath}: ${fileContent}`,
|
|
89
|
+
function: functionName
|
|
90
|
+
? (...args) => (0, exports.pythonPromptFunction)(filePath, functionName, ...args)
|
|
91
|
+
: (...args) => (0, exports.pythonPromptFunctionLegacy)(filePath, ...args),
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
exports.processPythonFile = processPythonFile;
|
|
96
|
+
//# sourceMappingURL=python.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"python.js","sourceRoot":"","sources":["../../../../src/prompts/processors/python.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,+CAA0E;AAC1E,0DAAkC;AAClC,kDAAiD;AAEjD,qCAA+C;AAE/C;;;;;;GAMG;AACI,MAAM,oBAAoB,GAAG,KAAK,EACvC,QAAgB,EAChB,YAAoB,EACpB,OAGC,EACD,EAAE;IACF,OAAO,IAAA,mBAAS,EAAC,QAAQ,EAAE,YAAY,EAAE;QACvC;YACE,GAAG,OAAO;YACV,QAAQ,EAAE;gBACR,EAAE,EAAE,OAAO,CAAC,QAA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,CAAC,IAAA,4BAAoB,EAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;gBACpE,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,IAAA,kCAA0B,EAAC,QAAQ,EAAE,GAAG,IAAI,CAAC;SAC/D;KACF,CAAC;AACJ,CAAC;AAnBD,8CAmBC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Prompt } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Processes a string as a literal prompt.
|
|
4
|
+
* @param prompt - The raw prompt data.
|
|
5
|
+
* @returns Array of prompts created from the string.
|
|
6
|
+
*/
|
|
7
|
+
export declare function processString(prompt: Partial<Prompt>): Prompt[];
|
|
8
|
+
//# sourceMappingURL=string.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../../src/prompts/processors/string.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAW/D"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.processString = void 0;
|
|
7
|
+
const tiny_invariant_1 = __importDefault(require("tiny-invariant"));
|
|
8
|
+
/**
|
|
9
|
+
* Processes a string as a literal prompt.
|
|
10
|
+
* @param prompt - The raw prompt data.
|
|
11
|
+
* @returns Array of prompts created from the string.
|
|
12
|
+
*/
|
|
13
|
+
function processString(prompt) {
|
|
14
|
+
(0, tiny_invariant_1.default)(typeof prompt.raw === 'string', `prompt.raw must be a string, but got ${JSON.stringify(prompt.raw)}`);
|
|
15
|
+
return [
|
|
16
|
+
{
|
|
17
|
+
raw: prompt.raw,
|
|
18
|
+
label: prompt.label ?? `${prompt.raw}`,
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
exports.processString = processString;
|
|
23
|
+
//# sourceMappingURL=string.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../../../src/prompts/processors/string.ts"],"names":[],"mappings":";;;;;;AAAA,oEAAuC;AAGvC;;;;GAIG;AACH,SAAgB,aAAa,CAAC,MAAuB;IACnD,IAAA,wBAAS,EACP,OAAO,MAAM,CAAC,GAAG,KAAK,QAAQ,EAC9B,wCAAwC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CACrE,CAAC;IACF,OAAO;QACL;YACE,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,GAAG,MAAM,CAAC,GAAG,EAAE;SACvC;KACF,CAAC;AACJ,CAAC;AAXD,sCAWC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Prompt } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Processes a text file to extract prompts, splitting by a delimiter.
|
|
4
|
+
* @param filePath - Path to the text file.
|
|
5
|
+
* @param prompt - The raw prompt data.
|
|
6
|
+
* @returns Array of prompts extracted from the file.
|
|
7
|
+
*/
|
|
8
|
+
export declare function processTxtFile(filePath: string, { label }: Partial<Prompt>): Prompt[];
|
|
9
|
+
//# sourceMappingURL=text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../../src/prompts/processors/text.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAUrF"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.processTxtFile = void 0;
|
|
27
|
+
const fs = __importStar(require("fs"));
|
|
28
|
+
const constants_1 = require("../constants");
|
|
29
|
+
/**
|
|
30
|
+
* Processes a text file to extract prompts, splitting by a delimiter.
|
|
31
|
+
* @param filePath - Path to the text file.
|
|
32
|
+
* @param prompt - The raw prompt data.
|
|
33
|
+
* @returns Array of prompts extracted from the file.
|
|
34
|
+
*/
|
|
35
|
+
function processTxtFile(filePath, { label }) {
|
|
36
|
+
const fileContent = fs.readFileSync(filePath, 'utf-8');
|
|
37
|
+
return fileContent // handle leading/trailing delimiters and empty lines
|
|
38
|
+
.split(constants_1.PROMPT_DELIMITER)
|
|
39
|
+
.map((p) => p.trim())
|
|
40
|
+
.filter((p) => p.length > 0)
|
|
41
|
+
.map((prompt) => ({
|
|
42
|
+
raw: prompt,
|
|
43
|
+
label: label ? `${label}: ${filePath}: ${prompt}` : `${filePath}: ${prompt}`,
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
exports.processTxtFile = processTxtFile;
|
|
47
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../../src/prompts/processors/text.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAEzB,4CAAgD;AAEhD;;;;;GAKG;AACH,SAAgB,cAAc,CAAC,QAAgB,EAAE,EAAE,KAAK,EAAmB;IACzE,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACvD,OAAO,WAAW,CAAC,qDAAqD;SACrE,KAAK,CAAC,4BAAgB,CAAC;SACvB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;SAC3B,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAChB,GAAG,EAAE,MAAM;QACX,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,QAAQ,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,GAAG,QAAQ,KAAK,MAAM,EAAE;KAC7E,CAAC,CAAC,CAAC;AACR,CAAC;AAVD,wCAUC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Prompt } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Processes a YAML file to extract prompts.
|
|
4
|
+
* This function reads a YAML file, parses it, and maps each entry to a `Prompt` object.
|
|
5
|
+
* Each prompt is labeled with the file path and the YAML content.
|
|
6
|
+
*
|
|
7
|
+
* @param filePath - The path to the YAML file.
|
|
8
|
+
* @param prompt - The raw prompt data, used for labeling.
|
|
9
|
+
* @returns An array of `Prompt` objects extracted from the YAML file.
|
|
10
|
+
* @throws Will throw an error if the file cannot be read or parsed.
|
|
11
|
+
*/
|
|
12
|
+
export declare function processYamlFile(filePath: string, prompt: Partial<Prompt>): Prompt[];
|
|
13
|
+
//# sourceMappingURL=yaml.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../../../../src/prompts/processors/yaml.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAWnF"}
|