Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve JsonSchemaRule template #1175

Merged
merged 5 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/griptape-framework/structures/rulesets.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ A [Ruleset](../../reference/griptape/rules/ruleset.md) can be used to define [Ru
This is particularly useful when you need the LLM to return well-formed data, such as JSON objects, with specific fields and data types.

!!! warning
`JsonSchemaRule` may break [ToolkitTask](../structures/tasks.md#toolkittask) which relies on a specific [output token](https://github.com/griptape-ai/griptape/blob/e6a04c7b88cf9fa5d6bcf4c833ffebfab89a3258/griptape/tasks/toolkit_task.py#L28).
`JsonSchemaRule` may break [ToolkitTask](../structures/tasks.md#toolkit) which relies on a specific [output token](https://github.com/griptape-ai/griptape/blob/e6a04c7b88cf9fa5d6bcf4c833ffebfab89a3258/griptape/tasks/toolkit_task.py#L28).


```python
Expand Down
3 changes: 2 additions & 1 deletion griptape/templates/rules/json_schema.j2
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
You must respond with a JSON object that successfully validates against the following schema: {{json_schema}}
Output valid JSON that matches this schema: {{ json_schema }}
No markdown, code snippets, code blocks, or backticks.
2 changes: 1 addition & 1 deletion tests/unit/rules/test_json_schema_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_to_text(self):
rule = JsonSchemaRule(json_schema)
assert (
rule.to_text()
== f"You must respond with a JSON object that successfully validates against the following schema: {json.dumps(json_schema)}"
== f"Output valid JSON that matches this schema: {json.dumps(json_schema)}\nNo markdown, code snippets, code blocks, or backticks."
)

def test___str__(self):
Expand Down
Loading