replaced init method to pydantic one

This commit is contained in:
shinrei
2025-07-02 20:32:04 +00:00
parent 240384840e
commit 686f5da8ce
2 changed files with 3 additions and 10 deletions

View File

@@ -18,5 +18,7 @@ class SolarisClient:
async def send_messages(self, messages: list[InputMessage]) -> list[OutputMessage]: async def send_messages(self, messages: list[InputMessage]) -> list[OutputMessage]:
data = json.dumps([msg.model_dump() for msg in messages], ensure_ascii=True) data = json.dumps([msg.model_dump() for msg in messages], ensure_ascii=True)
resp = await self.chat.send_message(data, config=MESSAGE_CONTENT_CONFIG) resp = await self.chat.send_message(data, config=MESSAGE_CONTENT_CONFIG)
output_messages = [OutputMessage.fromdict(msg) for msg in json.loads(resp.text)] output_messages = [
OutputMessage.model_validate(msg) for msg in json.loads(resp.text)
]
return output_messages return output_messages

View File

@@ -8,12 +8,3 @@ class OutputMessage(BaseModel):
text: Optional[str] text: Optional[str]
reaction: Optional[str] reaction: Optional[str]
reply_to: Optional[int] reply_to: Optional[int]
@classmethod
def fromdict(cls, data: dict):
return cls(
priority=data.get("priority"),
text=data.get("text"),
reaction=data.get("reaction"),
reply_to=data.get("reply_to"),
)