feat(providers): add error handling

This commit is contained in:
ItzCrazyKns 2024-04-21 20:52:47 +05:30
parent ec91289c0c
commit fd65af53c3
No known key found for this signature in database
GPG Key ID: 8162927C7CCE3065
1 changed files with 21 additions and 17 deletions

View File

@ -10,22 +10,26 @@ export const getAvailableProviders = async () => {
const models = {};
if (openAIApiKey) {
models['openai'] = {
'gpt-3.5-turbo': new ChatOpenAI({
openAIApiKey,
modelName: 'gpt-3.5-turbo',
temperature: 0.7,
}),
'gpt-4': new ChatOpenAI({
openAIApiKey,
modelName: 'gpt-4',
temperature: 0.7,
}),
embeddings: new OpenAIEmbeddings({
openAIApiKey,
modelName: 'text-embedding-3-large',
}),
};
try {
models['openai'] = {
'gpt-3.5-turbo': new ChatOpenAI({
openAIApiKey,
modelName: 'gpt-3.5-turbo',
temperature: 0.7,
}),
'gpt-4': new ChatOpenAI({
openAIApiKey,
modelName: 'gpt-4',
temperature: 0.7,
}),
embeddings: new OpenAIEmbeddings({
openAIApiKey,
modelName: 'text-embedding-3-large',
}),
};
} catch (err) {
console.log(`Error loading OpenAI models: ${err}`);
}
}
if (ollamaEndpoint) {
@ -50,7 +54,7 @@ export const getAvailableProviders = async () => {
});
}
} catch (err) {
console.log(err);
console.log(`Error loading Ollama models: ${err}`);
}
}