MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / InspectResponse

Class InspectResponse

tests/test_middleware.py:255–271  ·  view source on GitHub ↗

Records the response wrapper returned by `call_next` and passes it through.

Source from the content-addressed store, hash-verified

253
254
255class InspectResponse(Middleware):
256 """Records the response wrapper returned by `call_next` and passes it through."""
257
258 def __init__(self) -> None:
259 self.responses: list[Any] = []
260
261 @override
262 def handle(self, request: APIRequest, call_next: CallNext) -> Any:
263 response = call_next(request)
264 self.responses.append(response)
265 return response
266
267 @override
268 async def handle_async(self, request: APIRequest, call_next: AsyncCallNext) -> Any:
269 response = await call_next(request)
270 self.responses.append(response)
271 return response
272
273
274class ParseInMiddleware(Middleware):

Calls

no outgoing calls