File tree Expand file tree Collapse file tree
Client/microsoft-agents-connector/microsoft/agents/connector/client
Core/microsoft-agents-core/microsoft/agents/core/models Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818 ConversationsResult ,
1919 PagedMembersResult ,
2020)
21- from microsoft .agents .authorization import (
22- AccessTokenProviderBase ,
23- )
2421from microsoft .agents .connector import ConnectorClientBase
2522from ..attachments_base import AttachmentsBase
2623from ..conversations_base import ConversationsBase
@@ -179,15 +176,16 @@ async def reply_to_activity(
179176 by_alias = True , exclude_unset = True , exclude_none = True , mode = "json"
180177 ),
181178 ) as response :
179+ result = await response .json () if response .content_length else {}
180+
182181 if response .status >= 400 :
183- logger .error (f"Error replying to activity: { response .status } " )
182+ logger .error (f"Error replying to activity: { result or response .status } " )
184183 response .raise_for_status ()
185184
186- data = await response .json () if response .content_length else {}
187185 logger .info (
188- f"Reply to conversation/activity: { data .get ('id' )} , { activity_id } "
186+ f"Reply to conversation/activity: { result .get ('id' )} , { activity_id } "
189187 )
190- return ResourceResponse .model_validate (data )
188+ return ResourceResponse .model_validate (result )
191189
192190 async def send_to_conversation (
193191 self , conversation_id : str , body : Activity
Original file line number Diff line number Diff line change 1- from typing import Any
1+ from typing import Any , Optional
2+
3+ from pydantic import model_serializer , model_validator
24from .agents_model import AgentsModel , ConfigDict
5+ from pydantic .alias_generators import to_camel , to_snake
36from ._type_aliases import NonEmptyString
47
58
@@ -18,3 +21,18 @@ class Entity(AgentsModel):
1821 def additional_properties (self ) -> dict [str , Any ]:
1922 """Returns the set of properties that are not None."""
2023 return self .model_extra
24+
25+ @model_validator (mode = "before" )
26+ @classmethod
27+ def to_snake_for_all (cls , data ):
28+ ret = {to_snake (k ): v for k , v in data .items ()}
29+ return ret
30+
31+ @model_serializer (mode = "plain" )
32+ def to_camel_for_all (self , config ):
33+ if config .by_alias :
34+ new_data = {}
35+ for k , v in self :
36+ new_data [to_camel (k )] = v
37+ return new_data
38+ return {k : v for k , v in self }
You can’t perform that action at this time.
0 commit comments