File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
models/spring-ai-ollama/src
main/java/org/springframework/ai/ollama
test/java/org/springframework/ai/ollama Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 11/*
2- * Copyright 2023-2024 the original author or authors.
2+ * Copyright 2023-2025 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
6060 * @author Christian Tzolov
6161 * @author Thomas Vitale
6262 * @author Ilayaperumal Gopinathan
63+ * @author Jonghoon Park
6364 * @since 0.8.0
6465 */
6566public class OllamaEmbeddingModel extends AbstractEmbeddingModel {
@@ -188,7 +189,7 @@ public void setObservationConvention(EmbeddingModelObservationConvention observa
188189
189190 public static class DurationParser {
190191
191- private static final Pattern PATTERN = Pattern .compile ("(\\ d+)(ms|s|m|h)" );
192+ private static final Pattern PATTERN = Pattern .compile ("(-? \\ d+)(ms|s|m|h)" );
192193
193194 public static Duration parse (String input ) {
194195
Original file line number Diff line number Diff line change 11/*
2- * Copyright 2023-2024 the original author or authors.
2+ * Copyright 2023-2025 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
1616
1717package org .springframework .ai .ollama ;
1818
19+ import java .time .Duration ;
1920import java .util .List ;
2021
2122import org .junit .jupiter .api .Test ;
2829/**
2930 * @author Christian Tzolov
3031 * @author Thomas Vitale
32+ * @author Jonghoon Park
3133 */
3234public class OllamaEmbeddingRequestTests {
3335
@@ -67,4 +69,14 @@ public void ollamaEmbeddingRequestRequestOptions() {
6769 assertThat (request .input ()).isEqualTo (List .of ("Hello" ));
6870 }
6971
72+ @ Test
73+ public void ollamaEmbeddingRequestWithNegativeKeepAlive () {
74+
75+ var promptOptions = OllamaOptions .builder ().model ("PROMPT_MODEL" ).keepAlive ("-1m" ).build ();
76+
77+ var request = this .embeddingModel .ollamaEmbeddingRequest (List .of ("Hello" ), promptOptions );
78+
79+ assertThat (request .keepAlive ()).isEqualTo (Duration .ofMinutes (-1 ));
80+ }
81+
7082}
You can’t perform that action at this time.
0 commit comments