@@ -236,41 +236,25 @@ async def publish(
236236 self ,
237237 addr : Address ,
238238 msg : RawMessage ,
239- request : bool = False ,
240239 stream : bool = False ,
240+ request : bool = False ,
241241 reply : str = "" ,
242242 timeout : float = 0.5 ,
243243 probe : bool = True ,
244- ) -> RawMessage | None :
245- """Publish a message.
244+ ) -> AsyncIterator [ RawMessage ] | RawMessage | None :
245+ """Publish a message to the given address .
246246
247247 Args:
248248 addr (Address): The address of the agent.
249249 msg (RawMessage): The raw message to send.
250- request (bool, optional): Whether this is a request. Defaults to False.
251250 stream (bool, optional): Whether to request a streaming result. Defaults to False.
251+ request (bool, optional): Whether this is a request. Defaults to False. If `stream` is True, then this is always True.
252252 reply (str, optional): If `request` is True, then this will be the subject to reply to. Defaults to "".
253253 timeout (float, optional): If `request` is True, then this will be the timeout for the response. Defaults to 0.5.
254254 probe (bool, optional): Whether to probe the agent before sending the message. Defaults to True.
255255 """
256256 pass
257257
258- @abc .abstractmethod
259- async def publish_multi (
260- self ,
261- addr : Address ,
262- msg : RawMessage ,
263- probe : bool = True ,
264- ) -> AsyncIterator [RawMessage ]:
265- """Publish a message and wait for multiple reply messages.
266-
267- Args:
268- addr (Address): The address of the agent.
269- msg (RawMessage): The raw message to send.
270- probe (bool, optional): Whether to probe the agent before sending the message. Defaults to True.
271- """
272- pass
273-
274258 @abc .abstractmethod
275259 async def subscribe (
276260 self ,
@@ -310,20 +294,17 @@ async def run(
310294 stream : bool = False ,
311295 session_id : str = "" ,
312296 timeout : float = 0.5 ,
313- ) -> RawMessage | AsyncIterator [ RawMessage ] :
297+ ) -> AsyncIterator [ RawMessage ] | RawMessage | None :
314298 """Create an agent and run it with the given message."""
315299 if self .__runtime is None :
316300 raise ValueError (f"AgentSpec { self .name } is not registered to a runtime." )
317301
318302 session_id = session_id or uuid .uuid4 ().hex
319303 addr = Address (name = self .name , id = session_id )
320304
321- if stream :
322- return self .__runtime .channel .publish_multi (addr , msg )
323- else :
324- return await self .__runtime .channel .publish (
325- addr , msg , request = True , timeout = timeout
326- )
305+ return await self .__runtime .channel .publish (
306+ addr , msg , stream = stream , request = True , timeout = timeout
307+ )
327308
328309
329310class Runtime (abc .ABC ):
0 commit comments