prompt-lock 0.2.0 → 0.4.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/CHANGELOG.md +36 -0
- package/README.md +161 -4
- package/dist/assertions/builtin.d.ts.map +1 -1
- package/dist/assertions/builtin.js +11 -0
- package/dist/assertions/builtin.js.map +1 -1
- package/dist/assertions/index.d.ts.map +1 -1
- package/dist/assertions/index.js +5 -0
- package/dist/assertions/index.js.map +1 -1
- package/dist/assertions/llm-judge.d.ts +6 -0
- package/dist/assertions/llm-judge.d.ts.map +1 -0
- package/dist/assertions/llm-judge.js +75 -0
- package/dist/assertions/llm-judge.js.map +1 -0
- package/dist/cli.js +114 -11
- package/dist/cli.js.map +1 -1
- package/dist/config-loader.d.ts +4 -0
- package/dist/config-loader.d.ts.map +1 -0
- package/dist/config-loader.js +85 -0
- package/dist/config-loader.js.map +1 -0
- package/dist/config-validation.d.ts.map +1 -1
- package/dist/config-validation.js +33 -3
- package/dist/config-validation.js.map +1 -1
- package/dist/dataset-loader.d.ts +2 -0
- package/dist/dataset-loader.d.ts.map +1 -0
- package/dist/dataset-loader.js +130 -0
- package/dist/dataset-loader.js.map +1 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -1
- package/dist/index.js.map +1 -1
- package/dist/pricing.d.ts +9 -0
- package/dist/pricing.d.ts.map +1 -0
- package/dist/pricing.js +49 -0
- package/dist/pricing.js.map +1 -0
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +49 -36
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +7 -1
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/openai.d.ts.map +1 -1
- package/dist/providers/openai.js +48 -35
- package/dist/providers/openai.js.map +1 -1
- package/dist/reporter.d.ts +4 -1
- package/dist/reporter.d.ts.map +1 -1
- package/dist/reporter.js +141 -0
- package/dist/reporter.js.map +1 -1
- package/dist/runner.d.ts +2 -1
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +136 -20
- package/dist/runner.js.map +1 -1
- package/dist/types.d.ts +41 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -2
- package/schemas/promptlock.schema.json +271 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://raw.githubusercontent.com/shmulikdav/Promptlock/main/schemas/promptlock.schema.json",
|
|
4
|
+
"title": "prompt-lock config",
|
|
5
|
+
"description": "Configuration schema for a prompt-lock test definition. Can be a single config object or an array of configs.",
|
|
6
|
+
"oneOf": [
|
|
7
|
+
{ "$ref": "#/definitions/PromptLockConfig" },
|
|
8
|
+
{
|
|
9
|
+
"type": "array",
|
|
10
|
+
"items": { "$ref": "#/definitions/PromptLockConfig" }
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"definitions": {
|
|
14
|
+
"PromptLockConfig": {
|
|
15
|
+
"type": "object",
|
|
16
|
+
"required": ["id", "provider", "model", "prompt", "assertions"],
|
|
17
|
+
"additionalProperties": false,
|
|
18
|
+
"properties": {
|
|
19
|
+
"id": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"description": "Unique identifier for this prompt. Used in reports and to filter runs with --id."
|
|
22
|
+
},
|
|
23
|
+
"version": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "Semantic version string for this prompt, used in snapshot history."
|
|
26
|
+
},
|
|
27
|
+
"provider": {
|
|
28
|
+
"description": "LLM provider: 'openai', 'anthropic', or a custom HTTP endpoint.",
|
|
29
|
+
"oneOf": [
|
|
30
|
+
{ "type": "string", "enum": ["openai", "anthropic"] },
|
|
31
|
+
{ "$ref": "#/definitions/CustomProviderConfig" }
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
"model": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"description": "Model ID to use (e.g. 'gpt-4o-mini', 'claude-sonnet-4-20250514')."
|
|
37
|
+
},
|
|
38
|
+
"prompt": {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"description": "The prompt text. Use {{variableName}} for template variables."
|
|
41
|
+
},
|
|
42
|
+
"defaultVars": {
|
|
43
|
+
"type": "object",
|
|
44
|
+
"description": "Default values for template variables in the prompt.",
|
|
45
|
+
"additionalProperties": { "type": "string" }
|
|
46
|
+
},
|
|
47
|
+
"dataset": {
|
|
48
|
+
"description": "Test inputs: an inline array of variable objects, or a file path string (.csv or .json).",
|
|
49
|
+
"oneOf": [
|
|
50
|
+
{
|
|
51
|
+
"type": "array",
|
|
52
|
+
"items": {
|
|
53
|
+
"type": "object",
|
|
54
|
+
"additionalProperties": { "type": "string" }
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"type": "string",
|
|
59
|
+
"pattern": "\\.(csv|json)$"
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
"assertions": {
|
|
64
|
+
"type": "array",
|
|
65
|
+
"description": "Behavioral assertions to run against the output.",
|
|
66
|
+
"items": { "$ref": "#/definitions/Assertion" }
|
|
67
|
+
},
|
|
68
|
+
"options": {
|
|
69
|
+
"$ref": "#/definitions/PromptLockOptions"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"CustomProviderConfig": {
|
|
74
|
+
"type": "object",
|
|
75
|
+
"required": ["type", "url"],
|
|
76
|
+
"additionalProperties": false,
|
|
77
|
+
"properties": {
|
|
78
|
+
"type": { "type": "string", "const": "custom" },
|
|
79
|
+
"url": {
|
|
80
|
+
"type": "string",
|
|
81
|
+
"description": "HTTP/HTTPS endpoint URL for the custom LLM provider.",
|
|
82
|
+
"pattern": "^https?://"
|
|
83
|
+
},
|
|
84
|
+
"headers": {
|
|
85
|
+
"type": "object",
|
|
86
|
+
"description": "Custom HTTP headers (e.g. Authorization).",
|
|
87
|
+
"additionalProperties": { "type": "string" }
|
|
88
|
+
},
|
|
89
|
+
"bodyTemplate": {
|
|
90
|
+
"type": "object",
|
|
91
|
+
"description": "Custom request body template with {{prompt}} and {{model}} placeholders."
|
|
92
|
+
},
|
|
93
|
+
"responsePath": {
|
|
94
|
+
"type": "string",
|
|
95
|
+
"description": "JSONPath to extract the response text (e.g. 'choices[0].message.content')."
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
"PromptLockOptions": {
|
|
100
|
+
"type": "object",
|
|
101
|
+
"additionalProperties": false,
|
|
102
|
+
"properties": {
|
|
103
|
+
"temperature": { "type": "number", "minimum": 0, "maximum": 2 },
|
|
104
|
+
"maxTokens": { "type": "integer", "minimum": 1 },
|
|
105
|
+
"timeout": { "type": "integer", "minimum": 1 },
|
|
106
|
+
"parallel": { "type": "boolean" },
|
|
107
|
+
"concurrency": { "type": "integer", "minimum": 1 }
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
"Assertion": {
|
|
111
|
+
"oneOf": [
|
|
112
|
+
{
|
|
113
|
+
"type": "object",
|
|
114
|
+
"required": ["type", "value"],
|
|
115
|
+
"properties": {
|
|
116
|
+
"type": { "const": "contains" },
|
|
117
|
+
"value": { "type": "string", "description": "String that must appear in the output." }
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"type": "object",
|
|
122
|
+
"required": ["type", "value"],
|
|
123
|
+
"properties": {
|
|
124
|
+
"type": { "const": "not-contains" },
|
|
125
|
+
"value": { "type": "string", "description": "String that must NOT appear in the output." }
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"type": "object",
|
|
130
|
+
"required": ["type", "values"],
|
|
131
|
+
"properties": {
|
|
132
|
+
"type": { "const": "contains-all" },
|
|
133
|
+
"values": {
|
|
134
|
+
"type": "array",
|
|
135
|
+
"items": { "type": "string" },
|
|
136
|
+
"description": "All strings that must appear in the output."
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"type": "object",
|
|
142
|
+
"required": ["type", "value"],
|
|
143
|
+
"properties": {
|
|
144
|
+
"type": { "const": "starts-with" },
|
|
145
|
+
"value": { "type": "string" }
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"type": "object",
|
|
150
|
+
"required": ["type", "value"],
|
|
151
|
+
"properties": {
|
|
152
|
+
"type": { "const": "ends-with" },
|
|
153
|
+
"value": { "type": "string" }
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"type": "object",
|
|
158
|
+
"required": ["type", "pattern"],
|
|
159
|
+
"properties": {
|
|
160
|
+
"type": { "const": "matches-regex" },
|
|
161
|
+
"pattern": { "type": "string", "description": "JavaScript regex pattern." }
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"type": "object",
|
|
166
|
+
"required": ["type", "chars"],
|
|
167
|
+
"properties": {
|
|
168
|
+
"type": { "const": "max-length" },
|
|
169
|
+
"chars": { "type": "integer", "minimum": 0 }
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"type": "object",
|
|
174
|
+
"required": ["type", "chars"],
|
|
175
|
+
"properties": {
|
|
176
|
+
"type": { "const": "min-length" },
|
|
177
|
+
"chars": { "type": "integer", "minimum": 0 }
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"type": "object",
|
|
182
|
+
"required": ["type"],
|
|
183
|
+
"properties": {
|
|
184
|
+
"type": { "const": "json-valid" }
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"type": "object",
|
|
189
|
+
"required": ["type", "schema"],
|
|
190
|
+
"properties": {
|
|
191
|
+
"type": { "const": "json-schema" },
|
|
192
|
+
"schema": {
|
|
193
|
+
"type": "object",
|
|
194
|
+
"description": "JSON Schema the output must validate against."
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"type": "object",
|
|
200
|
+
"required": ["type"],
|
|
201
|
+
"properties": {
|
|
202
|
+
"type": { "const": "no-hallucination-words" },
|
|
203
|
+
"words": {
|
|
204
|
+
"type": "array",
|
|
205
|
+
"items": { "type": "string" },
|
|
206
|
+
"description": "Hallucination indicator words to check for (default list used if omitted)."
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"type": "object",
|
|
212
|
+
"required": ["type"],
|
|
213
|
+
"properties": {
|
|
214
|
+
"type": { "const": "no-duplicates" },
|
|
215
|
+
"separator": {
|
|
216
|
+
"type": "string",
|
|
217
|
+
"description": "Separator to split the output by (default '\\n')."
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"type": "object",
|
|
223
|
+
"required": ["type", "ms"],
|
|
224
|
+
"properties": {
|
|
225
|
+
"type": { "const": "max-latency" },
|
|
226
|
+
"ms": { "type": "integer", "minimum": 0, "description": "Max LLM response time in milliseconds." }
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
"type": "object",
|
|
231
|
+
"required": ["type", "dollars"],
|
|
232
|
+
"properties": {
|
|
233
|
+
"type": { "const": "max-cost" },
|
|
234
|
+
"dollars": { "type": "number", "minimum": 0, "description": "Max cost in USD for the LLM call." }
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"type": "object",
|
|
239
|
+
"required": ["type", "judge", "criteria"],
|
|
240
|
+
"properties": {
|
|
241
|
+
"type": { "const": "llm-judge" },
|
|
242
|
+
"judge": {
|
|
243
|
+
"type": "object",
|
|
244
|
+
"required": ["provider", "model"],
|
|
245
|
+
"properties": {
|
|
246
|
+
"provider": {
|
|
247
|
+
"oneOf": [
|
|
248
|
+
{ "type": "string", "enum": ["openai", "anthropic"] },
|
|
249
|
+
{ "$ref": "#/definitions/CustomProviderConfig" }
|
|
250
|
+
]
|
|
251
|
+
},
|
|
252
|
+
"model": { "type": "string" }
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
"criteria": { "type": "string", "description": "Evaluation criteria for the judge LLM." },
|
|
256
|
+
"threshold": { "type": "number", "minimum": 0, "maximum": 1, "description": "Pass threshold (0-1). Default 0.7." }
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
"type": "object",
|
|
261
|
+
"required": ["type", "name"],
|
|
262
|
+
"properties": {
|
|
263
|
+
"type": { "const": "custom" },
|
|
264
|
+
"name": { "type": "string" },
|
|
265
|
+
"fn": { "description": "Function returning boolean or Promise<boolean>. JS configs only." }
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
]
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|