mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-30 06:15:18 +01:00
🔧 refactor: Improve Params Handling, Remove Legacy Items, & Update Configs (#6074)
* chore: include all assets for service worker, remove unused tsconfig.node.json, eslint ignore vite config * chore: exclude image files from service worker caching * refactor: simplify googleSchema transformation and error handling * fix: max output tokens cap for 3.7 models * fix: skip index fixing in CI, development, and test environments * ci: add maxOutputTokens handling tests for Claude models * refactor: drop top_k and top_p parameters for claude-3.7 in AnthropicClient and add tests for new behavior * refactor: conditionally include top_k and top_p parameters for non-claude-3.7 models * ci: add unit tests for getLLMConfig function with various model options * chore: remove all OPENROUTER_API_KEY legacy logic * refactor: optimize stream chunk handling * feat: reset model parameters button * refactor: remove unused examples field from convoSchema and presetSchema * chore: update librechat-data-provider version to 0.7.6993 * refactor: move excludedKeys set to data-provider for better reusability * feat: enhance saveMessageToDatabase to handle unset fields and fetched conversation state * feat: add 'iconURL' and 'greeting' to excludedKeys in data provider config * fix: add optional chaining to user ID retrieval in getConvo call
This commit is contained in:
parent
e14df5956a
commit
be280004cf
25 changed files with 561 additions and 238 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { RotateCcw } from 'lucide-react';
|
||||
import React, { useMemo, useState, useEffect, useCallback } from 'react';
|
||||
import { getSettingsKeys, tConvoUpdateSchema } from 'librechat-data-provider';
|
||||
import { excludedKeys, getSettingsKeys, tConvoUpdateSchema } from 'librechat-data-provider';
|
||||
import type { TPreset } from 'librechat-data-provider';
|
||||
import { SaveAsPresetDialog } from '~/components/Endpoints';
|
||||
import { useSetIndexOptions, useLocalize } from '~/hooks';
|
||||
|
|
@ -9,23 +10,6 @@ import { componentMapping } from './components';
|
|||
import { useChatContext } from '~/Providers';
|
||||
import { settings } from './settings';
|
||||
|
||||
const excludedKeys = new Set([
|
||||
'conversationId',
|
||||
'title',
|
||||
'endpoint',
|
||||
'endpointType',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'messages',
|
||||
'isArchived',
|
||||
'tags',
|
||||
'user',
|
||||
'__v',
|
||||
'_id',
|
||||
'tools',
|
||||
'model',
|
||||
]);
|
||||
|
||||
export default function Parameters() {
|
||||
const localize = useLocalize();
|
||||
const { conversation, setConversation } = useChatContext();
|
||||
|
|
@ -105,6 +89,31 @@ export default function Parameters() {
|
|||
});
|
||||
}, [parameters, setConversation]);
|
||||
|
||||
const resetParameters = useCallback(() => {
|
||||
setConversation((prev) => {
|
||||
if (!prev) {
|
||||
return prev;
|
||||
}
|
||||
|
||||
const updatedConversation = { ...prev };
|
||||
const resetKeys: string[] = [];
|
||||
|
||||
Object.keys(updatedConversation).forEach((key) => {
|
||||
if (excludedKeys.has(key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (updatedConversation[key] !== undefined) {
|
||||
resetKeys.push(key);
|
||||
delete updatedConversation[key];
|
||||
}
|
||||
});
|
||||
|
||||
logger.log('parameters', 'parameters reset, affected keys:', resetKeys);
|
||||
return updatedConversation;
|
||||
});
|
||||
}, [setConversation]);
|
||||
|
||||
const openDialog = useCallback(() => {
|
||||
const newPreset = tConvoUpdateSchema.parse({
|
||||
...conversation,
|
||||
|
|
@ -146,7 +155,17 @@ export default function Parameters() {
|
|||
);
|
||||
})}
|
||||
</div>
|
||||
<div className="mt-6 flex justify-center">
|
||||
<div className="mt-4 flex justify-center">
|
||||
<button
|
||||
type="button"
|
||||
onClick={resetParameters}
|
||||
className="btn btn-neutral flex w-full items-center justify-center gap-2 px-4 py-2 text-sm"
|
||||
>
|
||||
<RotateCcw className="h-4 w-4" aria-hidden="true" />
|
||||
{localize('com_ui_reset_var', { 0: localize('com_ui_model_parameters') })}
|
||||
</button>
|
||||
</div>
|
||||
<div className="mt-2 flex justify-center">
|
||||
<button
|
||||
onClick={openDialog}
|
||||
className="btn btn-primary focus:shadow-outline flex w-full items-center justify-center px-4 py-2 font-semibold text-white hover:bg-green-600 focus:border-green-500"
|
||||
|
|
|
|||
|
|
@ -35,10 +35,5 @@
|
|||
"test/setupTests.js",
|
||||
"env.d.ts",
|
||||
"../config/translations/**/*.ts"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.node.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Node",
|
||||
"allowSyntheticDefaultImports": true
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
||||
|
|
@ -37,13 +37,12 @@ export default defineConfig({
|
|||
},
|
||||
useCredentials: true,
|
||||
workbox: {
|
||||
globPatterns: [
|
||||
'assets/**/*.{png,jpg,svg,ico}',
|
||||
'**/*.{js,css,html,ico,woff2}',
|
||||
],
|
||||
globPatterns: ['**/*'],
|
||||
globIgnores: ['images/**/*'],
|
||||
maximumFileSizeToCacheInBytes: 4 * 1024 * 1024,
|
||||
navigateFallbackDenylist: [/^\/oauth/],
|
||||
},
|
||||
includeAssets: ['**/*'],
|
||||
manifest: {
|
||||
name: 'LibreChat',
|
||||
short_name: 'LibreChat',
|
||||
|
|
@ -70,7 +69,7 @@ export default defineConfig({
|
|||
{
|
||||
src: '/assets/icon-192x192.png',
|
||||
sizes: '192x192',
|
||||
type: 'image/png'
|
||||
type: 'image/png',
|
||||
},
|
||||
{
|
||||
src: '/assets/maskable-icon.png',
|
||||
|
|
@ -113,10 +112,7 @@ export default defineConfig({
|
|||
if (id.includes('node_modules/highlight.js')) {
|
||||
return 'markdown_highlight';
|
||||
}
|
||||
if (
|
||||
id.includes('node_modules/hast-util-raw') ||
|
||||
id.includes('node_modules/katex')
|
||||
) {
|
||||
if (id.includes('node_modules/hast-util-raw') || id.includes('node_modules/katex')) {
|
||||
return 'markdown_large';
|
||||
}
|
||||
// Group TanStack libraries together.
|
||||
|
|
@ -141,10 +137,7 @@ export default defineConfig({
|
|||
entryFileNames: 'assets/[name].[hash].js',
|
||||
chunkFileNames: 'assets/[name].[hash].js',
|
||||
assetFileNames: (assetInfo) => {
|
||||
if (
|
||||
assetInfo.names &&
|
||||
/\.(woff|woff2|eot|ttf|otf)$/.test(assetInfo.names)
|
||||
) {
|
||||
if (assetInfo.names && /\.(woff|woff2|eot|ttf|otf)$/.test(assetInfo.names)) {
|
||||
return 'assets/fonts/[name][extname]';
|
||||
}
|
||||
return 'assets/[name].[hash][extname]';
|
||||
|
|
@ -187,4 +180,4 @@ export function sourcemapExclude(opts?: SourcemapExclude): Plugin {
|
|||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue