"Error decoding stream response" on Completed OpenAI compatible stream requests
Context I have a custom worker on serverless, I am streaming a response from async OpenAI python client.
Error When making requests on the OpenAI compatible API endpoint, non-streaming is fine, but stream requests always return with: - Response code: 200 - Body just text:
"Error decoding stream response"
"Error decoding stream response"
I attached the run status results, which show the expected output and Completed status
async def async_handler(event): job_input = JobInput(**event["input"]) openai_input = job_input.openai_input response = await self.openai_client.chat.completions.create(**openai_input) if "stream" in openai_input and openai_input["stream"] == True: async for chunk in response: # Only contain JSON serializable types yield chunk.to_dict(mode="json") else: print(f"Response: {response}") yield response.to_dict(mode="json")runpod.serverless.start( { "handler": async_handler, "return_aggregate_stream": True, })
async def async_handler(event): job_input = JobInput(**event["input"]) openai_input = job_input.openai_input response = await self.openai_client.chat.completions.create(**openai_input) if "stream" in openai_input and openai_input["stream"] == True: async for chunk in response: # Only contain JSON serializable types yield chunk.to_dict(mode="json") else: print(f"Response: {response}") yield response.to_dict(mode="json")runpod.serverless.start( { "handler": async_handler, "return_aggregate_stream": True, })
I cannot reproduce the error when running the pod locally and making requests to
/runsync
/runsync
with the matching input data, any insight would be helpful, not sure if there's an additional layer of decoding or deserializing in the API that isn't happy with the streaming responses