mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-23 20:00:15 +01:00
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:
parent
da3730b7d6
commit
a8babbcebf
2 changed files with 18 additions and 1 deletions
|
|
@ -64,6 +64,20 @@ describe('custom/initializeClient', () => {
|
|||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it('calls resolveHeaders with conversation ID when provided', async () => {
|
||||
const { resolveHeaders } = require('@librechat/api');
|
||||
const requestWithConversationId = {
|
||||
...mockRequest,
|
||||
body: { ...mockRequest.body, conversationId: 'existing-conversation-123' },
|
||||
};
|
||||
await initializeClient({ req: requestWithConversationId, res: mockResponse, optionsOnly: true });
|
||||
expect(resolveHeaders).toHaveBeenCalledWith(
|
||||
{ 'x-user': '{{LIBRECHAT_USER_ID}}', 'x-email': '{{LIBRECHAT_USER_EMAIL}}' },
|
||||
{ id: 'user-123', email: 'test@example.com' },
|
||||
{ LIBRECHAT_CONVERSATION_ID: 'existing-conversation-123' },
|
||||
);
|
||||
});
|
||||
|
||||
it('calls resolveHeaders with headers and user', async () => {
|
||||
const { resolveHeaders } = require('@librechat/api');
|
||||
await initializeClient({ req: mockRequest, res: mockResponse, optionsOnly: true });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue