Back to Testcontainers Java

Ollama

docs/modules/ollama.md

2.0.51.7 KB
Original Source

Ollama

Testcontainers module for Ollama .

Ollama's usage examples

You can start an Ollama container instance from any Java application by using:

<!--codeinclude-->

Ollama container inside_block:container

<!--/codeinclude-->

Pulling the model

Testcontainers allows executing commands in the container. So, pulling the model is as simple as:

<!--codeinclude-->

Pull model inside_block:pullModel

<!--/codeinclude-->

Create a new Image

In order to create a new image that contains the model, you can use the following code:

<!--codeinclude-->

Commit Image inside_block:commitToImage

<!--/codeinclude-->

And use the new image along with Image name Substitution

<!--codeinclude-->

Use new Image inside_block:substitute

<!--/codeinclude-->

Adding this module to your project dependencies

Add the following dependency to your pom.xml/build.gradle file:

=== "Gradle" groovy testImplementation "org.testcontainers:testcontainers-ollama:{{latest_version}}"

=== "Maven" xml <dependency> <groupId>org.testcontainers</groupId> <artifactId>testcontainers-ollama</artifactId> <version>{{latest_version}}</version> <scope>test</scope> </dependency>