Skip to content

Commit 78a2f86

Browse files
authored
fix(core): improve JSON get_format_instructions using Opik Agent Optimizer (#33718)
1 parent b5e23e5 commit 78a2f86

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
"""Format instructions."""
22

3-
JSON_FORMAT_INSTRUCTIONS = """The output should be formatted as a JSON instance that conforms to the JSON schema below.
3+
JSON_FORMAT_INSTRUCTIONS = """STRICT OUTPUT FORMAT:
4+
- Return only the JSON value that conforms to the schema. Do not include any additional text, explanations, headings, or separators.
5+
- Do not wrap the JSON in Markdown or code fences (no ``` or ```json).
6+
- Do not prepend or append any text (e.g., do not write "Here is the JSON:").
7+
- The response must be a single top-level JSON value exactly as required by the schema (object/array/etc.), with no trailing commas or comments.
48
5-
As an example, for the schema {{"properties": {{"foo": {{"title": "Foo", "description": "a list of strings", "type": "array", "items": {{"type": "string"}}}}}}, "required": ["foo"]}}
6-
the object {{"foo": ["bar", "baz"]}} is a well-formatted instance of the schema. The object {{"properties": {{"foo": ["bar", "baz"]}}}} is not well-formatted.
9+
The output should be formatted as a JSON instance that conforms to the JSON schema below.
710
8-
Here is the output schema:
11+
As an example, for the schema {{"properties": {{"foo": {{"title": "Foo", "description": "a list of strings", "type": "array", "items": {{"type": "string"}}}}}}, "required": ["foo"]}} the object {{"foo": ["bar", "baz"]}} is a well-formatted instance of the schema. The object {{"properties": {{"foo": ["bar", "baz"]}}}} is not well-formatted.
12+
13+
Here is the output schema (shown in a code block for readability only — do not include any backticks or Markdown in your output):
914
```
1015
{schema}
1116
```""" # noqa: E501

0 commit comments

Comments
 (0)