feat: Add conversation ID support to custom endpoint headers

- Add LIBRECHAT_CONVERSATION_ID to customUserVars when provided
- Pass conversation ID to header resolution for dynamic headers
- Add comprehensive test coverage

Enables custom endpoints to access conversation context using {{LIBRECHAT_CONVERSATION_ID}} placeholder.
This commit is contained in:
Gopal Sharma 2025-07-22 20:32:05 +05:30 committed by Gopal Sharma
parent da3730b7d6
commit a8babbcebf
2 changed files with 18 additions and 1 deletions

View file

@ -28,7 +28,10 @@ const initializeClient = async ({ req, res, endpointOption, optionsOnly, overrid
const CUSTOM_API_KEY = extractEnvVariable(endpointConfig.apiKey);
const CUSTOM_BASE_URL = extractEnvVariable(endpointConfig.baseURL);
let resolvedHeaders = resolveHeaders(endpointConfig.headers, req.user);
const customUserVars = {};
customUserVars.LIBRECHAT_CONVERSATION_ID = req.body.conversationId;
let resolvedHeaders = resolveHeaders(endpointConfig.headers, req.user, customUserVars);
if (CUSTOM_API_KEY.match(envVarRegex)) {
throw new Error(`Missing API Key for ${endpoint}.`);