fix(utils.py): handle key error in msg validation (#8325)

* fix(utils.py): handle key error in msg validation

* Support running Aim Guard during LLM call (#7918)

* support running Aim Guard during LLM call

* Rename header

* adjust docs and fix type annotations

* fix(timeout.md): doc fix for openai example on dynamic timeouts

---------

Co-authored-by: Tomer Bin <117278227+hxtomer@users.noreply.github.com>
This commit is contained in:
Krish Dholakia 2025-02-06 18:13:46 -08:00 committed by GitHub
parent fac1d2ccef
commit f031926b82
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 56 additions and 21 deletions

View file

@ -5884,6 +5884,10 @@ def validate_chat_completion_user_messages(messages: List[AllMessageValues]):
if item.get("type") not in ValidUserMessageContentTypes:
raise Exception("invalid content type")
except Exception as e:
if isinstance(e, KeyError):
raise Exception(
f"Invalid message={m} at index {idx}. Please ensure all messages are valid OpenAI chat completion messages."
)
if "invalid content type" in str(e):
raise Exception(
f"Invalid user message={m} at index {idx}. Please ensure all user messages are valid OpenAI chat completion messages."