Add OPENAI_CUSTOM_CHAT_MODEL configuration option

This commit is contained in:
ckt1031 2024-05-02 18:55:05 +08:00
parent 57ee62f3af
commit e6365c8ac6
4 changed files with 24 additions and 0 deletions

View file

@ -6,12 +6,14 @@ import {
getOllamaApiEndpoint,
getOpenaiApiKey,
getOpenaiBaseUrl,
getOpenaiCustomChatModel,
} from '../config';
import logger from '../utils/logger';
export const getAvailableProviders = async () => {
const openAIApiKey = getOpenaiApiKey();
const openAIBaseUrl = getOpenaiBaseUrl();
const openAICustomChatModel = getOpenaiCustomChatModel();
const groqApiKey = getGroqApiKey();
const ollamaEndpoint = getOllamaApiEndpoint();
@ -50,6 +52,20 @@ export const getAvailableProviders = async () => {
baseURL: openAIBaseUrl,
},
),
...(openAICustomChatModel.length > 0
? {
openAICustomChatModel: new ChatOpenAI(
{
openAIApiKey,
modelName: openAICustomChatModel,
temperature: 0.7,
},
{
baseURL: openAIBaseUrl,
},
),
}
: {}),
embeddings: new OpenAIEmbeddings(
{
openAIApiKey,