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.
20
20
import java .time .Instant ;
21
21
import java .util .List ;
22
22
23
+ import io .micrometer .observation .ObservationRegistry ;
23
24
import org .junit .jupiter .api .Test ;
24
25
import org .junit .jupiter .api .extension .ExtendWith ;
25
26
import org .mockito .Mock ;
26
27
import org .mockito .junit .jupiter .MockitoExtension ;
27
28
28
29
import org .springframework .ai .chat .metadata .ChatResponseMetadata ;
29
30
import org .springframework .ai .chat .metadata .DefaultUsage ;
31
+ import org .springframework .ai .chat .model .ChatModel ;
30
32
import org .springframework .ai .chat .model .ChatResponse ;
33
+ import org .springframework .ai .model .tool .ToolCallingManager ;
31
34
import org .springframework .ai .ollama .api .OllamaApi ;
32
35
import org .springframework .ai .ollama .api .OllamaModel ;
33
36
import org .springframework .ai .ollama .api .OllamaOptions ;
37
+ import org .springframework .ai .ollama .management .ModelManagementOptions ;
34
38
35
39
import static org .assertj .core .api .Assertions .assertThat ;
36
40
import static org .junit .jupiter .api .Assertions .assertEquals ;
40
44
* @author Jihoon Kim
41
45
* @author Christian Tzolov
42
46
* @author Alexandros Pappas
47
+ * @author Thomas Vitale
43
48
* @since 1.0.0
44
49
*/
45
50
@ ExtendWith (MockitoExtension .class )
46
- public class OllamaChatModelTests {
51
+ class OllamaChatModelTests {
47
52
48
53
@ Mock
49
54
OllamaApi ollamaApi ;
50
55
51
56
@ Test
52
- public void buildOllamaChatModel () {
57
+ void buildOllamaChatModelWithDeprecatedConstructor () {
58
+ ChatModel chatModel = new OllamaChatModel (this .ollamaApi ,
59
+ OllamaOptions .builder ().model (OllamaModel .MISTRAL ).build (), null , null , ObservationRegistry .NOOP ,
60
+ ModelManagementOptions .builder ().build ());
61
+ assertThat (chatModel ).isNotNull ();
62
+ }
63
+
64
+ @ Test
65
+ void buildOllamaChatModelWithConstructor () {
66
+ ChatModel chatModel = new OllamaChatModel (this .ollamaApi ,
67
+ OllamaOptions .builder ().model (OllamaModel .MISTRAL ).build (), ToolCallingManager .builder ().build (),
68
+ ObservationRegistry .NOOP , ModelManagementOptions .builder ().build ());
69
+ assertThat (chatModel ).isNotNull ();
70
+ }
71
+
72
+ @ Test
73
+ void buildOllamaChatModelWithBuilder () {
74
+ ChatModel chatModel = OllamaChatModel .builder ().ollamaApi (ollamaApi ).build ();
75
+ assertThat (chatModel ).isNotNull ();
76
+ }
77
+
78
+ @ Test
79
+ void buildOllamaChatModel () {
53
80
Exception exception = assertThrows (IllegalArgumentException .class ,
54
81
() -> OllamaChatModel .builder ()
55
82
.ollamaApi (this .ollamaApi )
@@ -60,7 +87,7 @@ public void buildOllamaChatModel() {
60
87
}
61
88
62
89
@ Test
63
- public void buildChatResponseMetadata () {
90
+ void buildChatResponseMetadata () {
64
91
65
92
Long evalDuration = 1000L ;
66
93
Integer evalCount = 101 ;
@@ -83,7 +110,7 @@ public void buildChatResponseMetadata() {
83
110
}
84
111
85
112
@ Test
86
- public void buildChatResponseMetadataAggregationWithNonEmptyMetadata () {
113
+ void buildChatResponseMetadataAggregationWithNonEmptyMetadata () {
87
114
88
115
Long evalDuration = 1000L ;
89
116
Integer evalCount = 101 ;
0 commit comments