diff --git a/langchain4j-ollama-spring-boot-starter/pom.xml b/langchain4j-ollama-spring-boot-starter/pom.xml index eecb11b5..07ec72e2 100644 --- a/langchain4j-ollama-spring-boot-starter/pom.xml +++ b/langchain4j-ollama-spring-boot-starter/pom.xml @@ -59,7 +59,7 @@ org.testcontainers - testcontainers + ollama test diff --git a/langchain4j-ollama-spring-boot-starter/src/test/java/dev/langchain4j/ollama/spring/AutoConfigIT.java b/langchain4j-ollama-spring-boot-starter/src/test/java/dev/langchain4j/ollama/spring/AutoConfigIT.java index fced9a72..1234a848 100644 --- a/langchain4j-ollama-spring-boot-starter/src/test/java/dev/langchain4j/ollama/spring/AutoConfigIT.java +++ b/langchain4j-ollama-spring-boot-starter/src/test/java/dev/langchain4j/ollama/spring/AutoConfigIT.java @@ -9,12 +9,14 @@ import dev.langchain4j.model.language.StreamingLanguageModel; import dev.langchain4j.model.ollama.*; import dev.langchain4j.model.output.Response; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.testcontainers.containers.GenericContainer; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; +import org.testcontainers.ollama.OllamaContainer; +import org.testcontainers.utility.DockerImageName; import java.util.concurrent.CompletableFuture; @@ -28,14 +30,19 @@ class AutoConfigIT { private static final String MODEL_NAME = "phi"; @Container - static GenericContainer ollama = new GenericContainer<>("langchain4j/ollama-" + MODEL_NAME) + static OllamaContainer ollama = new OllamaContainer(DockerImageName.parse("ollama/ollama:latest")) .withExposedPorts(11434); + @BeforeAll + static void beforeAll() throws Exception { + ollama.execInContainer("ollama", "pull", MODEL_NAME); + } + ApplicationContextRunner contextRunner = new ApplicationContextRunner() .withConfiguration(AutoConfigurations.of(AutoConfig.class)); private static String baseUrl() { - return format("http://%s:%s", ollama.getHost(), ollama.getFirstMappedPort()); + return ollama.getEndpoint(); } @Test