Skip to content

Commit

Permalink
fix(ai): Make DefaultToolCallResultConverter work with GraalVM
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasVitale committed Jan 12, 2025
1 parent 65287dc commit e8af82c
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.arconia.ai.tools.aot;

import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;

import io.arconia.ai.tools.execution.DefaultToolCallResultConverter;

/**
* Registers runtime hints for the tool calling APIs.
*/
public class ToolRuntimeHints implements RuntimeHintsRegistrar {

@Override
public void registerHints(@NonNull RuntimeHints hints, @Nullable ClassLoader classLoader) {
var mcs = MemberCategory.values();
hints.reflection().registerType(DefaultToolCallResultConverter.class, mcs);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
org.springframework.aot.hint.RuntimeHintsRegistrar=\
io.arconia.ai.tools.aot.ToolRuntimeHints
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.arconia.ai.tools.aot;

import org.junit.jupiter.api.Test;
import org.springframework.aot.hint.RuntimeHints;

import io.arconia.ai.tools.execution.DefaultToolCallResultConverter;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.springframework.aot.hint.predicate.RuntimeHintsPredicates.reflection;

/**
* Unit tests for {@link ToolRuntimeHints}.
*/
class ToolRuntimeHintsTests {

@Test
void registerHints() {
RuntimeHints runtimeHints = new RuntimeHints();
ToolRuntimeHints toolRuntimeHints = new ToolRuntimeHints();
toolRuntimeHints.registerHints(runtimeHints, null);
assertThat(runtimeHints).matches(reflection().onType(DefaultToolCallResultConverter.class));
}

}

0 comments on commit e8af82c

Please sign in to comment.