Skip to content

Commit

Permalink
Merge pull request #1125 from guardrails-ai/bug/rail_msg_history_mess…
Browse files Browse the repository at this point in the history
…ages

fix: enable the messages tag in RAIL
  • Loading branch information
zsimjee authored Oct 17, 2024
2 parents 7d78643 + d889ca0 commit 80fc455
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 80fc455

Please sign in to comment.