mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-23 20:00:15 +01:00
✨ feat: Add Google Parameters, Ollama/Openrouter Reasoning, & UI Optimizations (#5456)
* feat: Google Model Parameters * fix: dynamic input number value, previously coerced by zod schema * refactor: support openrouter reasoning tokens and XML for thinking directive to conform to ollama * fix: virtualize combobox to prevent performance drop on re-renders of long model/agent/assistant lists * refactor: simplify Fork component by removing unnecessary chat context index * fix: prevent rendering of Thinking component when children are null * refactor: update Markdown component to replace <think> tags and simplify remarkPlugins configuration * refactor: reorder remarkPlugins to improve plugin configuration in Markdown component
This commit is contained in:
parent
7818ae5c60
commit
af430e46f4
12 changed files with 200 additions and 50 deletions
|
|
@ -2,10 +2,10 @@ import { OptionTypes } from 'librechat-data-provider';
|
|||
import type { DynamicSettingProps } from 'librechat-data-provider';
|
||||
import { useLocalize, useDebouncedInput, useParameterEffects } from '~/hooks';
|
||||
import { Label, Input, HoverCard, HoverCardTrigger } from '~/components/ui';
|
||||
import { cn, defaultTextProps } from '~/utils';
|
||||
import { useChatContext } from '~/Providers';
|
||||
import OptionHover from './OptionHover';
|
||||
import { ESide } from '~/common';
|
||||
import { cn } from '~/utils';
|
||||
|
||||
function DynamicInput({
|
||||
label = '',
|
||||
|
|
@ -50,7 +50,7 @@ function DynamicInput({
|
|||
const value = e.target.value;
|
||||
if (type === 'number') {
|
||||
if (!isNaN(Number(value))) {
|
||||
setInputValue(e);
|
||||
setInputValue(e, true);
|
||||
}
|
||||
} else {
|
||||
setInputValue(e);
|
||||
|
|
@ -70,7 +70,7 @@ function DynamicInput({
|
|||
htmlFor={`${settingKey}-dynamic-input`}
|
||||
className="text-left text-sm font-medium"
|
||||
>
|
||||
{labelCode ? localize(label) ?? label : label || settingKey}{' '}
|
||||
{labelCode ? localize(label) || label : label || settingKey}{' '}
|
||||
{showDefault && (
|
||||
<small className="opacity-40">
|
||||
(
|
||||
|
|
@ -87,7 +87,7 @@ function DynamicInput({
|
|||
disabled={readonly}
|
||||
value={inputValue ?? ''}
|
||||
onChange={handleInputChange}
|
||||
placeholder={placeholderCode ? localize(placeholder) ?? placeholder : placeholder}
|
||||
placeholder={placeholderCode ? localize(placeholder) || placeholder : placeholder}
|
||||
className={cn(
|
||||
'flex h-10 max-h-10 w-full resize-none border-none bg-surface-secondary px-3 py-2',
|
||||
)}
|
||||
|
|
@ -95,7 +95,7 @@ function DynamicInput({
|
|||
</HoverCardTrigger>
|
||||
{description && (
|
||||
<OptionHover
|
||||
description={descriptionCode ? localize(description) ?? description : description}
|
||||
description={descriptionCode ? localize(description) || description : description}
|
||||
side={ESide.Left}
|
||||
/>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import {
|
|||
ImageDetail,
|
||||
EModelEndpoint,
|
||||
openAISettings,
|
||||
googleSettings,
|
||||
BedrockProviders,
|
||||
anthropicSettings,
|
||||
} from 'librechat-data-provider';
|
||||
|
|
@ -352,6 +353,87 @@ const meta: Record<string, SettingDefinition> = {
|
|||
}),
|
||||
};
|
||||
|
||||
const google: Record<string, SettingDefinition> = {
|
||||
temperature: createDefinition(baseDefinitions.temperature, {
|
||||
default: googleSettings.temperature.default,
|
||||
range: {
|
||||
min: googleSettings.temperature.min,
|
||||
max: googleSettings.temperature.max,
|
||||
step: googleSettings.temperature.step,
|
||||
},
|
||||
}),
|
||||
topP: createDefinition(baseDefinitions.topP, {
|
||||
default: googleSettings.topP.default,
|
||||
range: {
|
||||
min: googleSettings.topP.min,
|
||||
max: googleSettings.topP.max,
|
||||
step: googleSettings.topP.step,
|
||||
},
|
||||
}),
|
||||
topK: {
|
||||
key: 'topK',
|
||||
label: 'com_endpoint_top_k',
|
||||
labelCode: true,
|
||||
description: 'com_endpoint_google_topk',
|
||||
descriptionCode: true,
|
||||
type: 'number',
|
||||
default: googleSettings.topK.default,
|
||||
range: {
|
||||
min: googleSettings.topK.min,
|
||||
max: googleSettings.topK.max,
|
||||
step: googleSettings.topK.step,
|
||||
},
|
||||
component: 'slider',
|
||||
optionType: 'model',
|
||||
columnSpan: 4,
|
||||
},
|
||||
maxOutputTokens: {
|
||||
key: 'maxOutputTokens',
|
||||
label: 'com_endpoint_max_output_tokens',
|
||||
labelCode: true,
|
||||
type: 'number',
|
||||
component: 'input',
|
||||
description: 'com_endpoint_google_maxoutputtokens',
|
||||
descriptionCode: true,
|
||||
placeholder: 'com_nav_theme_system',
|
||||
placeholderCode: true,
|
||||
default: googleSettings.maxOutputTokens.default,
|
||||
range: {
|
||||
min: googleSettings.maxOutputTokens.min,
|
||||
max: googleSettings.maxOutputTokens.max,
|
||||
step: googleSettings.maxOutputTokens.step,
|
||||
},
|
||||
optionType: 'model',
|
||||
columnSpan: 2,
|
||||
},
|
||||
};
|
||||
|
||||
const googleConfig: SettingsConfiguration = [
|
||||
librechat.modelLabel,
|
||||
librechat.promptPrefix,
|
||||
librechat.maxContextTokens,
|
||||
google.maxOutputTokens,
|
||||
google.temperature,
|
||||
google.topP,
|
||||
google.topK,
|
||||
librechat.resendFiles,
|
||||
];
|
||||
|
||||
const googleCol1: SettingsConfiguration = [
|
||||
baseDefinitions.model as SettingDefinition,
|
||||
librechat.modelLabel,
|
||||
librechat.promptPrefix,
|
||||
];
|
||||
|
||||
const googleCol2: SettingsConfiguration = [
|
||||
librechat.maxContextTokens,
|
||||
google.maxOutputTokens,
|
||||
google.temperature,
|
||||
google.topP,
|
||||
google.topK,
|
||||
librechat.resendFiles,
|
||||
];
|
||||
|
||||
const openAI: SettingsConfiguration = [
|
||||
openAIParams.chatGptLabel,
|
||||
librechat.promptPrefix,
|
||||
|
|
@ -529,6 +611,7 @@ export const settings: Record<string, SettingsConfiguration | undefined> = {
|
|||
[`${EModelEndpoint.bedrock}-${BedrockProviders.Meta}`]: bedrockGeneral,
|
||||
[`${EModelEndpoint.bedrock}-${BedrockProviders.AI21}`]: bedrockGeneral,
|
||||
[`${EModelEndpoint.bedrock}-${BedrockProviders.Amazon}`]: bedrockGeneral,
|
||||
[EModelEndpoint.google]: googleConfig,
|
||||
};
|
||||
|
||||
const openAIColumns = {
|
||||
|
|
@ -571,6 +654,10 @@ export const presetSettings: Record<
|
|||
[`${EModelEndpoint.bedrock}-${BedrockProviders.Meta}`]: bedrockGeneralColumns,
|
||||
[`${EModelEndpoint.bedrock}-${BedrockProviders.AI21}`]: bedrockGeneralColumns,
|
||||
[`${EModelEndpoint.bedrock}-${BedrockProviders.Amazon}`]: bedrockGeneralColumns,
|
||||
[EModelEndpoint.google]: {
|
||||
col1: googleCol1,
|
||||
col2: googleCol2,
|
||||
},
|
||||
};
|
||||
|
||||
export const agentSettings: Record<string, SettingsConfiguration | undefined> = Object.entries(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue