mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-26 12:16:13 +01:00
Added Reverse Proxy for Anthropic (#1106)
* Update AnthropicClient.js Added BaseURL * Update .env.example Added ANTHROPIC_REVERSE_PROXY ENV * Update initializeClient.js Added Reverse_Proxy * Update .env.example * Update initializeClient.js * Update AnthropicClient.js * Update .env.example Request * Update initializeClient.js Mae ANTHROPIC_REVERSE_PROXY let instead of const * fix: lint errors, refactor(initializeClient) * chore: change casing of reverseProxy --------- Co-authored-by: Marco Beretta <81851188+Berry-13@users.noreply.github.com> Co-authored-by: Danny Avila <110412045+danny-avila@users.noreply.github.com>
This commit is contained in:
parent
b7dcc4264d
commit
d043a849a9
3 changed files with 24 additions and 10 deletions
|
|
@ -9,10 +9,13 @@ const AI_PROMPT = '\n\nAssistant:';
|
|||
const tokenizersCache = {};
|
||||
|
||||
class AnthropicClient extends BaseClient {
|
||||
constructor(apiKey, options = {}, cacheOptions = {}) {
|
||||
constructor(apiKey, options = {}, cacheOptions = {}, baseURL) {
|
||||
super(apiKey, options, cacheOptions);
|
||||
this.apiKey = apiKey || process.env.ANTHROPIC_API_KEY;
|
||||
this.sender = 'Anthropic';
|
||||
if (baseURL) {
|
||||
this.baseURL = baseURL;
|
||||
}
|
||||
this.userLabel = HUMAN_PROMPT;
|
||||
this.assistantLabel = AI_PROMPT;
|
||||
this.setOptions(options);
|
||||
|
|
@ -78,10 +81,10 @@ class AnthropicClient extends BaseClient {
|
|||
}
|
||||
|
||||
getClient() {
|
||||
if (this.options.reverseProxyUrl) {
|
||||
if (this.baseURL) {
|
||||
return new Anthropic({
|
||||
apiKey: this.apiKey,
|
||||
baseURL: this.options.reverseProxyUrl,
|
||||
baseURL: this.baseURL,
|
||||
});
|
||||
} else {
|
||||
return new Anthropic({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue