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

Add a dangerouslyAllowBrowser option to allow running in the browser #248

Closed
jkomoros opened this issue Jan 6, 2024 · 2 comments
Closed
Assignees
Labels
enhancement New feature or request

Comments

@jkomoros
Copy link

jkomoros commented Jan 6, 2024

I know that #28 and #219 were both closed as not planned.

In many cases it doesn't make sense to call directly from a browser environment because it could expose the secret API key.

However there are some valid use cases, especially adjacent to open source and tinkerers, where a "BYOKey" pattern makes sense. This happens when for example the project is open source, and the creator cannot and should not pay for API use on behalf of users. The user wouldn't want to give their API key directly to the creator of the service to be passed with a proxy, because who knows what the proxy is doing with that key. In this limited case, it makes sense for the webapp be constructed to store the users' API key in localStorage and only send it directly to Anthropic. This kind of set up allows a lot more tinkering-style apps to be built that cannot handle the marginal costs of completions on behalf of their users.

For example, I have built https://github.com/jkomoros/code-sprouts to support OpenAI, but also want to extend it to support Anthropic too.

Obviously, this is a potential footgun if used insecurely.

OpenAI has resolved this issue by having a dangerouslyAllowBrowser key that must be provided to run in a browser context. Something like that could allow this use case while minimizing potential misuse.

jkomoros added a commit to jkomoros/code-sprouts that referenced this issue Jan 6, 2024
Note that it doesn't actually work yet because of anthropics/anthropic-sdk-typescript#248, anthropic doesn't allow running in the browser.

But hte machinery is useful for other providers at least...

It's effectively disabled and hidden in the UI currently.

Merge branch 'anthropic'

* anthropic: (26 commits)
  Make it so Anthropic is hidden from the dialog to start because it doesn't yet run in browser.
  Make it so other providers are hidden.
  Skip empty chunks in conversationTurn.
  SET_API_KEY --> SET_API_KEYS.
  Tweak a weird race issue in sprout-view.
  Fixed a bug where if you had api keys for two providers set it would double run a sprout.
  Make it so if a sprout already has finish(), then streamWillStart will call stopStreaming immediately.
  Make the submit button force close the dialog too.
  Update the model requirements updating to be a subset of the modelProvider that has explicitly or implicitly already been set.
  AIProvider's methods override the modelRequirements to add the subset of models we actually have keys for.
  modelMatches allows specifying modelProvider, a single item or an array.
  Fix a bug introduced in bac7ad3 where the api key isn't persisted to local storage.
  Allow forcing open the API keys dialog.
  Fix a serious bug / infinite loop when setting an API key introduced in bac7ad3
  Render controls for multiple api key providers in the dialog.
  Fixed a bug where selectAPIKeysDialogAutoOpen logic was backwards.
  wire in apikeys to dialog.
  Wire in the notion of forcing open API key dialog.
  A layer of indirection of whether to open the apikeys dialog.
  sprout-view behavior stores and handles all kinds of APIKeys now.
  ...
@rattrayalex rattrayalex added the enhancement New feature or request label Jan 10, 2024
@rattrayalex
Copy link
Collaborator

Unfortunately Anthropic continues to have no plans to change this. We'll be sure to update the issues here if & when this changes.

@rattrayalex rattrayalex closed this as not planned Won't fix, can't repro, duplicate, stale Jan 10, 2024
@StudentoTechnologies
Copy link

I also need this dangerouslyAllowBrowser thing. Many developers and customers need it, as can be seen in many forums and discussions. I really can't find logic in Anthropic's decision to reject feature that so many people ask for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants