one-api 为什么/v1/chat/completions使用Transfer-Encoding: chunked

brgchamk  于 2个月前  发布在  其他
关注(0)|答案(1)|浏览(42)

fastgpt将/v1/chat/completions发送给one-api,然后one-api将其分发到下游的open-ai兼容API服务器。
在fastgpt的原始HTTP请求中,包含了Content-Length标头,但是one-api并没有使用这个标头,而是使用了Transfer-Encoding: chunked。
然而,text-generation-webui的open-ai兼容API服务器的实现中,/app/extensions/openai/script.py需要依赖于这个Content-Length标头。因此,text-generation-webui在收到/v1/chat/completions后会报错。

def do_POST(self):
        debug_msg(self.requestline)
        debug_msg(self.headers)

        content_length = int(self.headers['Content-Length'])
        body = json.loads(self.rfile.read(content_length).decode('utf-8'))

请问为什么one-api使用Transfer-Encoding: chunked?
谢谢!

相关问题