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
2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2023-2024 the original author or authors.
2
+ * Copyright 2023-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
60
60
* @author Christian Tzolov
61
61
* @author Thomas Vitale
62
62
* @author Ilayaperumal Gopinathan
63
+ * @author Jonghoon Park
63
64
* @since 0.8.0
64
65
*/
65
66
public class OllamaEmbeddingModel extends AbstractEmbeddingModel {
@@ -188,7 +189,7 @@ public void setObservationConvention(EmbeddingModelObservationConvention observa
188
189
189
190
public static class DurationParser {
190
191
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)" );
192
193
193
194
public static Duration parse (String input ) {
194
195
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2023-2024 the original author or authors.
2
+ * Copyright 2023-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
16
16
17
17
package org .springframework .ai .ollama ;
18
18
19
+ import java .time .Duration ;
19
20
import java .util .List ;
20
21
21
22
import org .junit .jupiter .api .Test ;
28
29
/**
29
30
* @author Christian Tzolov
30
31
* @author Thomas Vitale
32
+ * @author Jonghoon Park
31
33
*/
32
34
public class OllamaEmbeddingRequestTests {
33
35
@@ -67,4 +69,14 @@ public void ollamaEmbeddingRequestRequestOptions() {
67
69
assertThat (request .input ()).isEqualTo (List .of ("Hello" ));
68
70
}
69
71
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
+
70
82
}
You can’t perform that action at this time.
0 commit comments