Skip to content

Commit

Permalink
Make the WebSearchTool class a bean if we pick it up
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartisk committed Aug 30, 2024
1 parent b9c9cfc commit 2643945
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public void telemetry(Capabilities capabilities, BuildProducer<AdditionalBeanBui
@Record(ExecutionTime.STATIC_INIT)
public void handleTools(CombinedIndexBuildItem indexBuildItem,
ToolsRecorder recorder,
BuildProducer<AdditionalBeanBuildItem> additionalBeanProducer,
RecorderContext recorderContext,
BuildProducer<BytecodeTransformerBuildItem> transformerProducer,
BuildProducer<GeneratedClassBuildItem> generatedClassProducer,
Expand Down Expand Up @@ -176,6 +177,14 @@ public void handleTools(CombinedIndexBuildItem indexBuildItem,
boolean ignoreToolMethod = ignoreToolMethod(toolMethod, index);
if (ignoreToolMethod) {
continue;
} else {
// The WebSearchTool class isn't a CDI bean, so if
// we consider it as a tool, we have to also turn it into one
if (LangChain4jDotNames.WEB_SEARCH_TOOL.equals(className)) {
additionalBeanProducer.produce(AdditionalBeanBuildItem.builder()
.addBeanClass(className.toString())
.setUnremovable().build());
}
}

AnnotationValue nameValue = instance.value("name");
Expand Down

0 comments on commit 2643945

Please sign in to comment.