8 months ago
I have Python FastAPI application that uses openai's chat completion api with stream. I am getting CancelledError very frequently. I also added timeout middleware with 2 mins timeout and is still same error.
The same prompts works fine on my local machine. It's happening only in Railway. I guess may have to tweak some timeout out setting in Railway. I will provide full stack trace below. Please let me know how to resolve it.
CancelledError('Cancelled by cancel scope 7fa0af45f910')Traceback (most recent call last):\n\n\n File \"/usr/local/lib/python3.10/site-packages/langchain_core/language_models/chat_models.py\", line 472, in astream\n async for chunk in self._astream(\n\n\n File \"/usr/local/lib/python3.10/site-packages/langchain_openai/chat_models/base.py\", line 1989, in astream\n async for chunk in super().astream(*args, **kwargs):\n\n\n File \"/usr/local/lib/python3.10/site-packages/langchain_openai/chat_models/base.py\", line 779, in astream\n async for chunk in response:\n\n\n File \"/usr/local/lib/python3.10/site-packages/openai/streaming.py\", line 147, in aiter\n async for item in self._iterator:\n\n\n File \"/usr/local/lib/python3.10/site-packages/openai/_streaming.py\", line 160, in stream\n async for sse in iterator:\n\n\n File \"/usr/local/lib/python3.10/site-packages/openai/_streaming.py\", line 151, in iterevents\n async for sse in self._decoder.aiter_bytes(self.response.aiter_bytes()):\n\n\n File \"/usr/local/lib/python3.10/site-packages/openai/_streaming.py
1 Replies
8 months ago
Closing out in favor of the Discord thread.
https://discord.com/channels/713503345364697088/1286883336450605178
Status changed to Closed brody • 8 months ago