Skip to content

Commit

Permalink
Let Dev UI pick up a ToolProvider when it's not registered as a Supplier
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartisk committed Jan 8, 2025
1 parent a57c8bd commit 4afa2f2
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ public ChatJsonRPCService(@All List<ChatLanguageModel> models, // don't use Chat
@All List<RetrievalAugmentor> retrievalAugmentors,
ChatMemoryProvider memoryProvider,
QuarkusToolExecutorFactory toolExecutorFactory,
@All List<Supplier<ToolProvider>> toolProviders) {
@All List<Supplier<ToolProvider>> toolProvidersSuppliers,
@All List<ToolProvider> toolProviders) {
this.model = models.get(0);
this.toolProvider = getToolProvider(toolProviders);
this.toolProvider = getToolProvider(toolProvidersSuppliers, toolProviders);
this.streamingModel = streamingModels.isEmpty() ? Optional.empty() : Optional.of(streamingModels.get(0));
this.retrievalAugmentor = null;
for (Supplier<RetrievalAugmentor> supplier : retrievalAugmentorSuppliers) {
Expand Down Expand Up @@ -347,12 +348,21 @@ public void onError(Throwable error) {
});
}

private ToolProvider getToolProvider(List<Supplier<ToolProvider>> toolProviders) {
for (Supplier<ToolProvider> provider : toolProviders) {
/**
* Get the first available tool provider that we can find in the CDI container...
*/
private ToolProvider getToolProvider(List<Supplier<ToolProvider>> toolProviderSuppliers,
List<ToolProvider> toolProviders) {
for (Supplier<ToolProvider> provider : toolProviderSuppliers) {
if (provider.get() != null) {
return provider.get();
}
}
for (ToolProvider provider : toolProviders) {
if (provider != null) {
return provider;
}
}
return null;
}

Expand Down

0 comments on commit 4afa2f2

Please sign in to comment.