hi,
i needed the following graalvm native hints to make the pdf reader and the open ai embedding clients work in a graalvm aot native image context with Liberica NIK JDK. Please add them to their respective modules (KnuddelsHints
and OpenAiEmbeddingsHints
, I think , both belong near the openai support, and the PdfReaderHints
belongs near the pdf document reader.) Just add them to the auto @Configuration
class: @ImportRuntimeHints(KnuddelsHints.class)
, etc.
```java
static class KnuddelsHints implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
hints.resources().registerResource(new ClassPathResource("/com/knuddels/jtokkit/cl100k_base.tiktoken"));
}
}
static class OpenAiEmbeddingsHints implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
var memberCategories = MemberCategory.values();
for (var c : new Class[] { Embedding.class, EmbeddingRequest.class, EmbeddingResult.class })
hints.reflection().registerType(c, memberCategories);
hints.resources()
.registerResource(new ClassPathResource("embedding/embedding-model-dimensions.properties"));
}
}
static class PdfReaderHints implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
try {
var resolver = new PathMatchingResourcePatternResolver();
var patterns = Set.of("/org/apache/pdfbox/resources/glyphlist/zapfdingbats.txt",
"/org/apache/pdfbox/resources/glyphlist/glyphlist.txt", "/org/apache/fontbox/cmap/**",
"/org/apache/pdfbox/resources/afm/**", "/org/apache/pdfbox/resources/glyphlist/**",
"/org/apache/pdfbox/resources/icc/**", "/org/apache/pdfbox/resources/text/**",
"/org/apache/pdfbox/resources/ttf/**", "/org/apache/pdfbox/resources/version.properties");
for (var pattern : patterns)
for (var resourceMatch : resolver.getResources(pattern))
hints.resources().registerResource(resourceMatch);
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
}
````