Ollama Model¶
agentscope-extensions-model-ollama integrates locally hosted Ollama models. It is useful for local development, private deployments, and offline model serving.
Add the dependency¶
<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope-extensions-model-ollama</artifactId>
<version>${agentscope.version}</version>
</dependency>
ModelRegistry¶
Use the ollama:<model> id. OLLAMA_BASE_URL is optional and defaults to the local Ollama endpoint when omitted.
ReActAgent agent = ReActAgent.builder()
.name("assistant")
.model("ollama:llama3") // Resolved internally by ModelRegistry.resolve(modelId)
.build();
Explicit builder¶
Use the builder when you need a non-default Ollama endpoint, formatter, transport, proxy, or Ollama options:
import io.agentscope.extensions.model.ollama.OllamaChatModel;
OllamaChatModel model = OllamaChatModel.builder()
.modelName("llama3")
.baseUrl("http://localhost:11434")
.build();
Spring Boot¶
Spring Boot applications can use the Ollama starter:
<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope-ollama-spring-boot-starter</artifactId>
<version>${agentscope.version}</version>
</dependency>
Configure the local Ollama model with agentscope.model.provider=ollama. The base URL
is optional and defaults to http://localhost:11434:
agentscope:
model:
provider: ollama
ollama:
model-name: llama3
# base-url: http://localhost:11434
Full builder options, formatters, credentials, and registry context details are covered in Model.