-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ai): Make DefaultToolCallResultConverter work with GraalVM
- Loading branch information
1 parent
65287dc
commit e8af82c
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
arconia-ai/arconia-ai-tools/src/main/java/io/arconia/ai/tools/aot/ToolRuntimeHints.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
2 changes: 2 additions & 0 deletions
2
arconia-ai/arconia-ai-tools/src/main/resources/META-INF/spring/aot.factories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
24 changes: 24 additions & 0 deletions
24
arconia-ai/arconia-ai-tools/src/test/java/io/arconia/ai/tools/aot/ToolRuntimeHintsTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
|
||
} |