Skip to content

Commit b73f19b

Browse files
authored
Yet another round of doc fixes (#155)
* Refactor docstrings in InputFile and InputFileDownloader classes for clarity and consistency * Update type hints in docstrings for TurnContext and ClaimsIdentity for clarity * Update type hints in AgentState and BotStatePropertyAccessor docstrings for clarity * Clarify class reference in AgentState constructor docstring
1 parent 8bc89ec commit b73f19b

File tree

3 files changed

+40
-40
lines changed

3 files changed

+40
-40
lines changed

libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/input_file.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
class InputFile:
1717
"""A file sent by the user to the bot.
1818
19-
Attributes:
20-
content (bytes): The downloaded content of the file.
21-
content_type (str): The content type of the file.
22-
content_url (Optional[str]): Optional. URL to the content of the file.
19+
:param content: The downloaded content of the file.
20+
:type content: bytes
21+
:param content_type: The content type of the file.
22+
:type content_type: str
23+
:param content_url: Optional. URL to the content of the file.
24+
:type content_url: Optional[str]
2325
"""
2426

2527
content: bytes
@@ -29,17 +31,19 @@ class InputFile:
2931

3032
class InputFileDownloader(ABC):
3133
"""
32-
A plugin responsible for downloading files relative to the current user's input.
34+
Abstract base class for a plugin responsible for downloading files provided by the user.
35+
36+
Implementations should download any files referenced by the incoming activity and return a
37+
list of :class:`InputFile` instances representing the downloaded content.
3338
"""
3439

3540
@abstractmethod
3641
async def download_files(self, context: TurnContext) -> List[InputFile]:
3742
"""
38-
Download any files relative to the current user's input.
39-
40-
Args:
41-
context (TurnContext): Context for the current turn of conversation.
43+
Download any files referenced by the incoming activity for the current turn.
4244
43-
Returns:
44-
List[InputFile]: A list of input files.
45+
:param context: The turn context for the current request.
46+
:type context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
47+
:return: A list of downloaded :class:`InputFile` objects.
48+
:rtype: list[:class:`microsoft_agents.hosting.core.app.input_file.InputFile`]
4549
"""

libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/channel_adapter.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ async def send_activities(
4040
Sends a set of activities to the user. An array of responses from the server will be returned.
4141
4242
:param context: The context object for the turn.
43-
:type context: :class:`TurnContext`
43+
:type context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
4444
:param activities: The activities to send.
4545
:type activities: list[Activity]
4646
:return:
@@ -53,7 +53,7 @@ async def update_activity(self, context: TurnContext, activity: Activity):
5353
Replaces an existing activity.
5454
5555
:param context: The context object for the turn.
56-
:type context: :class:`TurnContext`
56+
:type context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
5757
:param activity: New replacement activity.
5858
:type activity: :class:`microsoft_agents.activity.Activity`
5959
:return:
@@ -68,7 +68,7 @@ async def delete_activity(
6868
Deletes an existing activity.
6969
7070
:param context: The context object for the turn.
71-
:type context: :class:`TurnContext`
71+
:type context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
7272
:param reference: Conversation reference for the activity to delete.
7373
:type reference: :class:`microsoft_agents.activity.ConversationReference`
7474
:return:
@@ -102,7 +102,7 @@ async def continue_conversation(
102102
:param reference: A reference to the conversation to continue.
103103
:type reference: :class:`microsoft_agents.activity.ConversationReference`
104104
:param callback: The method to call for the resulting agent turn.
105-
:type callback: Callable[[TurnContext], Awaitable]
105+
:type callback: Callable[[microsoft_agents.hosting.core.turn_context.TurnContext], Awaitable]
106106
:param claims_identity: A :class:`microsoft_agents.hosting.core.ClaimsIdentity` for the conversation.
107107
:type claims_identity: :class:`microsoft_agents.hosting.core.ClaimsIdentity`
108108
:param audience:A value signifying the recipient of the proactive message.
@@ -124,11 +124,11 @@ async def continue_conversation_with_claims(
124124
to the user.
125125
126126
:param claims_identity: A :class:`microsoft_agents.hosting.core.ClaimsIdentity` for the conversation.
127-
:type claims_identity: :class:`microsoft_agents.hosting.core.ClaimsIdentity`
127+
:type claims_identity: :class:`microsoft_agents.hosting.core.authorization.ClaimsIdentity`
128128
:param continuation_activity: The activity to send.
129129
:type continuation_activity: :class:`microsoft_agents.activity.Activity`
130130
:param callback: The method to call for the resulting agent turn.
131-
:type callback: Callable[[TurnContext], Awaitable]
131+
:type callback: Callable[[microsoft_agents.hosting.core.turn_context.TurnContext], Awaitable]
132132
:param audience: A value signifying the recipient of the proactive message.
133133
:type audience: str
134134
"""
@@ -155,9 +155,9 @@ async def create_conversation(
155155
:param audience: A value signifying the recipient of the proactive message.
156156
:type audience: str
157157
:param conversation_parameters: The information to use to create the conversation
158-
:type conversation_parameters: :class:`microsoft_agents.activity.models.ConversationParameters`
158+
:type conversation_parameters: :class:`microsoft_agents.activity.ConversationParameters`
159159
:param callback: The method to call for the resulting agent turn.
160-
:type callback: Callable[[TurnContext], Awaitable]
160+
:type callback: Callable[[microsoft_agents.hosting.core.turn_context.TurnContext], Awaitable]
161161
162162
:raises: Exception - Not implemented or when the implementation fails.
163163
@@ -222,7 +222,7 @@ async def run_pipeline(
222222
the end of the chain.
223223
224224
:param context: The context object for the turn.
225-
:type context: :class:`TurnContext`
225+
:type context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
226226
:param callback: A callback method to run at the end of the pipeline.
227227
:type callback: Callable[[TurnContext], Awaitable]
228228
:return:

libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/state/agent_state.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ class AgentState:
6868

6969
def __init__(self, storage: Storage, context_service_key: str):
7070
"""
71-
Initializes a new instance of the :class:`AgentState` class.
71+
Initializes a new instance of the :class:`microsoft_agents.hosting.core.state.agent_state.AgentState` class.
7272
7373
:param storage: The storage layer this state management object will use to store and retrieve state
7474
:type storage: :class:`microsoft_agents.hosting.core.storage.Storage`
75-
:param context_service_key: The key for the state cache for this :class:`AgentState`
75+
:param context_service_key: The key for the state cache for this :class:`microsoft_agents.hosting.core.state.agent_state.AgentState`
7676
:type context_service_key: str
7777
7878
.. remarks::
@@ -93,19 +93,19 @@ def get_cached_state(self, turn_context: TurnContext) -> CachedAgentState:
9393
from the turn context.
9494
9595
:param turn_context: The context object for this turn.
96-
:type turn_context: :class:`TurnContext`
96+
:type turn_context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
9797
:return: The cached agent state instance.
9898
"""
9999
return turn_context.turn_state.get(self._context_service_key)
100100

101101
def create_property(self, name: str) -> StatePropertyAccessor:
102102
"""
103-
Creates a property definition and registers it with this :class:`AgentState`.
103+
Creates a property definition and registers it with this :class:`microsoft_agents.hosting.core.state.agent_state.AgentState`.
104104
105105
:param name: The name of the property
106106
:type name: str
107107
:return: If successful, the state property accessor created
108-
:rtype: :class:`StatePropertyAccessor`
108+
:rtype: :class:`microsoft_agents.hosting.core.state.state_property_accessor.StatePropertyAccessor`
109109
"""
110110
if not name or not name.strip():
111111
raise ValueError(
@@ -123,7 +123,7 @@ async def load(self, turn_context: TurnContext, force: bool = False) -> None:
123123
Reads the current state object and caches it in the context object for this turn.
124124
125125
:param turn_context: The context object for this turn
126-
:type turn_context: :class:`TurnContext`
126+
:type turn_context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
127127
:param force: Optional, true to bypass the cache
128128
:type force: bool
129129
"""
@@ -141,7 +141,7 @@ async def save(self, turn_context: TurnContext, force: bool = False) -> None:
141141
If the state has changed, it saves the state cached in the current context for this turn.
142142
143143
:param turn_context: The context object for this turn
144-
:type turn_context: :class:`TurnContext`
144+
:type turn_context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
145145
:param force: Optional, true to save state to storage whether or not there are changes
146146
:type force: bool
147147
"""
@@ -157,7 +157,7 @@ def clear(self, turn_context: TurnContext):
157157
Clears any state currently stored in this state scope.
158158
159159
:param turn_context: The context object for this turn
160-
:type turn_context: :class:`TurnContext`
160+
:type turn_context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
161161
162162
:return: None
163163
@@ -174,7 +174,7 @@ async def delete(self, turn_context: TurnContext) -> None:
174174
Deletes any state currently stored in this state scope.
175175
176176
:param turn_context: The context object for this turn
177-
:type turn_context: :class:`TurnContext`
177+
:type turn_context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
178178
179179
:return: None
180180
"""
@@ -200,7 +200,7 @@ def get_value(
200200
Gets the value of the specified property in the turn context.
201201
202202
:param turn_context: The context object for this turn
203-
:type turn_context: :class:`TurnContext`
203+
:type turn_context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
204204
:param property_name: The property name
205205
:type property_name: str
206206
@@ -235,8 +235,6 @@ def delete_value(self, property_name: str) -> None:
235235
"""
236236
Deletes a property from the state cache in the turn context.
237237
238-
:param turn_context: The context object for this turn
239-
:type turn_context: :class:`TurnContext`
240238
:param property_name: The name of the property to delete
241239
:type property_name: str
242240
@@ -254,8 +252,6 @@ def set_value(self, property_name: str, value: StoreItem) -> None:
254252
"""
255253
Sets a property to the specified value in the turn context.
256254
257-
:param turn_context: The context object for this turn
258-
:type turn_context: :class:`TurnContext`
259255
:param property_name: The property name
260256
:type property_name: str
261257
:param value: The value to assign to the property
@@ -272,15 +268,15 @@ def set_value(self, property_name: str, value: StoreItem) -> None:
272268

273269
class BotStatePropertyAccessor(StatePropertyAccessor):
274270
"""
275-
Defines methods for accessing a state property created in a :class:`AgentState` object.
271+
Defines methods for accessing a state property created in a :class:`microsoft_agents.hosting.core.state.agent_state.AgentState` object.
276272
"""
277273

278274
def __init__(self, agent_state: AgentState, name: str):
279275
"""
280-
Initializes a new instance of the :class:`BotStatePropertyAccessor` class.
276+
Initializes a new instance of the :class:`microsoft_agents.hosting.core.state.agent_state.BotStatePropertyAccessor` class.
281277
282278
:param agent_state: The state object to access
283-
:type agent_state: :class:`AgentState`
279+
:type agent_state: :class:`microsoft_agents.hosting.core.state.agent_state.AgentState`
284280
:param name: The name of the state property to access
285281
:type name: str
286282
@@ -304,7 +300,7 @@ async def delete(self, turn_context: TurnContext) -> None:
304300
Deletes the property.
305301
306302
:param turn_context: The context object for this turn
307-
:type turn_context: :class:`TurnContext`
303+
:type turn_context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
308304
"""
309305
await self._agent_state.load(turn_context, False)
310306
self._agent_state.delete_value(self._name)
@@ -320,7 +316,7 @@ async def get(
320316
Gets the property value.
321317
322318
:param turn_context: The context object for this turn
323-
:type turn_context: :class:`TurnContext`
319+
:type turn_context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
324320
:param default_value_or_factory: Defines the default value for the property
325321
"""
326322
await self._agent_state.load(turn_context, False)
@@ -355,7 +351,7 @@ async def set(self, turn_context: TurnContext, value: StoreItem) -> None:
355351
Sets the property value.
356352
357353
:param turn_context: The context object for this turn
358-
:type turn_context: :class:`TurnContext`
354+
:type turn_context: :class:`microsoft_agents.hosting.core.turn_context.TurnContext`
359355
360356
:param value: The value to assign to the property
361357
"""

0 commit comments

Comments
 (0)