Skip to content

WIP: Allow streaming from custom http endpoints#1219

Closed
justyns wants to merge 3 commits intosilverbulletmd:mainfrom
justyns:httpstreaming
Closed

WIP: Allow streaming from custom http endpoints#1219
justyns wants to merge 3 commits intosilverbulletmd:mainfrom
justyns:httpstreaming

Conversation

@justyns
Copy link
Copy Markdown
Contributor

@justyns justyns commented Jan 23, 2025

  • Updates hono to latest version, using jsr. I didn't notice any issues with this, but maybe needs more testing?
  • service_worker sends custom http endpoint requests to the server
  • serveCustomEndpoints() tries to handle streaming responses now

I'd appreciate input on these changes. My goal is to have the ai plug be able to proxy all requests (optionally, configured per model) through the server, regardless of whether the client is in sync mode or not.

You can see the plug changes here: https://github.com/justyns/silverbullet-ai/pull/77/files

After testing a few different methods, this seems to work but is also a little hacky. I wanted the plug proxyHandler() to handle all of the fetch logic, but I could not figure out how to return something like ReadableStream to serveCustomEndpoints(). I'm assuming the response from the plug gets serialized somewhere so we lose the stream. My workaround was to have the plug return the info needed to initiate a new fetch request from serveCustomEndpoints and then stream directly from it.

This does work, but I'm not sure if we want to turn serveCustomEndpoints into a psuedo proxy like this? Is there a way for a plug to register an endpoint without using the event system?

@zefhemel zefhemel closed this Sep 29, 2025
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

Successfully merging this pull request may close these issues.

2 participants