mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-16 23:45:33 +01:00
Some checks failed
Docker Dev Branch Images Build / build (Dockerfile, lc-dev, node) (push) Waiting to run
Docker Dev Branch Images Build / build (Dockerfile.multi, lc-dev-api, api-build) (push) Waiting to run
Docker Dev Images Build / build (Dockerfile, librechat-dev, node) (push) Has been cancelled
Docker Dev Images Build / build (Dockerfile.multi, librechat-dev-api, api-build) (push) Has been cancelled
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Has been cancelled
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Has been cancelled
* feat(bedrock): add Moonshot Kimi K2 Thinking model support - Add Moonshot provider to BedrockProviders enum - Add Moonshot-specific parameter settings with 16384 default max tokens - Add conditional for anthropic_beta to only apply to Anthropic models - Kimi K2 Thinking model: moonshot.kimi-k2-thinking (256K context) * Delete add-kimi-bedrock.md * Remove comment on anthropic_beta condition Remove comment about adding anthropic_beta for Anthropic models. * chore: enum order * feat(bedrock): add tests to ensure anthropic_beta is not added to Moonshot Kimi K2 and DeepSeek models --------- Co-authored-by: Danny Avila <danacordially@gmail.com> Co-authored-by: Danny Avila <danny@librechat.ai>
136 lines
5.8 KiB
TypeScript
136 lines
5.8 KiB
TypeScript
import { bedrockInputParser } from '../src/bedrock';
|
|
import type { BedrockConverseInput } from '../src/bedrock';
|
|
|
|
describe('bedrockInputParser', () => {
|
|
describe('Model Matching for Reasoning Configuration', () => {
|
|
test('should match anthropic.claude-3-7-sonnet model', () => {
|
|
const input = {
|
|
model: 'anthropic.claude-3-7-sonnet',
|
|
};
|
|
const result = bedrockInputParser.parse(input) as BedrockConverseInput;
|
|
const additionalFields = result.additionalModelRequestFields as Record<string, unknown>;
|
|
expect(additionalFields.thinking).toBe(true);
|
|
expect(additionalFields.thinkingBudget).toBe(2000);
|
|
expect(additionalFields.anthropic_beta).toEqual(['output-128k-2025-02-19']);
|
|
});
|
|
|
|
test('should match anthropic.claude-sonnet-4 model', () => {
|
|
const input = {
|
|
model: 'anthropic.claude-sonnet-4',
|
|
};
|
|
const result = bedrockInputParser.parse(input) as BedrockConverseInput;
|
|
const additionalFields = result.additionalModelRequestFields as Record<string, unknown>;
|
|
expect(additionalFields.thinking).toBe(true);
|
|
expect(additionalFields.thinkingBudget).toBe(2000);
|
|
expect(additionalFields.anthropic_beta).toEqual(['output-128k-2025-02-19']);
|
|
});
|
|
|
|
test('should match anthropic.claude-opus-5 model', () => {
|
|
const input = {
|
|
model: 'anthropic.claude-opus-5',
|
|
};
|
|
const result = bedrockInputParser.parse(input) as BedrockConverseInput;
|
|
const additionalFields = result.additionalModelRequestFields as Record<string, unknown>;
|
|
expect(additionalFields.thinking).toBe(true);
|
|
expect(additionalFields.thinkingBudget).toBe(2000);
|
|
expect(additionalFields.anthropic_beta).toEqual(['output-128k-2025-02-19']);
|
|
});
|
|
|
|
test('should match anthropic.claude-haiku-6 model', () => {
|
|
const input = {
|
|
model: 'anthropic.claude-haiku-6',
|
|
};
|
|
const result = bedrockInputParser.parse(input) as BedrockConverseInput;
|
|
const additionalFields = result.additionalModelRequestFields as Record<string, unknown>;
|
|
expect(additionalFields.thinking).toBe(true);
|
|
expect(additionalFields.thinkingBudget).toBe(2000);
|
|
expect(additionalFields.anthropic_beta).toEqual(['output-128k-2025-02-19']);
|
|
});
|
|
|
|
test('should match anthropic.claude-4-sonnet model', () => {
|
|
const input = {
|
|
model: 'anthropic.claude-4-sonnet',
|
|
};
|
|
const result = bedrockInputParser.parse(input) as BedrockConverseInput;
|
|
const additionalFields = result.additionalModelRequestFields as Record<string, unknown>;
|
|
expect(additionalFields.thinking).toBe(true);
|
|
expect(additionalFields.thinkingBudget).toBe(2000);
|
|
expect(additionalFields.anthropic_beta).toEqual(['output-128k-2025-02-19']);
|
|
});
|
|
|
|
test('should match anthropic.claude-4.5-sonnet model', () => {
|
|
const input = {
|
|
model: 'anthropic.claude-4.5-sonnet',
|
|
};
|
|
const result = bedrockInputParser.parse(input) as BedrockConverseInput;
|
|
const additionalFields = result.additionalModelRequestFields as Record<string, unknown>;
|
|
expect(additionalFields.thinking).toBe(true);
|
|
expect(additionalFields.thinkingBudget).toBe(2000);
|
|
expect(additionalFields.anthropic_beta).toEqual(['output-128k-2025-02-19']);
|
|
});
|
|
|
|
test('should match anthropic.claude-4-7-sonnet model', () => {
|
|
const input = {
|
|
model: 'anthropic.claude-4-7-sonnet',
|
|
};
|
|
const result = bedrockInputParser.parse(input) as BedrockConverseInput;
|
|
const additionalFields = result.additionalModelRequestFields as Record<string, unknown>;
|
|
expect(additionalFields.thinking).toBe(true);
|
|
expect(additionalFields.thinkingBudget).toBe(2000);
|
|
expect(additionalFields.anthropic_beta).toEqual(['output-128k-2025-02-19']);
|
|
});
|
|
|
|
test('should not match non-Claude models', () => {
|
|
const input = {
|
|
model: 'some-other-model',
|
|
};
|
|
const result = bedrockInputParser.parse(input) as BedrockConverseInput;
|
|
expect(result.additionalModelRequestFields).toBeUndefined();
|
|
});
|
|
|
|
test('should not add anthropic_beta to Moonshot Kimi K2 models', () => {
|
|
const input = {
|
|
model: 'moonshot.kimi-k2-0711-thinking',
|
|
};
|
|
const result = bedrockInputParser.parse(input) as BedrockConverseInput;
|
|
const additionalFields = result.additionalModelRequestFields as
|
|
| Record<string, unknown>
|
|
| undefined;
|
|
expect(additionalFields?.anthropic_beta).toBeUndefined();
|
|
});
|
|
|
|
test('should not add anthropic_beta to DeepSeek models', () => {
|
|
const input = {
|
|
model: 'deepseek.deepseek-r1',
|
|
};
|
|
const result = bedrockInputParser.parse(input) as BedrockConverseInput;
|
|
const additionalFields = result.additionalModelRequestFields as
|
|
| Record<string, unknown>
|
|
| undefined;
|
|
expect(additionalFields?.anthropic_beta).toBeUndefined();
|
|
});
|
|
|
|
test('should respect explicit thinking configuration', () => {
|
|
const input = {
|
|
model: 'anthropic.claude-sonnet-4',
|
|
thinking: false,
|
|
};
|
|
const result = bedrockInputParser.parse(input) as BedrockConverseInput;
|
|
const additionalFields = result.additionalModelRequestFields as Record<string, unknown>;
|
|
expect(additionalFields.thinking).toBeUndefined();
|
|
expect(additionalFields.thinkingBudget).toBeUndefined();
|
|
});
|
|
|
|
test('should respect custom thinking budget', () => {
|
|
const input = {
|
|
model: 'anthropic.claude-sonnet-4',
|
|
thinking: true,
|
|
thinkingBudget: 3000,
|
|
};
|
|
const result = bedrockInputParser.parse(input) as BedrockConverseInput;
|
|
const additionalFields = result.additionalModelRequestFields as Record<string, unknown>;
|
|
expect(additionalFields.thinking).toBe(true);
|
|
expect(additionalFields.thinkingBudget).toBe(3000);
|
|
});
|
|
});
|
|
});
|