mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-20 18:30:15 +01:00
🏷️ fix: Ensure modelLabel Field Usage for ModelSpecs pt. 2 (#4225)
* fix: ensure modelSpec presets have endpointType defined, add `modelLabel` to openAISchema * chore: bump rollup due to CVE-2024-47068
This commit is contained in:
parent
6f498eee0f
commit
ba1014a038
5 changed files with 97 additions and 99 deletions
|
|
@ -11,7 +11,7 @@ import MenuButton from './MenuButton';
|
|||
import ModelSpecs from './ModelSpecs';
|
||||
import store from '~/store';
|
||||
|
||||
export default function ModelSpecsMenu({ modelSpecs }: { modelSpecs: TModelSpec[] }) {
|
||||
export default function ModelSpecsMenu({ modelSpecs }: { modelSpecs?: TModelSpec[] }) {
|
||||
const { conversation } = useChatContext();
|
||||
const { newConversation } = useNewConvo();
|
||||
|
||||
|
|
@ -23,7 +23,8 @@ export default function ModelSpecsMenu({ modelSpecs }: { modelSpecs: TModelSpec[
|
|||
const { preset } = spec;
|
||||
preset.iconURL = getModelSpecIconURL(spec);
|
||||
preset.spec = spec.name;
|
||||
const { endpoint: newEndpoint } = preset;
|
||||
const { endpoint } = preset;
|
||||
const newEndpoint = endpoint ?? '';
|
||||
if (!newEndpoint) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -42,6 +43,10 @@ export default function ModelSpecsMenu({ modelSpecs }: { modelSpecs: TModelSpec[
|
|||
endpointsConfig,
|
||||
});
|
||||
|
||||
if (newEndpointType) {
|
||||
preset.endpointType = newEndpointType;
|
||||
}
|
||||
|
||||
const isModular = isCurrentModular && isNewModular && shouldSwitch;
|
||||
if (isExistingConversation && isModular) {
|
||||
template.endpointType = newEndpointType as EModelEndpoint | undefined;
|
||||
|
|
@ -87,7 +92,7 @@ export default function ModelSpecsMenu({ modelSpecs }: { modelSpecs: TModelSpec[
|
|||
endpointsConfig={endpointsConfig}
|
||||
/>
|
||||
<Portal>
|
||||
{modelSpecs && modelSpecs?.length && (
|
||||
{modelSpecs && modelSpecs.length && (
|
||||
<div
|
||||
style={{
|
||||
position: 'fixed',
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ export default function useSelectMention({
|
|||
}: {
|
||||
presets?: TPreset[];
|
||||
modelSpecs: TModelSpec[];
|
||||
assistantMap: TAssistantsMap;
|
||||
assistantMap?: TAssistantsMap;
|
||||
newConversation: ConvoGenerator;
|
||||
endpointsConfig: TEndpointsConfig;
|
||||
}) {
|
||||
|
|
@ -40,7 +40,8 @@ export default function useSelectMention({
|
|||
const { preset } = spec;
|
||||
preset.iconURL = getModelSpecIconURL(spec);
|
||||
preset.spec = spec.name;
|
||||
const { endpoint: newEndpoint } = preset;
|
||||
const { endpoint } = preset;
|
||||
const newEndpoint = endpoint ?? '';
|
||||
if (!newEndpoint) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -59,6 +60,10 @@ export default function useSelectMention({
|
|||
endpointsConfig,
|
||||
});
|
||||
|
||||
if (newEndpointType) {
|
||||
preset.endpointType = newEndpointType;
|
||||
}
|
||||
|
||||
const isModular = isCurrentModular && isNewModular && shouldSwitch;
|
||||
if (isExistingConversation && isModular) {
|
||||
template.endpointType = newEndpointType as EModelEndpoint | undefined;
|
||||
|
|
@ -94,7 +99,8 @@ export default function useSelectMention({
|
|||
};
|
||||
|
||||
const onSelectEndpoint = useCallback(
|
||||
(newEndpoint?: EModelEndpoint | string | null, kwargs: Kwargs = {}) => {
|
||||
(_newEndpoint?: EModelEndpoint | string | null, kwargs: Kwargs = {}) => {
|
||||
const newEndpoint = _newEndpoint ?? '';
|
||||
if (!newEndpoint) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -113,12 +119,14 @@ export default function useSelectMention({
|
|||
endpointsConfig,
|
||||
});
|
||||
|
||||
if (kwargs.model) {
|
||||
template.model = kwargs.model;
|
||||
const model = kwargs.model ?? '';
|
||||
if (model) {
|
||||
template.model = model;
|
||||
}
|
||||
|
||||
if (kwargs.assistant_id) {
|
||||
template.assistant_id = kwargs.assistant_id;
|
||||
const assistant_id = kwargs.assistant_id ?? '';
|
||||
if (assistant_id) {
|
||||
template.assistant_id = assistant_id;
|
||||
}
|
||||
|
||||
if (isExistingConversation && isCurrentModular && isNewModular && shouldSwitch) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue