Skip to content

Commit

Permalink
fix: enable the messages tag in RAIL
Browse files Browse the repository at this point in the history
  • Loading branch information
takeshiyagiuchi authored and dtam committed Oct 10, 2024
1 parent 30eeb4c commit d889ca0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion guardrails/guard.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,12 @@ def __call__(
"""
instructions = instructions or self._exec_opts.instructions
prompt = prompt or self._exec_opts.prompt
msg_history = msg_history or kwargs.get("messages", None) or []
msg_history = (
msg_history
or kwargs.get("messages", None)
or self._exec_opts.messages
or []
)
if prompt is None:
if msg_history is not None and not len(msg_history):
raise RuntimeError(
Expand Down
2 changes: 1 addition & 1 deletion guardrails/schema/rail_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ def rail_string_to_schema(rail_string: str) -> ProcessedSchema:
role = message.attrib.get("role")
content = message.text
extracted_reask_messages.append({"role": role, "content": content})
processed_schema.exec_opts.messages = extracted_reask_messages
processed_schema.exec_opts.reask_messages = extracted_reask_messages

return processed_schema

Expand Down

0 comments on commit d889ca0

Please sign in to comment.