dylanglenister commited on
Commit
f24832a
·
1 Parent(s): 51db461

Minor fixes to models

Browse files
Files changed (2) hide show
  1. src/models/common.py +3 -2
  2. src/models/session.py +5 -1
src/models/common.py CHANGED
@@ -8,10 +8,11 @@ PyObjectId = Annotated[str, BeforeValidator(str)]
8
 
9
  class BaseMongoModel(BaseModel):
10
  """A base Pydantic model for all MongoDB documents."""
11
- id: PyObjectId = Field(..., alias="_id")
12
 
13
  model_config = ConfigDict(
14
  frozen=True,
15
  from_attributes=True,
16
- arbitrary_types_allowed=True
 
17
  )
 
8
 
9
  class BaseMongoModel(BaseModel):
10
  """A base Pydantic model for all MongoDB documents."""
11
+ id: PyObjectId = Field(..., validation_alias="_id")
12
 
13
  model_config = ConfigDict(
14
  frozen=True,
15
  from_attributes=True,
16
+ arbitrary_types_allowed=True,
17
+ populate_by_name=True
18
  )
src/models/session.py CHANGED
@@ -16,7 +16,11 @@ class Message(BaseModel):
16
  timestamp: datetime
17
 
18
  # Use a standard config for this sub-model
19
- model_config = ConfigDict(frozen=True, from_attributes=True)
 
 
 
 
20
 
21
  class Session(BaseMongoModel):
22
  """A Pydantic model for a chat session, including nested messages."""
 
16
  timestamp: datetime
17
 
18
  # Use a standard config for this sub-model
19
+ model_config = ConfigDict(
20
+ frozen=True,
21
+ from_attributes=True,
22
+ populate_by_name=True
23
+ )
24
 
25
  class Session(BaseMongoModel):
26
  """A Pydantic model for a chat session, including nested messages."""