-
Notifications
You must be signed in to change notification settings - Fork 197
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
Bug: requestUrl()
and server-sent events
#165
Comments
Note: I know there are other Obsidian plugins out there using the Anthropic API with streaming, so I checked one. This one solves the CORS issue in a different way, by running a proxy server with Node.js: https://github.com/logancyang/obsidian-copilot/blob/master/src/proxyServer.ts#L18 |
|
Can you give me some pointers how |
It's being delegated to the net.request Electron API. |
I'm using Obsidian's
requestUrl()
helper to bypass CORS restrictions. The API I'm calling is Anthropic's standard chat API that streams AI response chunks using server-sent events. I'm only focusing on desktop only for now, so I assumerequestUrl()
calls a Node.js or Electron networking API.I noticed that even though I have a working API request, the timing of events doesn't feel right.
Given this code (which I tried to make as short as possible, sorry!):
...what I see is that
await requestUrl()
blocks until the last server-sent event is received. In practice, streaming the response chunks doesn't feel any different than using the non-streaming API because the entire response appears at once (after a long delay).I don't think this is a problem with the
fetch-event-stream
wrapper because the blocking happens earlier, between the log linesBefore requestUrl
andAfter requestUrl
. The remaining log lines appear instantly and at the same time.I'm not sure this is a bug in itself, maybe I'm doing something wrong here? I would appreciate any help or guidance about how to use
requestUrl()
or what it's doing behind the scenes.Thank you!
The text was updated successfully, but these errors were encountered: