During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "/usr/local/lib/python3.10/dist-packages/gradio/queueing.py", line 536, in process_events

    response = await route_utils.call_process_api(

  File "/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py", line 322, in call_process_api

    output = await app.get_blocks().process_api(

  File "/usr/local/lib/python3.10/dist-packages/gradio/blocks.py", line 1935, in process_api

    result = await self.call_function(

  File "/usr/local/lib/python3.10/dist-packages/gradio/blocks.py", line 1532, in call_function

    prediction = await utils.async_iteration(iterator)

  File "/usr/local/lib/python3.10/dist-packages/gradio/utils.py", line 671, in async_iteration

    return await iterator.__anext__()

  File "/usr/local/lib/python3.10/dist-packages/gradio/utils.py", line 776, in asyncgen_wrapper

    response = await iterator.__anext__()

  File "/usr/local/lib/python3.10/dist-packages/gradio/chat_interface.py", line 653, in streamfn

    first_response = await async_iteration(generator)

  File "/usr/local/lib/python3.10/dist-packages/gradio/utils.py", line 671, in async_iteration

    return await iterator.__anext__()

  File "/usr/local/lib/python3.10/dist-packages/gradio/utils.py", line 664, in anext

    return await anyio.to_thread.run_sync(

  File "/usr/local/lib/python3.10/dist-packages/anyio/to_thread.py", line 56, in run_sync

    return await get_async_backend().run_sync_in_worker_thread(

  File "/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py", line 2405, in run_sync_in_worker_thread

    return await future

  File "/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py", line 914, in run

    result = context.run(func, *args)

  File "/usr/local/lib/python3.10/dist-packages/gradio/utils.py", line 647, in run_sync_iterator_async

    return next(iterator)

  File "/aphrodite-workspace/1.py", line 24, in slow_echo

    for line in response.iter_lines():

  File "/usr/local/lib/python3.10/dist-packages/requests/models.py", line 869, in iter_lines

    for chunk in self.iter_content(

  File "/usr/local/lib/python3.10/dist-packages/requests/models.py", line 822, in generate

    raise ChunkedEncodingError(e)

requests.exceptions.ChunkedEncodingError: Response ended prematurely

pelase fix this error

use this code 

import time

import gradio as gr

import requests

import json

API_URL = "http://0.0.0.0:2242/v1/completions"

API_KEY = "sk-empty"

def slow_echo(message, history):

    headers = {

        "Authorization": f"Bearer {API_KEY}",

        "Content-Type": "application/json"

    }

    data = {

        "model": "AiCloser/Qwen2.5-32B-AGI",

        "prompt": message,

        "max_tokens": 5000,

        "temperature": 0,

        "stream": True

    }

    response = requests.post(API_URL, headers=headers, json=data, stream=True)

    

    partial_response = ""

    for line in response.iter_lines():

        if line:

            decoded_line = line.decode('utf-8').replace("data: ", "")

            if decoded_line.strip():

                json_line = json.loads(decoded_line)

                text = json_line['choices'][0]['text']

                partial_response += text

                yield partial_response

gr.ChatInterface(slow_echo).launch(share=True)