feat(ws-connector): fix `undefined` chat model
This commit is contained in:
parent
cbce39a5dd
commit
08379fcad5
|
@ -54,13 +54,26 @@ const useSocket = (
|
||||||
).then(async (res) => await res.json());
|
).then(async (res) => await res.json());
|
||||||
|
|
||||||
const chatModelProviders = providers.chatModelProviders;
|
const chatModelProviders = providers.chatModelProviders;
|
||||||
const embeddingModelProviders = providers.embeddingModelProviders;
|
|
||||||
|
chatModelProvider = Object.keys(chatModelProviders)[0];
|
||||||
|
|
||||||
|
if (chatModelProvider === 'custom_openai') {
|
||||||
|
toast.error(
|
||||||
|
'Seems like you are using the custom OpenAI provider, please open the settings and configure the API key and base URL',
|
||||||
|
);
|
||||||
|
setError(true);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
chatModel = Object.keys(chatModelProviders[chatModelProvider])[0];
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!chatModelProviders ||
|
!chatModelProviders ||
|
||||||
Object.keys(chatModelProviders).length === 0
|
Object.keys(chatModelProviders).length === 0
|
||||||
)
|
)
|
||||||
return toast.error('No chat models available');
|
return toast.error('No chat models available');
|
||||||
|
}
|
||||||
|
|
||||||
|
const embeddingModelProviders = providers.embeddingModelProviders;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!embeddingModelProviders ||
|
!embeddingModelProviders ||
|
||||||
|
@ -68,9 +81,6 @@ const useSocket = (
|
||||||
)
|
)
|
||||||
return toast.error('No embedding models available');
|
return toast.error('No embedding models available');
|
||||||
|
|
||||||
chatModelProvider = Object.keys(chatModelProviders)[0];
|
|
||||||
chatModel = Object.keys(chatModelProviders[chatModelProvider])[0];
|
|
||||||
|
|
||||||
embeddingModelProvider = Object.keys(embeddingModelProviders)[0];
|
embeddingModelProvider = Object.keys(embeddingModelProviders)[0];
|
||||||
embeddingModel = Object.keys(
|
embeddingModel = Object.keys(
|
||||||
embeddingModelProviders[embeddingModelProvider],
|
embeddingModelProviders[embeddingModelProvider],
|
||||||
|
@ -106,6 +116,7 @@ const useSocket = (
|
||||||
|
|
||||||
if (
|
if (
|
||||||
chatModelProvider &&
|
chatModelProvider &&
|
||||||
|
chatModelProvider != 'custom_openai' &&
|
||||||
!chatModelProviders[chatModelProvider][chatModel]
|
!chatModelProviders[chatModelProvider][chatModel]
|
||||||
) {
|
) {
|
||||||
chatModel = Object.keys(chatModelProviders[chatModelProvider])[0];
|
chatModel = Object.keys(chatModelProviders[chatModelProvider])[0];
|
||||||
|
@ -187,6 +198,13 @@ const useSocket = (
|
||||||
console.log('[DEBUG] closed');
|
console.log('[DEBUG] closed');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ws.addEventListener('message', (e) => {
|
||||||
|
const data = JSON.parse(e.data);
|
||||||
|
if (data.type === 'error') {
|
||||||
|
toast.error(data.data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
setWs(ws);
|
setWs(ws);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue