mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-22 11:20:15 +01:00
🆔 feat: Add User ID to Anthropic API Payload as Metadata (#9174)
This commit is contained in:
parent
49cd3894aa
commit
ce19abc968
2 changed files with 8 additions and 1 deletions
|
|
@ -39,8 +39,9 @@ const initializeClient = async ({ req, res, endpointOption, overrideModel, optio
|
||||||
if (optionsOnly) {
|
if (optionsOnly) {
|
||||||
clientOptions = Object.assign(
|
clientOptions = Object.assign(
|
||||||
{
|
{
|
||||||
reverseProxyUrl: ANTHROPIC_REVERSE_PROXY ?? null,
|
|
||||||
proxy: PROXY ?? null,
|
proxy: PROXY ?? null,
|
||||||
|
userId: req.user.id,
|
||||||
|
reverseProxyUrl: ANTHROPIC_REVERSE_PROXY ?? null,
|
||||||
modelOptions: endpointOption?.model_parameters ?? {},
|
modelOptions: endpointOption?.model_parameters ?? {},
|
||||||
},
|
},
|
||||||
clientOptions,
|
clientOptions,
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ const { checkPromptCacheSupport, getClaudeHeaders, configureReasoning } = requir
|
||||||
* @param {number} [options.modelOptions.topK] - Controls the number of top tokens to consider.
|
* @param {number} [options.modelOptions.topK] - Controls the number of top tokens to consider.
|
||||||
* @param {string[]} [options.modelOptions.stop] - Sequences where the API will stop generating further tokens.
|
* @param {string[]} [options.modelOptions.stop] - Sequences where the API will stop generating further tokens.
|
||||||
* @param {boolean} [options.modelOptions.stream] - Whether to stream the response.
|
* @param {boolean} [options.modelOptions.stream] - Whether to stream the response.
|
||||||
|
* @param {string} options.userId - The user ID for tracking and personalization.
|
||||||
* @param {string} [options.proxy] - Proxy server URL.
|
* @param {string} [options.proxy] - Proxy server URL.
|
||||||
* @param {string} [options.reverseProxyUrl] - URL for a reverse proxy, if used.
|
* @param {string} [options.reverseProxyUrl] - URL for a reverse proxy, if used.
|
||||||
*
|
*
|
||||||
|
|
@ -47,6 +48,11 @@ function getLLMConfig(apiKey, options = {}) {
|
||||||
maxTokens:
|
maxTokens:
|
||||||
mergedOptions.maxOutputTokens || anthropicSettings.maxOutputTokens.reset(mergedOptions.model),
|
mergedOptions.maxOutputTokens || anthropicSettings.maxOutputTokens.reset(mergedOptions.model),
|
||||||
clientOptions: {},
|
clientOptions: {},
|
||||||
|
invocationKwargs: {
|
||||||
|
metadata: {
|
||||||
|
user_id: options.userId,
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
requestOptions = configureReasoning(requestOptions, systemOptions);
|
requestOptions = configureReasoning(requestOptions, systemOptions);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue