-
Notifications
You must be signed in to change notification settings - Fork 238
Description
When sending a stream=true request to optiLLM, the service encounters the following error:
{"error":"Object of type Stream is not JSON serializable"}
This error suggests that optiLLM is not properly handling streamed responses from liteLLM or OpenAI GPT-4o. Instead of processing the stream incrementally, it attempts to serialize the raw stream object directly into JSON, which causes the serialization failure.
Steps to Reproduce:
Send a POST request to optiLLM with the following payload:
{
"model": "gpt-4o",
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "Write a Python program to build an RL model using only numpy." }
],
"max_tokens": 1000,
"stream": true
}
Observe the error response:
{"error":"Object of type Stream is not JSON serializable"}
Expected Behavior:
The optiLLM service should handle streamed responses by:
- Iterating through the stream of chunks from liteLLM or OpenAI.
- Processing each chunk incrementally and forwarding it to the next layer (e.g., AnythingLLM).
Additional Context:
- The following pipeline works properly: User -> AnythingLLM -> liteLLM -> openai/gpt-4o
- The problem seems specific to how optiLLM handles the streamed response from liteLLM.
Severity:
High - This issue blocks the usage of stream=true functionality, which is critical for incremental responses in real-time applications.