Skip to content

Commit

Permalink
Miscellaneous typo, type annotation and docs fixes (#396)
Browse files Browse the repository at this point in the history
* fix: URL typo to https://docs.guardrailsai.com/0-2-migration/

* fix: add return type annotation for completeness sake

* docs: fix the instructions element docs typos

* docs: improve the Prompts Element docs page

---------

Co-authored-by: Caleb Courier <[email protected]>
  • Loading branch information
marwan116 and CalebCourier authored Oct 26, 2023
1 parent 9df4acd commit a06a9e6
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions docs/concepts/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The `<instructions></instructions>` element is passed to the LLM as secondary input. Different model may use these differently. For example, chat models may receive instructions in the system-prompt.

## 📚 Components of a Instructions
## 📚 Components of an Instructions Element

In addition to any static text describing the context of the task, instructions can also contain any of the following:

Expand All @@ -25,8 +25,8 @@ ${gr.json_suffix_prompt_examples} <!-- (2)! -->
</rail>
```

1. The instructions contains high level background information for the LLM containing textual context and constraints.
2. `${gr.json_suffix_prompt_examples}` is a prompt primitive provided by guardrails. It is equivalent to typing the following lines in the prompt:
1. The instructions element contains high level background information for the LLM containing textual context and constraints.
2. `${gr.json_suffix_prompt_examples}` is a prompt primitive provided by guardrails. It is equivalent to typing the following lines in the instructions:
````
ONLY return a valid JSON object (no other text is necessary), where the key of the field in JSON is the `name` attribute of the corresponding XML, and the value is of the type specified by the corresponding XML's tag. 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 `null`.
Expand All @@ -45,8 +45,8 @@ instructions = """You are a helpful assistant only capable of communicating with
```


1. The instructions contains high level background information for the LLM containing textual context and constraints.
2. `${gr.json_suffix_prompt_examples}` is a prompt primitive provided by guardrails. It is equivalent to typing the following lines in the prompt:
1. The instructions element contains high level background information for the LLM containing textual context and constraints.
2. `${gr.json_suffix_prompt_examples}` is a prompt primitive provided by guardrails. It is equivalent to typing the following lines in the instructions:
````
ONLY return a valid JSON object (no other text is necessary), where the key of the field in JSON is the `name` attribute of the corresponding XML, and the value is of the type specified by the corresponding XML's tag. 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 `null`.
Expand Down
4 changes: 2 additions & 2 deletions docs/concepts/prompt.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# `Prompt` Element

The `<prompt></prompt>` element contains the high level instructions sent to the LLM that describe the high level task.
The `<prompt></prompt>` element contains the query that describes the high level task.

## 📚 Components of a Prompt
## 📚 Components of a Prompt Element

In addition to the high level task description, the prompt also contains the following:

Expand Down
4 changes: 2 additions & 2 deletions docs/examples/regex_validation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@
"text": [
"/home/zayd/workspace/shreya/guardrails/.venv/lib/python3.11/site-packages/guardrails/rail.py:115: UserWarning: Prompt must be provided during __call__.\n",
" warnings.warn(\"Prompt must be provided during __call__.\")\n",
"/home/zayd/workspace/shreya/guardrails/.venv/lib/python3.11/site-packages/guardrails/prompt/prompt.py:23: UserWarning: Prompt does not have any variables, if you are migrating follow the new variable convention documented here: https://docs.getguardrails.ai/0-2-migration/\n",
"/home/zayd/workspace/shreya/guardrails/.venv/lib/python3.11/site-packages/guardrails/prompt/prompt.py:23: UserWarning: Prompt does not have any variables, if you are migrating follow the new variable convention documented here: https://docs.guardrailsai.com/0-2-migration/\n",
" warnings.warn(\n",
"/home/zayd/workspace/shreya/guardrails/.venv/lib/python3.11/site-packages/guardrails/prompt/instructions.py:32: UserWarning: Instructions do not have any variables, if you are migrating follow the new variable convention documented here: https://docs.getguardrails.ai/0-2-migration/\n",
"/home/zayd/workspace/shreya/guardrails/.venv/lib/python3.11/site-packages/guardrails/prompt/instructions.py:32: UserWarning: Instructions do not have any variables, if you are migrating follow the new variable convention documented here: https://docs.guardrailsai.com/0-2-migration/\n",
" warn(\n"
]
},
Expand Down
2 changes: 1 addition & 1 deletion docs/integrations/azure_openai.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/rafael/guardrails/guardrails/prompt/prompt.py:23: UserWarning: Prompt does not have any variables, if you are migrating follow the new variable convention documented here: https://docs.getguardrails.ai/0-2-migration/\n",
"/Users/rafael/guardrails/guardrails/prompt/prompt.py:23: UserWarning: Prompt does not have any variables, if you are migrating follow the new variable convention documented here: https://docs.guardrailsai.com/0-2-migration/\n",
" warnings.warn(\n"
]
}
Expand Down
2 changes: 1 addition & 1 deletion guardrails/document_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class DocumentStoreBase(ABC):
"""

@abstractmethod
def add_document(self, document: Document):
def add_document(self, document: Document) -> None:
"""Adds a document to the store.
Args:
Expand Down
2 changes: 1 addition & 1 deletion guardrails/prompt/base_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def substitute_constants(self, text):
warnings.warn(
"It appears that you are using an old schema for gaurdrails variables, "
"follow the new namespaced convention "
"documented here: https://docs.getguardrails.ai/0-2-migration/"
"documented here: https://docs.guardrailsai.com/0-2-migration/"
)

matches = re.findall(r"\${gr\.(\w+)}", text)
Expand Down
2 changes: 1 addition & 1 deletion guardrails/prompt/instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def format(self, **kwargs):
warn(
"Instructions do not have any variables, "
"if you are migrating follow the new variable convention "
"documented here: https://docs.getguardrails.ai/0-2-migration/"
"documented here: https://docs.guardrailsai.com/0-2-migration/"
)

# Return another instance of the class with the formatted prompt.
Expand Down
2 changes: 1 addition & 1 deletion guardrails/prompt/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def format(self, **kwargs):
warnings.warn(
"Prompt does not have any variables, "
"if you are migrating follow the new variable convention "
"documented here: https://docs.getguardrails.ai/0-2-migration/"
"documented here: https://docs.guardrailsai.com/0-2-migration/"
)

# Return another instance of the class with the formatted prompt.
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/test_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def test_uses_old_constant_schema(text, is_old_schema):
warn_mock.assert_called_once_with(
"""It appears that you are using an old schema for gaurdrails\
variables, follow the new namespaced convention documented here:\
https://docs.getguardrails.ai/0-2-migration/\
https://docs.guardrailsai.com/0-2-migration/\
"""
)

Expand Down

0 comments on commit a06a9e6

Please sign in to comment.