Skip to content

Commit

Permalink
refactor: restore LCChatMemory.messages validation
Browse files Browse the repository at this point in the history
  • Loading branch information
lpm0073 committed Nov 29, 2023
1 parent 135dd2e commit a18e7ad
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions grader/langchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from typing import List, Optional

from pydantic import BaseModel, Field
from pydantic import BaseModel, Field, model_validator


class LCRequestMetaData(BaseModel):
Expand All @@ -30,12 +30,12 @@ class LCChatMemory(BaseModel):

messages: List[LCMessage]

# @model_validator(mode="after")
# def validate_messages(self) -> "LCChatMemory":
# """Validate that chat memory contains at least 2 dicts"""
# if len(self.messages) < 2:
# raise ValueError("messages must contain at least 2 objects")
# return self
@model_validator(mode="after")
def validate_messages(self) -> "LCChatMemory":
"""Validate that chat memory contains at least 2 dicts"""
if len(self.messages) < 2:
raise ValueError("messages must contain at least 2 objects")
return self


class LCBody(BaseModel):
Expand Down

0 comments on commit a18e7ad

Please sign in to comment.