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
@@ -28,14 +30,19 @@ class AutoConfigIT {
2830 private static final String MODEL_NAME = "phi" ;
2931
3032 @ Container
31- static GenericContainer <?> ollama = new GenericContainer <>( "langchain4j /ollama-" + MODEL_NAME )
33+ static OllamaContainer ollama = new OllamaContainer ( DockerImageName . parse ( "ollama /ollama:latest" ) )
3234 .withExposedPorts (11434 );
3335
36+ @ BeforeAll
37+ static void beforeAll () throws Exception {
38+ ollama .execInContainer ("ollama" , "pull" , MODEL_NAME );
39+ }
40+
3441 ApplicationContextRunner contextRunner = new ApplicationContextRunner ()
3542 .withConfiguration (AutoConfigurations .of (AutoConfig .class ));
3643
3744 private static String baseUrl () {
38- return format ( "http://%s:%s" , ollama .getHost (), ollama . getFirstMappedPort () );
45+ return ollama .getEndpoint ( );
3946 }
4047
4148 @ Test
0 commit comments