From d889ca04ade6d444e1e747dc9fd81e8e0508e35c Mon Sep 17 00:00:00 2001 From: Takeshi Yagiuchi Date: Thu, 10 Oct 2024 14:01:38 +0900 Subject: [PATCH] fix: enable the messages tag in RAIL --- guardrails/guard.py | 7 ++++++- guardrails/schema/rail_schema.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/guardrails/guard.py b/guardrails/guard.py index 9f95c451d..b41b45af1 100644 --- a/guardrails/guard.py +++ b/guardrails/guard.py @@ -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( diff --git a/guardrails/schema/rail_schema.py b/guardrails/schema/rail_schema.py index 2aaa04ec4..2071f6b01 100644 --- a/guardrails/schema/rail_schema.py +++ b/guardrails/schema/rail_schema.py @@ -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