I was trying some hacky solution involving: ``` de...
# general-english
l
I was trying some hacky solution involving:
Copy code
def generate_streaming_response(data):
    for message in data:
        json_data = message.model_dump_json()
        # logger.info(f"JSON data: {json.dumps(json_data, indent=2)}")
        yield f"data: {json_data}\n\n"

    time.sleep(5)

    for message in data:
        json_data = message.model_dump_json()
        # logger.info(f"JSON data: {json.dumps(json_data, indent=2)}")
        yield f"data: {json_data}\n\n"

.......
.......

return Response(generate_streaming_response(), content_type="text/event-stream")
i.e. first response can be "Please wait". Then time.sleep mimics the function processing. Then add output of function call However it seems vapi waits for the whole function to run (including the time) before saying the output. Any ideas why the yield output before the time.sleep isn't said before the time.sleep runs?
5 Views