@@ -4,18 +4,9 @@ import (
44 "testing"
55 "time"
66
7- "github.com/mirpo/datamatic/llm"
87 "github.com/stretchr/testify/assert"
98)
109
11- func floatPtr (f float64 ) * float64 {
12- return & f
13- }
14-
15- func intPtr (i int ) * int {
16- return & i
17- }
18-
1910func TestNewConfig (t * testing.T ) {
2011 cfg := NewConfig ()
2112
@@ -34,89 +25,6 @@ func TestNewConfig(t *testing.T) {
3425 assert .Equal (t , 2.0 , cfg .RetryConfig .BackoffMultiplier )
3526}
3627
37- func TestGetProviderConfig (t * testing.T ) {
38- tests := []struct {
39- name string
40- step Step
41- httpTimeout int
42- expected llm.ProviderConfig
43- }{
44- {
45- name : "Full config with temperature and max tokens" ,
46- step : Step {
47- ModelConfig : ModelConfig {
48- BaseURL : "http://example.com/api" ,
49- ModelProvider : llm .ProviderOllama ,
50- ModelName : "llama3" ,
51- Temperature : floatPtr (0.7 ),
52- MaxTokens : intPtr (1000 ),
53- },
54- },
55- httpTimeout : 30 ,
56- expected : llm.ProviderConfig {
57- ProviderType : llm .ProviderOllama ,
58- BaseURL : "http://example.com/api" ,
59- ModelName : "llama3" ,
60- AuthToken : "token" ,
61- Temperature : floatPtr (0.7 ),
62- MaxTokens : intPtr (1000 ),
63- HTTPTimeout : 30 ,
64- },
65- },
66- {
67- name : "Config without temperature and max tokens" ,
68- step : Step {
69- ModelConfig : ModelConfig {
70- BaseURL : "http://another-api.com" ,
71- ModelProvider : llm .ProviderOllama ,
72- ModelName : "command" ,
73- Temperature : nil ,
74- MaxTokens : nil ,
75- },
76- },
77- httpTimeout : 60 ,
78- expected : llm.ProviderConfig {
79- ProviderType : llm .ProviderOllama ,
80- BaseURL : "http://another-api.com" ,
81- ModelName : "command" ,
82- AuthToken : "token" ,
83- Temperature : nil ,
84- MaxTokens : nil ,
85- HTTPTimeout : 60 ,
86- },
87- },
88- {
89- name : "Different http timeout" ,
90- step : Step {
91- ModelConfig : ModelConfig {
92- BaseURL : "http://api3.org" ,
93- ModelProvider : llm .ProviderLmStudio ,
94- ModelName : "gpt-3.5-turbo" ,
95- Temperature : floatPtr (0.1 ),
96- MaxTokens : intPtr (500 ),
97- },
98- },
99- httpTimeout : 10 ,
100- expected : llm.ProviderConfig {
101- ProviderType : llm .ProviderLmStudio ,
102- BaseURL : "http://api3.org" ,
103- ModelName : "gpt-3.5-turbo" ,
104- AuthToken : "token" ,
105- Temperature : floatPtr (0.1 ),
106- MaxTokens : intPtr (500 ),
107- HTTPTimeout : 10 ,
108- },
109- },
110- }
111-
112- for _ , tt := range tests {
113- t .Run (tt .name , func (t * testing.T ) {
114- actual := tt .step .GetProviderConfig (tt .httpTimeout )
115- assert .Equal (t , tt .expected , actual , "ProviderConfig should match expected" )
116- })
117- }
118- }
119-
12028func TestGetStepByName (t * testing.T ) {
12129 step1 := Step {Name : "step1" }
12230 step2 := Step {Name : "step2" }
@@ -133,19 +41,3 @@ func TestGetStepByName(t *testing.T) {
13341 assert .Nil (t , step )
13442 })
13543}
136-
137- func TestRetryConfig (t * testing.T ) {
138- cfg := RetryConfig {
139- MaxAttempts : 5 ,
140- InitialDelay : 2 * time .Second ,
141- MaxDelay : 30 * time .Second ,
142- BackoffMultiplier : 1.5 ,
143- Enabled : false ,
144- }
145-
146- assert .False (t , cfg .Enabled )
147- assert .Equal (t , 5 , cfg .MaxAttempts )
148- assert .Equal (t , 2 * time .Second , cfg .InitialDelay )
149- assert .Equal (t , 30 * time .Second , cfg .MaxDelay )
150- assert .Equal (t , 1.5 , cfg .BackoffMultiplier )
151- }
0 commit comments