mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
fix(pangea): use elif to prevent UnboundLocalError and handle None messages
Address Greptile review feedback:
- Make branches mutually exclusive using elif to prevent input_messages from being overwritten
- Handle case where data.get('messages') returns None to avoid passing invalid payload to Pangea API
This commit is contained in:
parent
0337fa79ea
commit
32116cf433
1 changed files with 6 additions and 3 deletions
|
|
@ -250,10 +250,13 @@ class PangeaHandler(CustomGuardrail):
|
|||
if isinstance(response, TextCompletionResponse):
|
||||
# Assume the earlier call type as well
|
||||
input_messages = _TextCompletionRequest(data).get_messages()
|
||||
if not isinstance(response, ModelResponse):
|
||||
return
|
||||
elif isinstance(response, ModelResponse):
|
||||
messages = data.get("messages")
|
||||
if messages is None:
|
||||
return # No messages to check
|
||||
input_messages = cast(List[Dict[Any, Any]], messages)
|
||||
else:
|
||||
input_messages = cast(List[Dict[Any, Any]], data.get("messages"))
|
||||
return
|
||||
|
||||
if choices := response.get("choices"):
|
||||
if isinstance(choices, list):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue