AI stream to content script

I am creating a chrome extension which is a content script, I want to stream my AI response and display it token by token. I am able to get the stream with POST request using background script but don't know how to get it to content script token by token by using res.send() or something similar.
5 Replies
Sam
Sam2mo ago
I would think the best way to stream data from your BGSW to a content script would be VIA a Port. You can subscribe to the ports onMessage event.
Vishal
VishalOP2mo ago
Yep, I tried it, works fine. ☺️ Thanks ✨
Sam
Sam5w ago
Awesome! Yeah I saw the message in the main chat and someone provided with a code snippet.
Arcane
Arcane5w ago
@Sam has reached level 8. GG!
Vishal
VishalOP5w ago
Yep ☺️
Want results from more Discord servers?
Add your server