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

Support http string streaming requests #474

Open
nearnshaw opened this issue Feb 26, 2025 · 0 comments
Open

Support http string streaming requests #474

nearnshaw opened this issue Feb 26, 2025 · 0 comments
Labels
2-medium Important issues we must fix, but not as important as high! enhancement New feature or request typescript Includes significant typescript work (more than just a new component or field)

Comments

@nearnshaw
Copy link
Member

nearnshaw commented Feb 26, 2025

It's possible to receive http responses as a string stream, which has some interesting applications. The most useful one is with AI NPCs, as we would not need to wait for the entire response to be ready, we can instead display the text as it is being generated, character by character.
This is also a lot simpler to implement than using an intermediary websockets server, as we did in the past.

This approach takes over an http channel while waiting for more responses, so it's not something to use abundantly, but since a scene can have up to 5 open http requests at a time, it's reasonable to dedicate one to an AI communication.

Will (ex Content Team) shared some insights that might be helpful to tackle this:

The js runtime uses undici https://github.com/decentraland/js-sdk-toolchain/blob/main/packages/%40dcl/sdk-commands/src/components/fetch.ts

Unidici supports body

https://undici.nodejs.org/#/?id=responsebody

It is exposed here

https://github.com/decentraland/js-sdk-toolchain/blob/c459a2f95046d73bbfa2142d06e4395f4f60a4b5/packages/%40dcl/js-runtime/index.d.ts#L35

And I think all they have to do is add body to the interface to expose it on the SDK?

https://github.com/decentraland/js-sdk-toolchain/blob/c459a2f95046d73bbfa2142d06e4395f4f60a4b5/packages/%40dcl/js-runtime/index.d.ts#L35

@nearnshaw nearnshaw converted this from a draft issue Feb 26, 2025
@nearnshaw nearnshaw added enhancement New feature or request typescript Includes significant typescript work (more than just a new component or field) 2-medium Important issues we must fix, but not as important as high! labels Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2-medium Important issues we must fix, but not as important as high! enhancement New feature or request typescript Includes significant typescript work (more than just a new component or field)
Projects
Status: Todo
Development

No branches or pull requests

1 participant