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

Class AppendBeta

tests/test_middleware.py:135–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133
134
135class AppendBeta(Middleware):
136 def _append(self, request: APIRequest) -> APIRequest:
137 current = request.headers.get("anthropic-beta")
138 betas = f"{current},middleware-beta" if current else "middleware-beta"
139 return request.copy(headers={**request.headers, "anthropic-beta": betas})
140
141 @override
142 def handle(self, request: APIRequest, call_next: CallNext) -> Any:
143 return call_next(self._append(request))
144
145 @override
146 async def handle_async(self, request: APIRequest, call_next: AsyncCallNext) -> Any:
147 return await call_next(self._append(request))
148
149
150class RebuildRequest(Middleware):

Calls

no outgoing calls