feat(providers): add error handling
This commit is contained in:
parent
ec91289c0c
commit
fd65af53c3
|
@ -10,22 +10,26 @@ export const getAvailableProviders = async () => {
|
||||||
const models = {};
|
const models = {};
|
||||||
|
|
||||||
if (openAIApiKey) {
|
if (openAIApiKey) {
|
||||||
models['openai'] = {
|
try {
|
||||||
'gpt-3.5-turbo': new ChatOpenAI({
|
models['openai'] = {
|
||||||
openAIApiKey,
|
'gpt-3.5-turbo': new ChatOpenAI({
|
||||||
modelName: 'gpt-3.5-turbo',
|
openAIApiKey,
|
||||||
temperature: 0.7,
|
modelName: 'gpt-3.5-turbo',
|
||||||
}),
|
temperature: 0.7,
|
||||||
'gpt-4': new ChatOpenAI({
|
}),
|
||||||
openAIApiKey,
|
'gpt-4': new ChatOpenAI({
|
||||||
modelName: 'gpt-4',
|
openAIApiKey,
|
||||||
temperature: 0.7,
|
modelName: 'gpt-4',
|
||||||
}),
|
temperature: 0.7,
|
||||||
embeddings: new OpenAIEmbeddings({
|
}),
|
||||||
openAIApiKey,
|
embeddings: new OpenAIEmbeddings({
|
||||||
modelName: 'text-embedding-3-large',
|
openAIApiKey,
|
||||||
}),
|
modelName: 'text-embedding-3-large',
|
||||||
};
|
}),
|
||||||
|
};
|
||||||
|
} catch (err) {
|
||||||
|
console.log(`Error loading OpenAI models: ${err}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ollamaEndpoint) {
|
if (ollamaEndpoint) {
|
||||||
|
@ -50,7 +54,7 @@ export const getAvailableProviders = async () => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(`Error loading Ollama models: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue