MCPcopy Index your code
hub / github.com/commandoperator/cmdop-sdk / collect

Method collect

python/src/cmdop/streaming.py:220–232  ·  view source on GitHub ↗

Drain to the final text (the ``done`` frame's text, else accumulated event deltas). Raises :class:`AgentStreamError` on an error outcome.

(self)

Source from the content-addressed store, hash-verified

218 )
219
220 async def collect(self) -> str:
221 """Drain to the final text (the ``done`` frame's text, else accumulated
222 event deltas). Raises :class:`AgentStreamError` on an error outcome."""
223 text = ""
224 async for frame in self:
225 if isinstance(frame, EventFrame):
226 payload = frame.payload if isinstance(frame.payload, dict) else {}
227 text += payload.get("delta") or payload.get("text") or ""
228 elif isinstance(frame, DoneFrame):
229 return frame.text or text
230 elif isinstance(frame, ErrorFrame):
231 raise _stream_error(frame.code, frame.message)
232 return text
233
234 def _require_id(self) -> int:
235 if self._id is None:

Callers 1

Calls 2

_stream_errorFunction · 0.85
getMethod · 0.45

Tested by 1