mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-18 10:03:27 +00:00
fix(ai): Fix browser compatibility for Anthropic OAuth tokens
- Check if process exists before modifying process.env - Prevents errors in browser environments - Maintains OAuth token functionality in Node.js
This commit is contained in:
parent
add1b76b6c
commit
cf35215686
2 changed files with 89 additions and 86 deletions
|
|
@ -48,7 +48,10 @@ export class AnthropicLLM implements LLM<AnthropicLLMOptions> {
|
|||
"anthropic-beta": "oauth-2025-04-20,fine-grained-tool-streaming-2025-05-14",
|
||||
};
|
||||
|
||||
process.env.ANTHROPIC_API_KEY = undefined;
|
||||
// Clear the env var if we're in Node.js to prevent SDK from using it
|
||||
if (typeof process !== "undefined" && process.env) {
|
||||
process.env.ANTHROPIC_API_KEY = undefined;
|
||||
}
|
||||
this.client = new Anthropic({ apiKey: null, authToken: apiKey, baseURL: model.baseUrl, defaultHeaders });
|
||||
this.isOAuthToken = true;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue