decentraland / decentraland/creator-hub

Support http string streaming requests

Open
#474 0 comments 0 reactions 0 assignees View on GitHub
2-medium enhancement typescript
Dominant language
TypeScript
Stars
7
Forks
14
Avg merge
2d 8h
Merged PRs (30d)
44

Description

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.