perf: 专线代理配置

This commit is contained in:
archer
2023-04-08 20:49:15 +08:00
parent 52d00d0562
commit 705ac1c27e
15 changed files with 52 additions and 32 deletions

View File

@@ -85,7 +85,7 @@ export const openaiCreateEmbedding = async ({
},
{
timeout: 60000,
httpsAgent
httpsAgent: httpsAgent(isPay)
}
)
.then((res) => ({

View File

@@ -83,15 +83,8 @@ export const authOpenApiKey = async (req: NextApiRequest) => {
};
/* 代理 */
export const httpsAgent =
process.env.AXIOS_PROXY_HOST && process.env.AXIOS_PROXY_PORT
? tunnel.httpsOverHttp({
proxy: {
host: process.env.AXIOS_PROXY_HOST,
port: +process.env.AXIOS_PROXY_PORT
}
})
: undefined;
export const httpsAgent = (fast: boolean) =>
fast ? global.httpsAgentFast : global.httpsAgentNormal;
/* tokens 截断 */
export const openaiChatFilter = (prompts: ChatItemType[], maxTokens: number) => {