mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-14 23:21:35 +00:00
Merge pull request #3174 from jmandel/fix-claude-streaming
fix: Stream completion responses from anthropic. (Fix #3129)
This commit is contained in:
commit
dc932ac518
2 changed files with 7 additions and 3 deletions
|
|
@ -258,8 +258,9 @@ class AnthropicChatCompletion(BaseLLM):
|
|||
self.async_handler = AsyncHTTPHandler(
|
||||
timeout=httpx.Timeout(timeout=600.0, connect=5.0)
|
||||
)
|
||||
data["stream"] = True
|
||||
response = await self.async_handler.post(
|
||||
api_base, headers=headers, data=json.dumps(data)
|
||||
api_base, headers=headers, data=json.dumps(data), stream=True
|
||||
)
|
||||
|
||||
if response.status_code != 200:
|
||||
|
|
|
|||
|
|
@ -41,13 +41,16 @@ class AsyncHTTPHandler:
|
|||
data: Optional[Union[dict, str]] = None, # type: ignore
|
||||
params: Optional[dict] = None,
|
||||
headers: Optional[dict] = None,
|
||||
stream: Optional[bool] = False
|
||||
):
|
||||
response = await self.client.post(
|
||||
req = self.client.build_request(
|
||||
"POST",
|
||||
url,
|
||||
data=data, # type: ignore
|
||||
params=params,
|
||||
headers=headers,
|
||||
headers=headers
|
||||
)
|
||||
response = await self.client.send(req, stream=stream)
|
||||
return response
|
||||
|
||||
def __del__(self) -> None:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue