Print message token by token


at the moment my tool sends a AJAX request using a PHP file that sends it to and generates a JSON message that is rendered via JavaScript.

The problem is that the output is rendered at a strech and not token-via-token.

You could i implement that?

Best regards

stream (defaults to false…)

If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message. See the OpenAI Cookbook for example code.

Here you go. Hope your weekend is going well…

1 Like