🤖 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

@ -87,22 +87,23 @@ const firstLocalConvoKey = LocalStorageKeys.LAST_CONVO_SETUP + '_0';
* update without updating last convo setup when same endpoint */
export function updateLastSelectedModel({
endpoint,
model,
model = '',
}: {
endpoint: string;
model: string | undefined;
model?: string;
}) {
if (!model) {
return;
}
const lastConversationSetup = JSON.parse(localStorage.getItem(firstLocalConvoKey) || '{}');
/* Note: an empty string value is possible */
const lastConversationSetup = JSON.parse((localStorage.getItem(firstLocalConvoKey) ?? '{}') || '{}');
if (lastConversationSetup.endpoint === endpoint) {
lastConversationSetup.model = model;
localStorage.setItem(firstLocalConvoKey, JSON.stringify(lastConversationSetup));
}
const lastSelectedModels = JSON.parse(localStorage.getItem(LocalStorageKeys.LAST_MODEL) || '{}');
const lastSelectedModels = JSON.parse((localStorage.getItem(LocalStorageKeys.LAST_MODEL) ?? '{}') || '{}');
lastSelectedModels[endpoint] = model;
localStorage.setItem(LocalStorageKeys.LAST_MODEL, JSON.stringify(lastSelectedModels));
}