ianarawjo / ianarawjo/ChainForge
Suggestion: Use "anthropic-dangerous-direct-browser-access" for Anthropic to resolve cors issues
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 256
- Avg merge
- 4h 40m
- Merged PRs (30d)
- 22
Description
**Is your feature request related to a problem? Please describe.**
Currently API Calls are routed through the flask backend. Anthropic has kind of silently introduced the ["anthropic-dangerous-direct-browser-access" header](https://github.com/anthropics/anthropic-sdk-typescript/pull/504#issuecomment-2306060472) to allow cors calls from everywhere
**Describe the solution you'd like**
Harmonize the calls to providers. For anthropic it could now be like
```
// Make a REST call to Anthropic
// Repeat call n times, waiting for each response to come in:
const responses: Array = [];
while (responses.length < n) {
// Abort if canceled
if (should_cancel && should_cancel()) throw new UserForcedPrematureExit();
// Direct API call to Anthropic (harmonized with other providers)
const url = `https://api.anthropic.com/v1/${
use_messages_api ? "messages" : "complete"
}`;
const headers = {
"x-api-key": ANTHROPIC_API_KEY,
"anthropic-version": "2023-06-01",
"content-type": "application/json",
"anthropic-dangerous-direct-browser-access": "true", // Enable direct browser access
};
[...]
```
**Additional context**
[See this Issue for details.](https://github.com/anthropics/anthropic-sdk-typescript/pull/504)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.