mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-24 04:10:15 +01:00
🛠️ fix: Error Message Parsing and ChatOpenAI credentials (#1482)
* refactor(createLLM): ensure ChatOpenAI class always uses client-defined openAIApiKey; move typedefs to main def file * refactor(useSSE): improve error message parsing in error handler
This commit is contained in:
parent
d6d3d2ba13
commit
4befee829b
3 changed files with 47 additions and 35 deletions
|
|
@ -2,38 +2,6 @@ const { ChatOpenAI } = require('langchain/chat_models/openai');
|
|||
const { sanitizeModelName } = require('../../../utils');
|
||||
const { isEnabled } = require('../../../server/utils');
|
||||
|
||||
/**
|
||||
* @typedef {Object} ModelOptions
|
||||
* @property {string} modelName - The name of the model.
|
||||
* @property {number} [temperature] - The temperature setting for the model.
|
||||
* @property {number} [presence_penalty] - The presence penalty setting.
|
||||
* @property {number} [frequency_penalty] - The frequency penalty setting.
|
||||
* @property {number} [max_tokens] - The maximum number of tokens to generate.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ConfigOptions
|
||||
* @property {string} [basePath] - The base path for the API requests.
|
||||
* @property {Object} [baseOptions] - Base options for the API requests, including headers.
|
||||
* @property {Object} [httpAgent] - The HTTP agent for the request.
|
||||
* @property {Object} [httpsAgent] - The HTTPS agent for the request.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} Callbacks
|
||||
* @property {Function} [handleChatModelStart] - A callback function for handleChatModelStart
|
||||
* @property {Function} [handleLLMEnd] - A callback function for handleLLMEnd
|
||||
* @property {Function} [handleLLMError] - A callback function for handleLLMError
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} AzureOptions
|
||||
* @property {string} [azureOpenAIApiKey] - The Azure OpenAI API key.
|
||||
* @property {string} [azureOpenAIApiInstanceName] - The Azure OpenAI API instance name.
|
||||
* @property {string} [azureOpenAIApiDeploymentName] - The Azure OpenAI API deployment name.
|
||||
* @property {string} [azureOpenAIApiVersion] - The Azure OpenAI API version.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a new instance of a language model (LLM) for chat interactions.
|
||||
*
|
||||
|
|
@ -96,6 +64,7 @@ function createLLM({
|
|||
configuration,
|
||||
...azureOptions,
|
||||
...modelOptions,
|
||||
...credentials,
|
||||
callbacks,
|
||||
},
|
||||
configOptions,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue