Skip to content

Commit

Permalink
Fix pydantic warnings when saving state (#4801)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sachin Joglekar authored Dec 23, 2024
1 parent 9c8877e commit 8e116fd
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, List, Mapping, Optional
from typing import Annotated, Any, List, Mapping, Optional

from pydantic import BaseModel, Field

Expand All @@ -7,6 +7,9 @@
ChatMessage,
)

# Ensures pydantic can distinguish between types of events & messages.
_AgentMessage = Annotated[AgentEvent | ChatMessage, Field(discriminator="type")]


class BaseState(BaseModel):
"""Base class for all saveable state"""
Expand All @@ -33,7 +36,7 @@ class TeamState(BaseState):
class BaseGroupChatManagerState(BaseState):
"""Base state for all group chat managers."""

message_thread: List[AgentEvent | ChatMessage] = Field(default_factory=list)
message_thread: List[_AgentMessage] = Field(default_factory=list)
current_turn: int = Field(default=0)
type: str = Field(default="BaseGroupChatManagerState")

Expand Down

0 comments on commit 8e116fd

Please sign in to comment.