feat(xai): support namespace tools and enhance tool normalization logic
- Added `namespace` tool type support, enabling nested tools to be normalized and moved to the top level. - Refactored tool normalization logic into `normalizeXAITool` for reusability and clarity. - Updated `xai_executor` test cases to validate namespace tool handling and nested tool normalization.
This commit is contained in:
@@ -49,6 +49,42 @@ func TestWithXAIBuiltinsAddsVideoModel(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateModelsCatalogAllowsMissingSections(t *testing.T) {
|
||||
data := validTestModelsCatalog()
|
||||
data.XAI = nil
|
||||
|
||||
if err := validateModelsCatalog(data); err != nil {
|
||||
t.Fatalf("validateModelsCatalog() error = %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateModelsCatalogRejectsInvalidDefinitions(t *testing.T) {
|
||||
data := validTestModelsCatalog()
|
||||
data.Claude = []*ModelInfo{{ID: ""}}
|
||||
|
||||
if err := validateModelsCatalog(data); err == nil {
|
||||
t.Fatal("expected invalid model definition error")
|
||||
}
|
||||
}
|
||||
|
||||
func validTestModelsCatalog() *staticModelsJSON {
|
||||
models := []*ModelInfo{{ID: "test-model"}}
|
||||
return &staticModelsJSON{
|
||||
Claude: models,
|
||||
Gemini: models,
|
||||
Vertex: models,
|
||||
GeminiCLI: models,
|
||||
AIStudio: models,
|
||||
CodexFree: models,
|
||||
CodexTeam: models,
|
||||
CodexPlus: models,
|
||||
CodexPro: models,
|
||||
Kimi: models,
|
||||
Antigravity: models,
|
||||
XAI: models,
|
||||
}
|
||||
}
|
||||
|
||||
func findModelInfo(models []*ModelInfo, id string) *ModelInfo {
|
||||
for _, model := range models {
|
||||
if model != nil && model.ID == id {
|
||||
|
||||
@@ -349,7 +349,8 @@ func validateModelsCatalog(data *staticModelsJSON) error {
|
||||
|
||||
func validateModelSection(section string, models []*ModelInfo) error {
|
||||
if len(models) == 0 {
|
||||
return fmt.Errorf("%s section is empty", section)
|
||||
log.Warnf("models catalog: %s section is empty, continuing without those model definitions", section)
|
||||
return nil
|
||||
}
|
||||
|
||||
seen := make(map[string]struct{}, len(models))
|
||||
|
||||
Reference in New Issue
Block a user