feat: app module
This commit is contained in:
25
client/src/service/ai/openai.ts
Normal file
25
client/src/service/ai/openai.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Configuration, OpenAIApi } from 'openai';
|
||||
|
||||
export const getSystemOpenAiKey = () => {
|
||||
return process.env.ONEAPI_KEY || '';
|
||||
};
|
||||
|
||||
export const getOpenAIApi = () => {
|
||||
return new OpenAIApi(
|
||||
new Configuration({
|
||||
basePath: process.env.ONEAPI_URL
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
/* openai axios config */
|
||||
export const axiosConfig = () => {
|
||||
return {
|
||||
baseURL: process.env.ONEAPI_URL, // 此处仅对非 npm 模块有效
|
||||
httpsAgent: global.httpsAgent,
|
||||
headers: {
|
||||
Authorization: `Bearer ${getSystemOpenAiKey()}`,
|
||||
auth: process.env.OPENAI_BASE_URL_AUTH || ''
|
||||
}
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user