Open Yullin opened 1 year ago
Proposal: Support following openresty config In plugin proxy-control:
proxy_buffering off;
proxy_http_version 1.1;
proxy_set_header Connection "";
with those config to support http stream, in chatbot scenario
Sorry,I don't know any other easier way.
But I've fixed this problem with following action: after the backend service output the last chunk, sleep 5ms, and then close the connection.
So, now, just need to support the proposal I mentioned
proxy_buffering off; proxy_http_version 1.1; proxy_set_header Connection "";
Is there any way to dynamically change these settings on a particular route?
@qwzhou89 Currently this feature is not supported in the open source version.
enterprise: https://docs.api7.ai/hub/proxy-buffering
enterprise: https://docs.api7.ai/hub/proxy-buffering
When will the open source apisix be adapted to the SSE ?
At the moment, no plan that I'm aware of.
you can return x-accel-buffering: no
in response header from your upstream in order to disable proxy_buffering
option on nginx, it is from the documentation
Current Behavior
Scenario: The company is working on a large model, similar to a chatbot-type service like ChatGPT. The development team has set up a service and is accessing it using the following code:
Problem: In normal circumstances (accessing the development service directly), the JSON data is printed out one by one. But after going through OpenResty reverse proxy, the first few JSON data is still printed out one by one, and the last two JSON data are returned together as a single string ("{"text":"...."}{"text":"...."}"), causing json.loads to fail.
Configuration:
I have tested with HAProxy and there are no such issues.
Expected Behavior
the JSON data is printed out one by one. and I have posted this issue to openresty(https://github.com/openresty/openresty/issues/914) , maybe people here can fix this
Error Logs
No response
Steps to Reproduce
chunks = requests.post(url=url, json=data, stream=True) answer = "" for chunk in chunks.iter_content(chunk_size=None): if chunk: try: chunk = json.loads(chunk.decode('utf-8')) print(chunk) except Exception as e: print("----------------error---------------") print(chunk) print(e) print("----------------error---------------") continue