@zhushanwen/pi-structured-output 0.3.0 → 0.3.1
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/package.json +1 -1
- package/src/index.ts +16 -11
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -38,24 +38,29 @@ export default function structuredOutputExtension(pi: PiAPI): void {
|
|
|
38
38
|
label: "Structured Output",
|
|
39
39
|
description:
|
|
40
40
|
"Return structured output validated against a JSON Schema. "
|
|
41
|
-
+ "Call this tool
|
|
42
|
-
+ "Pass
|
|
43
|
-
+ "
|
|
41
|
+
+ "Call this tool to produce validated JSON data. "
|
|
42
|
+
+ "Pass `schema` (a JSON Schema draft-07 object) and `data` (the value to validate).\n\n"
|
|
43
|
+
+ "✅ Correct: schema={type:'object',properties:{name:{type:'string'},age:{type:'number'}},required:['name']}, data={name:'Alice',age:30}\n"
|
|
44
|
+
+ "✅ Correct: schema={type:'array',items:{type:'string'}}, data=['a','b','c']\n"
|
|
45
|
+
+ "✅ Correct: schema={type:'string',enum:['low','medium','high']}, data='medium'\n\n"
|
|
46
|
+
+ "❌ Wrong: putting the answer in text instead of calling this tool\n"
|
|
47
|
+
+ "❌ Wrong: data not matching schema (e.g. schema requires number but data is string)\n"
|
|
48
|
+
+ "❌ Wrong: schema={type:'object'} with data='hello' (string ≠ object)",
|
|
44
49
|
promptSnippet:
|
|
45
50
|
"Use structured-output to return validated JSON data. "
|
|
46
|
-
+ "Pass schema (JSON Schema) and data (your output). "
|
|
47
|
-
+ "
|
|
51
|
+
+ "Pass schema (JSON Schema draft-07) and data (your output). "
|
|
52
|
+
+ "Example: {schema:{type:'object',properties:{score:{type:'number'}},required:['score']}, data:{score:8}}",
|
|
48
53
|
promptGuidelines: [
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"Do not output JSON in text —
|
|
54
|
+
"schema must be a valid JSON Schema (draft-07). data must conform to it.",
|
|
55
|
+
"Both primitive types (string, number, boolean) and complex types (object, array) are valid schema roots.",
|
|
56
|
+
"Do not output JSON in text — call this tool instead.",
|
|
52
57
|
],
|
|
53
58
|
parameters: Type.Object({
|
|
54
|
-
schema: Type.
|
|
55
|
-
description: "JSON Schema object
|
|
59
|
+
schema: Type.Any({
|
|
60
|
+
description: "JSON Schema draft-07 object. Example: {type:'object',properties:{name:{type:'string'}},required:['name']}",
|
|
56
61
|
}),
|
|
57
62
|
data: Type.Any({
|
|
58
|
-
description: "The value to validate against
|
|
63
|
+
description: "The value to validate against schema. Example: {name:'Alice'}",
|
|
59
64
|
}),
|
|
60
65
|
}),
|
|
61
66
|
async execute(
|