Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completion API: How to stream the response #58

Open
MdMxMyr opened this issue Jun 23, 2022 · 1 comment
Open

Completion API: How to stream the response #58

MdMxMyr opened this issue Jun 23, 2022 · 1 comment

Comments

@MdMxMyr
Copy link

MdMxMyr commented Jun 23, 2022

Are there any examples available on how to use this package when "stream" is set to "true"? I'm currently trying to make this work, but I don't know how...

Thanks!

@MdMxMyr MdMxMyr changed the title How to stream the response Completion API: How to stream the response Jun 23, 2022
@cbarber713
Copy link

I wasn't able to get it work work so I did this on the front end side:

function typeText(element, text) {
let index = 0;

let inerval = setInterval(() => {
if(index < text.length) {
element.innerHTML += text.charAt(index);
index++;
} else {
clearInterval(inerval);
}
}, 15)
}

const data = await response.json();
const parsedData = data.bot.content.trim();

typeText(messageDiv, parsedData);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants