diff --git a/README.md b/README.md index 6ae30a8aa..fdc098001 100644 --- a/README.md +++ b/README.md @@ -143,8 +143,6 @@ Given below is XML that describes the information to extract from this document ONLY return a valid JSON object (no other text is necessary). The JSON MUST conform to the XML format, including any types and format requests e.g. requests for lists, objects and specific types. Be correct and concise. - -JSON Output: ``` Call the `Guard` object with the LLM API call as the first argument and add any additional arguments to the LLM API call as the remaining arguments. diff --git a/docs/rail/prompt.md b/docs/rail/prompt.md index c036b092a..d3fe30fad 100644 --- a/docs/rail/prompt.md +++ b/docs/rail/prompt.md @@ -41,6 +41,4 @@ Given the following document, answer the following questions. If the answer does ``` ONLY return a valid JSON object (no other text is necessary). The JSON MUST conform to the XML format, including any types and format requests e.g. requests for lists, objects and specific types. Be correct and concise. If you are unsure anywhere, enter `None`. - -JSON Output: ``` diff --git a/guardrails/constants.xml b/guardrails/constants.xml index 253bc0f3e..8c7e88546 100644 --- a/guardrails/constants.xml +++ b/guardrails/constants.xml @@ -13,15 +13,11 @@ Given below is XML that describes the information to extract from this document ONLY return a valid JSON object (no other text is necessary). The JSON MUST conform to the XML format, including any types and format requests e.g. requests for lists, objects and specific types. Be correct and concise. If you are unsure anywhere, enter "None". - -JSON Output: ONLY return a valid JSON object (no other text is necessary). The JSON MUST conform to the XML format, including any types and format requests e.g. requests for lists, objects and specific types. Be correct and concise. - -JSON Output: @@ -46,8 +42,7 @@ Here are examples of simple (XML, JSON) pairs that show the expected behavior: - ``]]> => `{{{{'foo': 'example one'}}}}` - `]]>` => `{{{{"bar": ['STRING ONE', 'STRING TWO', etc.]}}}}` - `]]>` => `{{{{'baz': {{{{'foo': 'Some String', 'index': 1}}}}}}}}` - -JSON Object: + Given below is XML that describes the information to extract from this document and the tags to extract it into. @@ -60,8 +55,7 @@ Here are examples of simple (XML, JSON) pairs that show the expected behavior: - ``]]> => `{{{{'foo': 'example one'}}}}` - `]]>` => `{{{{"bar": ['STRING ONE', 'STRING TWO', etc.]}}}}` - `]]>` => `{{{{'baz': {{{{'foo': 'Some String', 'index': 1}}}}}}}}` - -JSON Object: + \ No newline at end of file diff --git a/guardrails/llm_providers.py b/guardrails/llm_providers.py index 78af007ff..781326cf6 100644 --- a/guardrails/llm_providers.py +++ b/guardrails/llm_providers.py @@ -46,7 +46,7 @@ def openai_wrapper(text: str, *args, **kwargs): api_key = os.environ.get("OPENAI_API_KEY") openai_response = openai.Completion.create( api_key=api_key, - prompt=text, + prompt=text + "\n\nJson Output:\n\n", *args, **kwargs, ) diff --git a/tests/integration_tests/test_cases/entity_extraction/compiled_prompt.txt b/tests/integration_tests/test_cases/entity_extraction/compiled_prompt.txt index 61ac648a8..466c4bea7 100644 --- a/tests/integration_tests/test_cases/entity_extraction/compiled_prompt.txt +++ b/tests/integration_tests/test_cases/entity_extraction/compiled_prompt.txt @@ -131,5 +131,3 @@ Given below is XML that describes the information to extract from this document ONLY return a valid JSON object (no other text is necessary). The JSON MUST conform to the XML format, including any types and format requests e.g. requests for lists, objects and specific types. Be correct and concise. - -JSON Output: diff --git a/tests/integration_tests/test_cases/entity_extraction/compiled_prompt_reask.txt b/tests/integration_tests/test_cases/entity_extraction/compiled_prompt_reask.txt index 29fe1f3e6..a9299e277 100644 --- a/tests/integration_tests/test_cases/entity_extraction/compiled_prompt_reask.txt +++ b/tests/integration_tests/test_cases/entity_extraction/compiled_prompt_reask.txt @@ -37,5 +37,3 @@ Here are examples of simple (XML, JSON) pairs that show the expected behavior: - `` => `{{'foo': 'example one'}}` - `` => `{{"bar": ['STRING ONE', 'STRING TWO', etc.]}}` - `` => `{{'baz': {{'foo': 'Some String', 'index': 1}}}}` - -JSON Object: \ No newline at end of file diff --git a/tests/integration_tests/test_cases/pydantic/compiled_prompt.txt b/tests/integration_tests/test_cases/pydantic/compiled_prompt.txt index 34f2fef18..edee77f93 100644 --- a/tests/integration_tests/test_cases/pydantic/compiled_prompt.txt +++ b/tests/integration_tests/test_cases/pydantic/compiled_prompt.txt @@ -36,5 +36,3 @@ Here are examples of simple (XML, JSON) pairs that show the expected behavior: - `` => `{'foo': 'example one'}` - `` => `{"bar": ['STRING ONE', 'STRING TWO', etc.]}` - `` => `{'baz': {'foo': 'Some String', 'index': 1}}` - -JSON Object: \ No newline at end of file diff --git a/tests/integration_tests/test_cases/pydantic/compiled_prompt_reask_1.txt b/tests/integration_tests/test_cases/pydantic/compiled_prompt_reask_1.txt index 00ca8b8b2..e72363530 100644 --- a/tests/integration_tests/test_cases/pydantic/compiled_prompt_reask_1.txt +++ b/tests/integration_tests/test_cases/pydantic/compiled_prompt_reask_1.txt @@ -35,5 +35,3 @@ Here are examples of simple (XML, JSON) pairs that show the expected behavior: - `` => `{{'foo': 'example one'}}` - `` => `{{"bar": ['STRING ONE', 'STRING TWO', etc.]}}` - `` => `{{'baz': {{'foo': 'Some String', 'index': 1}}}}` - -JSON Object: \ No newline at end of file diff --git a/tests/integration_tests/test_cases/pydantic/compiled_prompt_reask_2.txt b/tests/integration_tests/test_cases/pydantic/compiled_prompt_reask_2.txt index 65717f183..0926534f2 100644 --- a/tests/integration_tests/test_cases/pydantic/compiled_prompt_reask_2.txt +++ b/tests/integration_tests/test_cases/pydantic/compiled_prompt_reask_2.txt @@ -35,5 +35,3 @@ Here are examples of simple (XML, JSON) pairs that show the expected behavior: - `` => `{{'foo': 'example one'}}` - `` => `{{"bar": ['STRING ONE', 'STRING TWO', etc.]}}` - `` => `{{'baz': {{'foo': 'Some String', 'index': 1}}}}` - -JSON Object: \ No newline at end of file diff --git a/tests/unit_tests/utils/test_reask_utils.py b/tests/unit_tests/utils/test_reask_utils.py index 6dfb40b78..7f7f3e81a 100644 --- a/tests/unit_tests/utils/test_reask_utils.py +++ b/tests/unit_tests/utils/test_reask_utils.py @@ -158,8 +158,7 @@ def test_get_reask_prompt(example_rail, reasks, reask_json): - `` => `{{'foo': 'example one'}}` - `` => `{{"bar": ['STRING ONE', 'STRING TWO', etc.]}}` - `` => `{{'baz': {{'foo': 'Some String', 'index': 1}}}}` - -JSON Object:""" # noqa: E501 +""" # noqa: E501 result_prompt, _ = reask_utils.get_reask_prompt( ET.fromstring(example_rail), reasks, reask_json