Skip to content

Commit

Permalink
[Fix] remove validator in dataclass for multimodal
Browse files Browse the repository at this point in the history
  • Loading branch information
Daggx committed May 15, 2024
1 parent 155fa2b commit 0c21160
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions edenai_apis/features/multimodal/chat/chat_dataclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,21 @@ class ChatMessage(BaseModel):
type: Literal["media_url", "media_base64", "text"]
content: ChatMessageContent

@model_validator(mode="before")
def check_type_and_content(cls, values):
type_, content = values.get("type"), values.get("content")
if type_ == "media_url" and not content.media_url:
raise ValueError(
"If type is media_url, media_url must be provided in content"
)
if type_ == "media_base64" and not content.media_base64:
raise ValueError(
"If type is media_base64, media_base64 must be provided in content"
)
if type_ == "text" and not content.text:
raise ValueError("If type is text, text must be provided in content")

return values
# @model_validator(mode="before")
# def check_type_and_content(cls, values):
# type_, content = values.get("type"), values.get("content")
# if type_ == "media_url" and not content.media_url:
# raise ValueError(
# "If type is media_url, media_url must be provided in content"
# )
# if type_ == "media_base64" and not content.media_base64:
# raise ValueError(
# "If type is media_base64, media_base64 must be provided in content"
# )
# if type_ == "text" and not content.text:
# raise ValueError("If type is text, text must be provided in content")

# return values


class ChatMessageDataClass(BaseModel):
Expand Down

0 comments on commit 0c21160

Please sign in to comment.