Skip to content

Commit

Permalink
Merge pull request #1048 from quarkiverse/#1043
Browse files Browse the repository at this point in the history
Fix warning about missing model-id in Ollama
  • Loading branch information
geoand authored Nov 5, 2024
2 parents 4c72522 + 89de624 commit 56d62d8
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
package io.quarkiverse.langchain4j.ollama.runtime.config;

import java.util.function.Function;

import io.smallrye.config.FallbackConfigSourceInterceptor;

public class ModelIdConfigFallbackInterceptor extends FallbackConfigSourceInterceptor {

private static final Function<String, String> FALLBACK = new Function<>() {
@Override
public String apply(String name) {
if (!name.startsWith("quarkus.langchain4j.ollama")) {
return name;
}
if (!name.endsWith("model-id")) {
return name;
}
int index = name.lastIndexOf(".model-id");
if (index < 1) {
return name;
}
return name.substring(0, index) + ".model-name";
}
};

public ModelIdConfigFallbackInterceptor() {
super(ModelIdToModelNameFunction.INSTANCE);
super(FALLBACK);
}

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
package io.quarkiverse.langchain4j.ollama.runtime.config;

import java.util.function.Function;

import io.smallrye.config.RelocateConfigSourceInterceptor;

public class ModelIdConfigRelocateInterceptor extends RelocateConfigSourceInterceptor {

private static final Function<String, String> RELOCATE = new Function<>() {
@Override
public String apply(String name) {
if (!name.startsWith("quarkus.langchain4j.ollama")) {
return name;
}
if (!name.endsWith("model-name")) {
return name;
}
int index = name.lastIndexOf(".model-name");
if (index < 1) {
return name;
}
return name.substring(0, index) + ".model-id";
}
};

public ModelIdConfigRelocateInterceptor() {
super(ModelIdToModelNameFunction.INSTANCE);
super(RELOCATE);
}
}

This file was deleted.

0 comments on commit 56d62d8

Please sign in to comment.