Update chunking options in tests to reflect new defaults and structure

- Changed MaxConcurrent from 10 to 1 in test cases to align with updated configuration.
- Added new properties: Separator and EnableDebug, with default values set in tests.
- Refactored semantic options handling to include Connector and Toolcall properties, ensuring correct defaults are validated in tests.
- Enhanced test structure for semantic properties to improve clarity and maintainability.
This commit is contained in:
Max 2025-08-14 13:55:40 +08:00
parent ec91fca5c9
commit 2ebf73fce0

View file

@ -25,7 +25,9 @@ func TestStructured_Options(t *testing.T) {
Overlap: 20, Overlap: 20,
MaxDepth: 3, MaxDepth: 3,
SizeMultiplier: 3, SizeMultiplier: 3,
MaxConcurrent: 10, MaxConcurrent: 1,
Separator: "",
EnableDebug: false,
} }
if options.Size != expected.Size { if options.Size != expected.Size {
@ -157,8 +159,8 @@ func TestStructured_Options(t *testing.T) {
if options.SizeMultiplier != 3 { if options.SizeMultiplier != 3 {
t.Errorf("Expected SizeMultiplier 3 (default), got %d", options.SizeMultiplier) t.Errorf("Expected SizeMultiplier 3 (default), got %d", options.SizeMultiplier)
} }
if options.MaxConcurrent != 10 { if options.MaxConcurrent != 1 {
t.Errorf("Expected MaxConcurrent 10 (default), got %d", options.MaxConcurrent) t.Errorf("Expected MaxConcurrent 1 (default), got %d", options.MaxConcurrent)
} }
}) })
@ -210,8 +212,8 @@ func TestSemantic_Options(t *testing.T) {
if options.SizeMultiplier != 3 { if options.SizeMultiplier != 3 {
t.Errorf("Expected SizeMultiplier 3, got %d", options.SizeMultiplier) t.Errorf("Expected SizeMultiplier 3, got %d", options.SizeMultiplier)
} }
if options.MaxConcurrent != 10 { if options.MaxConcurrent != 1 {
t.Errorf("Expected MaxConcurrent 10, got %d", options.MaxConcurrent) t.Errorf("Expected MaxConcurrent 1, got %d", options.MaxConcurrent)
} }
// Check semantic options // Check semantic options
@ -224,11 +226,14 @@ func TestSemantic_Options(t *testing.T) {
if options.SemanticOptions.MaxRetry != 3 { if options.SemanticOptions.MaxRetry != 3 {
t.Errorf("Expected MaxRetry 3, got %d", options.SemanticOptions.MaxRetry) t.Errorf("Expected MaxRetry 3, got %d", options.SemanticOptions.MaxRetry)
} }
if options.SemanticOptions.MaxConcurrent != 10 { if options.SemanticOptions.MaxConcurrent != 1 {
t.Errorf("Expected MaxConcurrent 10, got %d", options.SemanticOptions.MaxConcurrent) t.Errorf("Expected MaxConcurrent 1, got %d", options.SemanticOptions.MaxConcurrent)
} }
if options.SemanticOptions.Toolcall != false { if options.SemanticOptions.Toolcall != true {
t.Errorf("Expected Toolcall false, got %v", options.SemanticOptions.Toolcall) t.Errorf("Expected Toolcall true, got %v", options.SemanticOptions.Toolcall)
}
if options.SemanticOptions.Connector != "openai.gpt-4o-mini" {
t.Errorf("Expected Connector 'openai.gpt-4o-mini', got '%s'", options.SemanticOptions.Connector)
} }
}) })
@ -263,6 +268,7 @@ func TestSemantic_Options(t *testing.T) {
t.Run("semantic specific properties", func(t *testing.T) { t.Run("semantic specific properties", func(t *testing.T) {
option := &kbtypes.ProviderOption{ option := &kbtypes.ProviderOption{
Properties: map[string]interface{}{ Properties: map[string]interface{}{
"semantic": map[string]interface{}{
"connector": "openai.gpt-4o-mini", "connector": "openai.gpt-4o-mini",
"toolcall": true, "toolcall": true,
"context_size": 2400, "context_size": 2400,
@ -271,6 +277,7 @@ func TestSemantic_Options(t *testing.T) {
"max_retry": 5, "max_retry": 5,
"semantic_max_concurrent": 15, "semantic_max_concurrent": 15,
}, },
},
} }
options, err := s.Options(option) options, err := s.Options(option)
@ -325,8 +332,10 @@ func TestSemantic_Options(t *testing.T) {
option := &kbtypes.ProviderOption{ option := &kbtypes.ProviderOption{
Properties: map[string]interface{}{ Properties: map[string]interface{}{
"size": 400, // Would auto-calculate to 2400 "size": 400, // Would auto-calculate to 2400
"semantic": map[string]interface{}{
"context_size": 3000, // Explicit override "context_size": 3000, // Explicit override
}, },
},
} }
options, err := s.Options(option) options, err := s.Options(option)
@ -343,10 +352,12 @@ func TestSemantic_Options(t *testing.T) {
option := &kbtypes.ProviderOption{ option := &kbtypes.ProviderOption{
Properties: map[string]interface{}{ Properties: map[string]interface{}{
"size": 500.0, "size": 500.0,
"semantic": map[string]interface{}{
"context_size": 3000.0, "context_size": 3000.0,
"max_retry": 4.0, "max_retry": 4.0,
"semantic_max_concurrent": 12.0, "semantic_max_concurrent": 12.0,
}, },
},
} }
options, err := s.Options(option) options, err := s.Options(option)
@ -372,10 +383,12 @@ func TestSemantic_Options(t *testing.T) {
option := &kbtypes.ProviderOption{ option := &kbtypes.ProviderOption{
Properties: map[string]interface{}{ Properties: map[string]interface{}{
"size": 500, // valid "size": 500, // valid
"semantic": map[string]interface{}{
"connector": 123, // invalid type for string "connector": 123, // invalid type for string
"toolcall": "invalid", // invalid type for bool "toolcall": "invalid", // invalid type for bool
"max_retry": 3, // valid "max_retry": 3, // valid
}, },
},
} }
options, err := s.Options(option) options, err := s.Options(option)
@ -392,11 +405,11 @@ func TestSemantic_Options(t *testing.T) {
} }
// Invalid properties should use defaults // Invalid properties should use defaults
if options.SemanticOptions.Connector != "" { if options.SemanticOptions.Connector != "openai.gpt-4o-mini" {
t.Errorf("Expected Connector '' (default), got '%s'", options.SemanticOptions.Connector) t.Errorf("Expected Connector 'openai.gpt-4o-mini' (default), got '%s'", options.SemanticOptions.Connector)
} }
if options.SemanticOptions.Toolcall != false { if options.SemanticOptions.Toolcall != true {
t.Errorf("Expected Toolcall false (default), got %v", options.SemanticOptions.Toolcall) t.Errorf("Expected Toolcall true (default), got %v", options.SemanticOptions.Toolcall)
} }
}) })
} }