feat: app module

This commit is contained in:
archer
2023-06-27 20:41:36 +08:00
parent 7e6272ca1b
commit 4c54e1821b
17 changed files with 2059 additions and 121 deletions

View 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 || ''
}
};
};