@@ -43,14 +43,14 @@ def nonchat_prompt(prompt: str, instructions: Optional[str] = None) -> str:
4343def chat_prompt (
4444 prompt : Optional [str ],
4545 instructions : Optional [str ] = None ,
46- msg_history : Optional [List [Dict ]] = None ,
46+ messages : Optional [List [Dict ]] = None ,
4747) -> List [Dict [str , str ]]:
4848 """Prepare final prompt for chat engine."""
49- if msg_history :
50- return msg_history
49+ if messages :
50+ return messages
5151 if prompt is None :
5252 raise PromptCallableException (
53- "You must pass in either `text` or `msg_history ` to `guard.__call__`."
53+ "You must pass in either `text` or `messages ` to `guard.__call__`."
5454 )
5555
5656 if not instructions :
@@ -65,14 +65,14 @@ def chat_prompt(
6565def litellm_messages (
6666 prompt : Optional [str ],
6767 instructions : Optional [str ] = None ,
68- msg_history : Optional [List [Dict ]] = None ,
68+ messages : Optional [List [Dict ]] = None ,
6969) -> List [Dict [str , str ]]:
7070 """Prepare messages for LiteLLM."""
71- if msg_history :
72- return msg_history
71+ if messages :
72+ return messages
7373 if prompt is None :
7474 raise PromptCallableException (
75- "Either `text` or `msg_history ` required for `guard.__call__`."
75+ "Either `text` or `messages ` required for `guard.__call__`."
7676 )
7777
7878 if instructions :
@@ -143,8 +143,7 @@ def _invoke_llm(
143143 self ,
144144 text : Optional [str ] = None ,
145145 model : str = "gpt-3.5-turbo" ,
146- instructions : Optional [str ] = None ,
147- msg_history : Optional [List [Dict ]] = None ,
146+ messages : Optional [List [Dict ]] = None ,
148147 * args ,
149148 ** kwargs ,
150149 ) -> LLMResponse :
@@ -170,9 +169,9 @@ def _invoke_llm(
170169 "The `litellm` package is not installed. "
171170 "Install with `pip install litellm`"
172171 ) from e
173- if text is not None or instructions is not None or msg_history is not None :
172+ if messages is not None :
174173 messages = litellm_messages (
175- prompt = text , instructions = instructions , msg_history = msg_history
174+ prompt = text , messages = messages
176175 )
177176 kwargs ["messages" ] = messages
178177
@@ -592,7 +591,7 @@ async def invoke_llm(
592591 self ,
593592 text : Optional [str ] = None ,
594593 instructions : Optional [str ] = None ,
595- msg_history : Optional [List [Dict ]] = None ,
594+ messages : Optional [List [Dict ]] = None ,
596595 * args ,
597596 ** kwargs ,
598597 ):
@@ -619,11 +618,11 @@ async def invoke_llm(
619618 "Install with `pip install litellm`"
620619 ) from e
621620
622- if text is not None or instructions is not None or msg_history is not None :
621+ if text is not None or instructions is not None or messages is not None :
623622 messages = litellm_messages (
624623 prompt = text ,
625624 instructions = instructions ,
626- msg_history = msg_history ,
625+ messages = messages ,
627626 )
628627 kwargs ["messages" ] = messages
629628
0 commit comments