From 437ff74cade942977baeb5ef19c39ed1e070d4e2 Mon Sep 17 00:00:00 2001 From: Christian Tzolov Date: Thu, 25 Jul 2024 09:49:23 +0200 Subject: [PATCH] Deprecate the legacy Ollama generate API in favor of chat completion one --- .../java/org/springframework/ai/ollama/api/OllamaApi.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaApi.java b/models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaApi.java index fd7d0996f..83acf37a7 100644 --- a/models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaApi.java +++ b/models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaApi.java @@ -145,6 +145,7 @@ public class OllamaApi { * @param images (optional) a list of base64-encoded images (for multimodal models such as llava). * @param keepAlive (optional) controls how long the model will stay loaded into memory following the request (default: 5m). */ + @Deprecated(since = "1.0.0-M2", forRemoval = true) @JsonInclude(Include.NON_NULL) public record GenerateRequest( @JsonProperty("model") String model, @@ -289,6 +290,7 @@ public class OllamaApi { * @param evalCount Number of tokens in the response. * @param evalDuration Time spent generating the response. */ + @Deprecated(since = "1.0.0-M2", forRemoval = true) @JsonInclude(Include.NON_NULL) public record GenerateResponse( @JsonProperty("model") String model, @@ -304,11 +306,13 @@ public class OllamaApi { @JsonProperty("eval_duration") Duration evalDuration) { } - /** + /** * Generate a completion for the given prompt. * @param completionRequest Completion request. * @return Completion response. + * @deprecated Use {@link #chat(ChatRequest)} instead. */ + @Deprecated(since = "1.0.0-M2", forRemoval = true) public GenerateResponse generate(GenerateRequest completionRequest) { Assert.notNull(completionRequest, REQUEST_BODY_NULL_ERROR); Assert.isTrue(completionRequest.stream() == false, "Stream mode must be disabled."); @@ -326,7 +330,9 @@ public class OllamaApi { * @param completionRequest Completion request. The request must set the stream * property to true. * @return Completion response as a {@link Flux} stream. + * @deprecated Use {@link #streamingChat(ChatRequest)} instead. */ + @Deprecated(since = "1.0.0-M2", forRemoval = true) public Flux generateStreaming(GenerateRequest completionRequest) { Assert.notNull(completionRequest, REQUEST_BODY_NULL_ERROR); Assert.isTrue(completionRequest.stream(), "Request must set the steam property to true.");