99import dev .langchain4j .model .language .StreamingLanguageModel ;
1010import dev .langchain4j .model .ollama .*;
1111import dev .langchain4j .model .output .Response ;
12+ import org .junit .jupiter .api .BeforeAll ;
1213import org .junit .jupiter .api .Test ;
1314import org .springframework .boot .autoconfigure .AutoConfigurations ;
1415import org .springframework .boot .test .context .runner .ApplicationContextRunner ;
15- import org .testcontainers .containers .GenericContainer ;
1616import org .testcontainers .junit .jupiter .Container ;
1717import org .testcontainers .junit .jupiter .Testcontainers ;
18+ import org .testcontainers .ollama .OllamaContainer ;
19+ import org .testcontainers .utility .DockerImageName ;
1820
1921import java .util .concurrent .CompletableFuture ;
2022
21- import static java .lang .String .format ;
2223import static java .util .concurrent .TimeUnit .SECONDS ;
2324import static org .assertj .core .api .Assertions .assertThat ;
2425
@@ -28,14 +29,22 @@ class AutoConfigIT {
2829 private static final String MODEL_NAME = "phi" ;
2930
3031 @ Container
31- static GenericContainer <?> ollama = new GenericContainer <>("langchain4j/ollama-" + MODEL_NAME )
32+ static OllamaContainer ollama = new OllamaContainer (
33+ DockerImageName .parse ("alpine/ollama:latest" )
34+ .asCompatibleSubstituteFor ("ollama/ollama" )
35+ )
3236 .withExposedPorts (11434 );
3337
38+ @ BeforeAll
39+ static void beforeAll () throws Exception {
40+ ollama .execInContainer ("ollama" , "pull" , MODEL_NAME );
41+ }
42+
3443 ApplicationContextRunner contextRunner = new ApplicationContextRunner ()
3544 .withConfiguration (AutoConfigurations .of (AutoConfig .class ));
3645
3746 private static String baseUrl () {
38- return format ( "http://%s:%s" , ollama .getHost (), ollama . getFirstMappedPort () );
47+ return ollama .getEndpoint ( );
3948 }
4049
4150 @ Test
0 commit comments