mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-22 03:10:15 +01:00
* feat(azureOpenAI): allow switching deployment name by model name * ci: add unit tests and throw error on no api key provided to avoid API call * fix(gptPlugins/initializeClient): check if azure is enabled; ci: add unit tests for gptPlugins/initializeClient * fix(ci): fix expected error message for partial regex match: unexpected token
42 lines
865 B
JavaScript
42 lines
865 B
JavaScript
const { ChatOpenAI } = require('langchain/chat_models/openai');
|
|
const { sanitizeModelName } = require('../../../utils');
|
|
|
|
function createLLM({
|
|
modelOptions,
|
|
configOptions,
|
|
callbacks,
|
|
streaming = false,
|
|
openAIApiKey,
|
|
azure = {},
|
|
}) {
|
|
let credentials = { openAIApiKey };
|
|
let configuration = {
|
|
apiKey: openAIApiKey,
|
|
};
|
|
|
|
let azureOptions = {};
|
|
if (azure) {
|
|
credentials = {};
|
|
configuration = {};
|
|
azureOptions = azure;
|
|
azureOptions.azureOpenAIApiDeploymentName = sanitizeModelName(modelOptions.modelName);
|
|
}
|
|
|
|
// console.debug('createLLM: configOptions');
|
|
// console.debug(configOptions);
|
|
|
|
return new ChatOpenAI(
|
|
{
|
|
streaming,
|
|
verbose: true,
|
|
credentials,
|
|
configuration,
|
|
...azureOptions,
|
|
...modelOptions,
|
|
callbacks,
|
|
},
|
|
configOptions,
|
|
);
|
|
}
|
|
|
|
module.exports = createLLM;
|