Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail if selected chat/embedding model isn't the one found on classpath #221

Merged
merged 1 commit into from
Jan 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ private <T extends ProviderHolder> String selectProvider(
requestedBeanName));
}
if (availableProviders.size() == 1) {
// user has selected a provider, but it's not the one that is available
if (userSelectedProvider.isPresent() && !availableProviders.get(0).equals(userSelectedProvider.get())) {
throw new ConfigurationException(String.format(
"A %s bean with provider=%s was requested was requested via configuration, but the only provider found on the classpath is %s.",
requestedBeanName, userSelectedProvider.get(), availableProviders.get(0)));
}
return availableProviders.get(0);
}
// multiple providers exist, so we now need the configuration to select the proper one
Expand Down Expand Up @@ -170,10 +176,16 @@ private <T extends ProviderHolder> String selectEmbeddingModelProvider(
throw new ConfigurationException(String.format(
"A %s bean was requested, but no langchain4j providers were configured and no in-process embedding model were found on the classpath. "
+
"Consider adding an extension like 'quarkus-langchain4j-openai' or one of the in-process embedding model.",
"Consider adding an extension like 'quarkus-langchain4j-openai' or one of the in-process embedding models.",
requestedBeanName));
}
if (availableProviders.size() == 1) {
// user has selected a provider, but it's not the one that is available
if (userSelectedProvider.isPresent() && !availableProviders.get(0).equals(userSelectedProvider.get())) {
throw new ConfigurationException(String.format(
"Embedding model provider %s was requested via configuration, but the only provider found on the classpath is %s.",
userSelectedProvider.get(), availableProviders.get(0)));
}
return availableProviders.get(0);
}
// multiple providers exist, so we now need the configuration to select the proper one
Expand Down
Loading