Skip to content

Commit 437ff74

Browse files
committed
Deprecate the legacy Ollama generate API in favor of chat completion one
1 parent b9593fe commit 437ff74

File tree

1 file changed

+7
-1
lines changed
  • models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api

1 file changed

+7
-1
lines changed

models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaApi.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ public OllamaApi(String baseUrl, RestClient.Builder restClientBuilder) {
145145
* @param images (optional) a list of base64-encoded images (for multimodal models such as llava).
146146
* @param keepAlive (optional) controls how long the model will stay loaded into memory following the request (default: 5m).
147147
*/
148+
@Deprecated(since = "1.0.0-M2", forRemoval = true)
148149
@JsonInclude(Include.NON_NULL)
149150
public record GenerateRequest(
150151
@JsonProperty("model") String model,
@@ -289,6 +290,7 @@ public GenerateRequest build() {
289290
* @param evalCount Number of tokens in the response.
290291
* @param evalDuration Time spent generating the response.
291292
*/
293+
@Deprecated(since = "1.0.0-M2", forRemoval = true)
292294
@JsonInclude(Include.NON_NULL)
293295
public record GenerateResponse(
294296
@JsonProperty("model") String model,
@@ -304,11 +306,13 @@ public record GenerateResponse(
304306
@JsonProperty("eval_duration") Duration evalDuration) {
305307
}
306308

307-
/**
309+
/**
308310
* Generate a completion for the given prompt.
309311
* @param completionRequest Completion request.
310312
* @return Completion response.
313+
* @deprecated Use {@link #chat(ChatRequest)} instead.
311314
*/
315+
@Deprecated(since = "1.0.0-M2", forRemoval = true)
312316
public GenerateResponse generate(GenerateRequest completionRequest) {
313317
Assert.notNull(completionRequest, REQUEST_BODY_NULL_ERROR);
314318
Assert.isTrue(completionRequest.stream() == false, "Stream mode must be disabled.");
@@ -326,7 +330,9 @@ public GenerateResponse generate(GenerateRequest completionRequest) {
326330
* @param completionRequest Completion request. The request must set the stream
327331
* property to true.
328332
* @return Completion response as a {@link Flux} stream.
333+
* @deprecated Use {@link #streamingChat(ChatRequest)} instead.
329334
*/
335+
@Deprecated(since = "1.0.0-M2", forRemoval = true)
330336
public Flux<GenerateResponse> generateStreaming(GenerateRequest completionRequest) {
331337
Assert.notNull(completionRequest, REQUEST_BODY_NULL_ERROR);
332338
Assert.isTrue(completionRequest.stream(), "Request must set the steam property to true.");

0 commit comments

Comments
 (0)