mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-03-02 14:20:18 +01:00
🧠 feat: Add reasoning_effort configuration for Bedrock models (#11991)
* 🧠 feat: Add reasoning_effort configuration for Bedrock models - Introduced a new `reasoning_effort` setting in the Bedrock configuration, allowing users to specify the reasoning level for supported models. - Updated the input parser to map `reasoning_effort` to `reasoning_config` for Moonshot and ZAI models, ensuring proper handling of reasoning levels. - Enhanced tests to validate the mapping of `reasoning_effort` to `reasoning_config` and to ensure correct behavior for various model types, including Anthropic models. - Updated translation files to include descriptions for the new configuration option. * chore: Update translation keys for Bedrock reasoning configuration - Renamed translation key from `com_endpoint_bedrock_reasoning_config` to `com_endpoint_bedrock_reasoning_effort` for consistency with the new configuration setting. - Updated the parameter settings to reflect the change in the description key, ensuring accurate mapping in the application. * 🧪 test: Enhance bedrockInputParser tests for reasoning_config handling - Added tests to ensure that stale `reasoning_config` is stripped when switching models from Moonshot to Meta and ZAI to DeepSeek. - Included additional tests to verify that `reasoning_effort` values of "none", "minimal", and "xhigh" do not forward to `reasoning_config` for Moonshot and ZAI models. - Improved coverage for the bedrockInputParser functionality to ensure correct behavior across various model configurations. * feat: Introduce Bedrock reasoning configuration and update input parser - Added a new `BedrockReasoningConfig` enum to define reasoning levels: low, medium, and high. - Updated the `bedrockInputParser` to utilize the new reasoning configuration, ensuring proper handling of `reasoning_effort` values. - Enhanced logic to validate `reasoning_effort` against the defined configuration values before assigning to `reasoning_config`. - Improved code clarity with additional comments and refactored conditions for better readability.
This commit is contained in:
parent
cde5079886
commit
e6b324b259
6 changed files with 326 additions and 9 deletions
|
|
@ -722,4 +722,66 @@ describe('initializeBedrock', () => {
|
|||
expect(amrf.effort).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Bedrock reasoning_effort for Moonshot/ZAI models', () => {
|
||||
it('should map reasoning_effort to reasoning_config for Moonshot Kimi K2.5', async () => {
|
||||
const params = createMockParams({
|
||||
model_parameters: {
|
||||
model: 'moonshotai.kimi-k2.5',
|
||||
reasoning_effort: 'high',
|
||||
},
|
||||
});
|
||||
|
||||
const result = (await initializeBedrock(params)) as BedrockLLMConfigResult;
|
||||
const amrf = result.llmConfig.additionalModelRequestFields as Record<string, unknown>;
|
||||
|
||||
expect(amrf.reasoning_config).toBe('high');
|
||||
expect(amrf.reasoning_effort).toBeUndefined();
|
||||
expect(amrf.thinking).toBeUndefined();
|
||||
expect(amrf.anthropic_beta).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should map reasoning_effort to reasoning_config for ZAI GLM', async () => {
|
||||
const params = createMockParams({
|
||||
model_parameters: {
|
||||
model: 'zai.glm-4.7',
|
||||
reasoning_effort: 'medium',
|
||||
},
|
||||
});
|
||||
|
||||
const result = (await initializeBedrock(params)) as BedrockLLMConfigResult;
|
||||
const amrf = result.llmConfig.additionalModelRequestFields as Record<string, unknown>;
|
||||
|
||||
expect(amrf.reasoning_config).toBe('medium');
|
||||
expect(amrf.reasoning_effort).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should not include reasoning_config when reasoning_effort is unset', async () => {
|
||||
const params = createMockParams({
|
||||
model_parameters: {
|
||||
model: 'moonshotai.kimi-k2.5',
|
||||
reasoning_effort: '',
|
||||
},
|
||||
});
|
||||
|
||||
const result = (await initializeBedrock(params)) as BedrockLLMConfigResult;
|
||||
|
||||
expect(result.llmConfig.additionalModelRequestFields).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should not map reasoning_effort to reasoning_config for Anthropic models', async () => {
|
||||
const params = createMockParams({
|
||||
model_parameters: {
|
||||
model: 'anthropic.claude-opus-4-6-v1',
|
||||
reasoning_effort: 'high',
|
||||
},
|
||||
});
|
||||
|
||||
const result = (await initializeBedrock(params)) as BedrockLLMConfigResult;
|
||||
const amrf = result.llmConfig.additionalModelRequestFields as Record<string, unknown>;
|
||||
|
||||
expect(amrf.reasoning_config).toBeUndefined();
|
||||
expect(amrf.thinking).toEqual({ type: 'adaptive' });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue