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

WIP: Allow streaming from custom http endpoints #1219

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

justyns
Copy link
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?

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.

1 participant