fix: proxy only Anthropic via VPS; sechenov direct (VPS was banned)
This commit is contained in:
@@ -2,13 +2,11 @@ const express = require('express');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const { ProxyAgent, setGlobalDispatcher } = require('undici');
|
||||
const { ProxyAgent } = require('undici');
|
||||
|
||||
const proxyUrl = process.env.HTTPS_PROXY || process.env.HTTP_PROXY;
|
||||
if (proxyUrl) {
|
||||
setGlobalDispatcher(new ProxyAgent(proxyUrl));
|
||||
console.log(`✓ Using proxy: ${proxyUrl}`);
|
||||
}
|
||||
const anthropicAgent = proxyUrl ? new ProxyAgent(proxyUrl) : undefined;
|
||||
if (proxyUrl) console.log(`✓ Anthropic proxy: ${proxyUrl} (sechenov: direct)`);
|
||||
|
||||
const app = express();
|
||||
const PUBLIC_DIR = path.join(__dirname, 'public');
|
||||
@@ -57,6 +55,7 @@ const SYSTEM_PROMPT = [
|
||||
async function callClaude(modelId, text, accessToken) {
|
||||
return fetch('https://api.anthropic.com/v1/messages', {
|
||||
method: 'POST',
|
||||
dispatcher: anthropicAgent,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${accessToken}`,
|
||||
|
||||
Reference in New Issue
Block a user