Skip to content

Commit 443946a

Browse files
committed
fix: add type alias
1 parent 55c0c08 commit 443946a

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/codegen/agents/data.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List, Optional
1+
from typing import List, Optional, Union
22
from dataclasses import dataclass, field
33
from datetime import datetime
44

@@ -49,4 +49,6 @@ class FunctionMessageData(BaseMessage):
4949
@dataclass
5050
class UnknownMessage(BaseMessage):
5151
"""Represents an unknown message type."""
52-
type: str = field(default="unknown")
52+
type: str = field(default="unknown")
53+
54+
type AgentRunMessage = Union[UserMessage, SystemMessageData, AssistantMessage, ToolMessageData, FunctionMessageData, UnknownMessage]

src/codegen/agents/loggers.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import json
2-
from typing import Dict, List, Any, Union, Protocol
3-
from dataclasses import asdict
4-
from .data import BaseMessage
1+
from typing import Protocol
2+
from .data import AgentRunMessage
53

64
# Define the interface for ExternalLogger
75
class ExternalLogger(Protocol):
86
"""Protocol defining the interface for external loggers."""
97

10-
def log(self, data: Union[Dict[str, Any], BaseMessage]) -> None:
8+
def log(self, data: AgentRunMessage) -> None:
119
"""
1210
Log structured data to an external system.
1311

0 commit comments

Comments
 (0)