mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2025-10-26 08:58:14 +00:00
feat(app): fix issues with model selection
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import Select from '@/components/ui/Select';
|
||||
import { ConfigModelProvider } from '@/lib/config/types';
|
||||
import { useChat } from '@/lib/hooks/useChat';
|
||||
import { useState } from 'react';
|
||||
import { toast } from 'sonner';
|
||||
|
||||
@@ -16,6 +17,7 @@ const ModelSelect = ({
|
||||
: `${localStorage.getItem('embeddingModelProviderId')}/${localStorage.getItem('embeddingModelKey')}`,
|
||||
);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const { setChatModelProvider, setEmbeddingModelProvider } = useChat();
|
||||
|
||||
const handleSave = async (newValue: string) => {
|
||||
setLoading(true);
|
||||
@@ -23,20 +25,33 @@ const ModelSelect = ({
|
||||
|
||||
try {
|
||||
if (type === 'chat') {
|
||||
localStorage.setItem('chatModelProviderId', newValue.split('/')[0]);
|
||||
localStorage.setItem(
|
||||
'chatModelKey',
|
||||
newValue.split('/').slice(1).join('/'),
|
||||
);
|
||||
const providerId = newValue.split('/')[0];
|
||||
const modelKey = newValue.split('/').slice(1).join('/');
|
||||
|
||||
localStorage.setItem('chatModelProviderId', providerId);
|
||||
localStorage.setItem('chatModelKey', modelKey);
|
||||
|
||||
setChatModelProvider({
|
||||
providerId: providerId,
|
||||
key: modelKey,
|
||||
});
|
||||
} else {
|
||||
const providerId = newValue.split('/')[0];
|
||||
const modelKey = newValue.split('/').slice(1).join('/');
|
||||
|
||||
localStorage.setItem(
|
||||
'embeddingModelProviderId',
|
||||
newValue.split('/')[0],
|
||||
providerId,
|
||||
);
|
||||
localStorage.setItem(
|
||||
'embeddingModelKey',
|
||||
newValue.split('/').slice(1).join('/'),
|
||||
modelKey,
|
||||
);
|
||||
|
||||
setEmbeddingModelProvider({
|
||||
providerId: providerId,
|
||||
key: modelKey,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error saving config:', error);
|
||||
|
||||
Reference in New Issue
Block a user