mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-01 20:27:45 +00:00
feat: openai base url
This commit is contained in:
@@ -8,7 +8,8 @@ import mongoose from 'mongoose';
|
||||
|
||||
export const getOpenAIApi = (apiKey: string) => {
|
||||
const configuration = new Configuration({
|
||||
apiKey
|
||||
apiKey,
|
||||
basePath: process.env.OPENAI_BASE_URL || 'https://api.openai.com/v1'
|
||||
});
|
||||
|
||||
return new OpenAIApi(configuration, undefined);
|
||||
|
@@ -2,7 +2,7 @@ import type { NextApiResponse } from 'next';
|
||||
import type { PassThrough } from 'stream';
|
||||
import { createParser, ParsedEvent, ReconnectInterval } from 'eventsource-parser';
|
||||
import { getOpenAIApi } from '@/service/utils/auth';
|
||||
import { httpsAgent } from './tools';
|
||||
import { axiosConfig } from './tools';
|
||||
import { User } from '../models/user';
|
||||
import { formatPrice } from '@/utils/user';
|
||||
import { embeddingModel } from '@/constants/model';
|
||||
@@ -85,7 +85,7 @@ export const openaiCreateEmbedding = async ({
|
||||
},
|
||||
{
|
||||
timeout: 60000,
|
||||
httpsAgent: httpsAgent(isPay)
|
||||
...axiosConfig
|
||||
}
|
||||
)
|
||||
.then((res) => ({
|
||||
|
@@ -84,9 +84,10 @@ export const authOpenApiKey = async (req: NextApiRequest) => {
|
||||
}
|
||||
};
|
||||
|
||||
/* 代理 */
|
||||
export const httpsAgent = (fast: boolean) =>
|
||||
fast ? global.httpsAgentFast : global.httpsAgentNormal;
|
||||
/* openai axios config */
|
||||
export const axiosConfig = {
|
||||
httpsAgent: global.httpsAgent
|
||||
};
|
||||
|
||||
/* delete invalid symbol */
|
||||
const simplifyStr = (str: string) =>
|
||||
|
Reference in New Issue
Block a user