🤖 feat: Enhance Assistant Model Handling for Model Specs (#4390)

* chore: cleanup type issues in client/src/utils/endpoints

* refactor: use Constant enum for 'new' conversationId

* refactor: select assistant model if not provided for model spec
This commit is contained in:
Danny Avila 2024-10-11 14:20:32 +02:00 committed by GitHub
parent 2846779603
commit bab0152c58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 12 deletions

View file

@ -6,6 +6,7 @@ import {
} from 'librechat-data-provider/react-query';
import { useNavigate } from 'react-router-dom';
import {
Constants,
FileSources,
isParamEndpoint,
LocalStorageKeys,
@ -116,7 +117,7 @@ const useNewConvo = (index = 0) => {
) ?? assistants[0]?.id;
}
if (currentAssistantId && isAssistantEndpoint && conversation.conversationId === 'new') {
if (currentAssistantId && isAssistantEndpoint && conversation.conversationId === Constants.NEW_CONVO) {
const assistant = assistants.find((asst) => asst.id === currentAssistantId);
conversation.model = assistant?.model;
updateLastSelectedModel({
@ -147,12 +148,12 @@ const useNewConvo = (index = 0) => {
clearAllLatestMessages();
}
if (conversation.conversationId === 'new' && !modelsData) {
if (conversation.conversationId === Constants.NEW_CONVO && !modelsData) {
const appTitle = localStorage.getItem(LocalStorageKeys.APP_TITLE) ?? '';
if (appTitle) {
document.title = appTitle;
}
navigate('/c/new');
navigate(`/c/${Constants.NEW_CONVO}`);
}
clearTimeout(timeoutIdRef.current);
@ -189,12 +190,12 @@ const useNewConvo = (index = 0) => {
isParamEndpoint(_template.endpoint ?? '', _template.endpointType ?? '') === true ||
isParamEndpoint(_preset?.endpoint ?? '', _preset?.endpointType ?? '');
const template =
paramEndpoint === true && templateConvoId && templateConvoId === 'new'
paramEndpoint === true && templateConvoId && templateConvoId === Constants.NEW_CONVO
? { endpoint: _template.endpoint }
: _template;
const conversation = {
conversationId: 'new',
conversationId: Constants.NEW_CONVO as string,
title: 'New Chat',
endpoint: null,
...template,