From 84d75846ebb3d7b60dad5ad6c085a6c39d55943a Mon Sep 17 00:00:00 2001 From: mirkoCrobu Date: Thu, 20 Nov 2025 17:07:41 +0100 Subject: [PATCH 1/7] remove models field from brick list --- internal/api/docs/openapi.yaml | 5 ----- internal/e2e/client/client.gen.go | 15 +++++++-------- internal/orchestrator/bricks/bricks.go | 3 --- internal/orchestrator/bricks/types.go | 13 ++++++------- 4 files changed, 13 insertions(+), 23 deletions(-) diff --git a/internal/api/docs/openapi.yaml b/internal/api/docs/openapi.yaml index f2b3a999..b50e2ff3 100644 --- a/internal/api/docs/openapi.yaml +++ b/internal/api/docs/openapi.yaml @@ -1365,11 +1365,6 @@ components: type: string id: type: string - models: - items: - type: string - nullable: true - type: array name: type: string status: diff --git a/internal/e2e/client/client.gen.go b/internal/e2e/client/client.gen.go index f6094430..ed56e54f 100644 --- a/internal/e2e/client/client.gen.go +++ b/internal/e2e/client/client.gen.go @@ -1,6 +1,6 @@ // Package client provides primitives to interact with the openapi HTTP API. // -// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.5.0 DO NOT EDIT. +// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.5.1 DO NOT EDIT. package client import ( @@ -164,13 +164,12 @@ type BrickInstance struct { // BrickListItem defines model for BrickListItem. type BrickListItem struct { - Author *string `json:"author,omitempty"` - Category *string `json:"category,omitempty"` - Description *string `json:"description,omitempty"` - Id *string `json:"id,omitempty"` - Models *[]string `json:"models"` - Name *string `json:"name,omitempty"` - Status *string `json:"status,omitempty"` + Author *string `json:"author,omitempty"` + Category *string `json:"category,omitempty"` + Description *string `json:"description,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Status *string `json:"status,omitempty"` } // BrickListResult defines model for BrickListResult. diff --git a/internal/orchestrator/bricks/bricks.go b/internal/orchestrator/bricks/bricks.go index e8dea9da..8fcb4c66 100644 --- a/internal/orchestrator/bricks/bricks.go +++ b/internal/orchestrator/bricks/bricks.go @@ -64,9 +64,6 @@ func (s *Service) List() (BrickListResult, error) { Description: brick.Description, Category: brick.Category, Status: "installed", - Models: f.Map(s.modelsIndex.GetModelsByBrick(brick.ID), func(m modelsindex.AIModel) string { - return m.ID - }), } } return res, nil diff --git a/internal/orchestrator/bricks/types.go b/internal/orchestrator/bricks/types.go index 868c563a..7310a359 100644 --- a/internal/orchestrator/bricks/types.go +++ b/internal/orchestrator/bricks/types.go @@ -20,13 +20,12 @@ type BrickListResult struct { } type BrickListItem struct { - ID string `json:"id"` - Name string `json:"name"` - Author string `json:"author"` - Description string `json:"description"` - Category string `json:"category"` - Status string `json:"status"` - Models []string `json:"models"` + ID string `json:"id"` + Name string `json:"name"` + Author string `json:"author"` + Description string `json:"description"` + Category string `json:"category"` + Status string `json:"status"` } type AppBrickInstancesResult struct { From 9f73db47189a22480a51c7d6825636db6740f022 Mon Sep 17 00:00:00 2001 From: mirkoCrobu Date: Thu, 20 Nov 2025 17:33:54 +0100 Subject: [PATCH 2/7] add lite model information to brickDetails endpoint --- internal/api/docs/openapi.yaml | 7 ++++++ internal/e2e/client/client.gen.go | 4 +++ internal/e2e/daemon/brick_test.go | 14 +++++++++++ internal/orchestrator/bricks/bricks.go | 2 +- internal/orchestrator/bricks/types.go | 25 +++++++++++-------- .../orchestrator/modelsindex/models_index.go | 25 +++++++++++++++++++ .../modelsindex/modelsindex_test.go | 11 ++++++++ 7 files changed, 76 insertions(+), 12 deletions(-) diff --git a/internal/api/docs/openapi.yaml b/internal/api/docs/openapi.yaml index b50e2ff3..3d0e30d2 100644 --- a/internal/api/docs/openapi.yaml +++ b/internal/api/docs/openapi.yaml @@ -1171,6 +1171,8 @@ components: runner: type: string type: object + AIModelLite: + type: object AIModelsListResult: properties: models: @@ -1314,6 +1316,11 @@ components: type: string id: type: string + models: + items: + $ref: '#/components/schemas/AIModelLite' + nullable: true + type: array name: type: string readme: diff --git a/internal/e2e/client/client.gen.go b/internal/e2e/client/client.gen.go index ed56e54f..d08272ac 100644 --- a/internal/e2e/client/client.gen.go +++ b/internal/e2e/client/client.gen.go @@ -52,6 +52,9 @@ type AIModelItem struct { Runner *string `json:"runner,omitempty"` } +// AIModelLite defines model for AIModelLite. +type AIModelLite = map[string]interface{} + // AIModelsListResult defines model for AIModelsListResult. type AIModelsListResult struct { Models *[]AIModelItem `json:"models"` @@ -141,6 +144,7 @@ type BrickDetailsResult struct { CodeExamples *[]CodeExample `json:"code_examples"` Description *string `json:"description,omitempty"` Id *string `json:"id,omitempty"` + Models *[]AIModelLite `json:"models"` Name *string `json:"name,omitempty"` Readme *string `json:"readme,omitempty"` Status *string `json:"status,omitempty"` diff --git a/internal/e2e/daemon/brick_test.go b/internal/e2e/daemon/brick_test.go index fa1cab40..aaebe31f 100644 --- a/internal/e2e/daemon/brick_test.go +++ b/internal/e2e/daemon/brick_test.go @@ -30,6 +30,7 @@ import ( "github.com/arduino/arduino-app-cli/internal/e2e/client" "github.com/arduino/arduino-app-cli/internal/orchestrator/bricksindex" "github.com/arduino/arduino-app-cli/internal/orchestrator/config" + "github.com/arduino/arduino-app-cli/internal/orchestrator/modelsindex" "github.com/arduino/arduino-app-cli/internal/store" ) @@ -115,6 +116,17 @@ func TestBricksDetails(t *testing.T) { }, } + expectedModelLiteInfo := []modelsindex.AIModelLite{ + { + ID: "mobilenet-image-classification", + Name: "General purpose image classification", + ModuleDescription: "General purpose image classification model based on MobileNetV2. This model is trained on the ImageNet dataset and can classify images into 1000 categories.", + }, + { + ID: "person-classification", + Name: "Person classification", + ModuleDescription: "Person classification model based on WakeVision dataset. This model is trained to classify images into two categories: person and not-person.", + }} response, err := httpClient.GetBrickDetailsWithResponse(t.Context(), validBrickID, func(ctx context.Context, req *http.Request) error { return nil }) require.NoError(t, err) require.Equal(t, http.StatusOK, response.StatusCode(), "status code should be 200 ok") @@ -133,5 +145,7 @@ func TestBricksDetails(t *testing.T) { require.NotEmpty(t, *response.JSON200.Readme) require.NotNil(t, response.JSON200.UsedByApps, "UsedByApps should not be nil") require.Equal(t, expectedUsedByApps, *(response.JSON200.UsedByApps)) + require.NotNil(t, response.JSON200.Models, "Models should not be nil") + require.Equal(t, expectedModelLiteInfo, *(response.JSON200.Models)) }) } diff --git a/internal/orchestrator/bricks/bricks.go b/internal/orchestrator/bricks/bricks.go index 8fcb4c66..9c9c8711 100644 --- a/internal/orchestrator/bricks/bricks.go +++ b/internal/orchestrator/bricks/bricks.go @@ -190,7 +190,6 @@ func (s *Service) BricksDetails(id string, idProvider *app.IDProvider, if err != nil { return BrickDetailsResult{}, fmt.Errorf("unable to get used by apps: %w", err) } - return BrickDetailsResult{ ID: id, Name: brick.Name, @@ -203,6 +202,7 @@ func (s *Service) BricksDetails(id string, idProvider *app.IDProvider, ApiDocsPath: apiDocsPath, CodeExamples: codeExamples, UsedByApps: usedByApps, + Models: s.modelsIndex.GetModelsLiteInfoByBrick(brick.ID), }, nil } diff --git a/internal/orchestrator/bricks/types.go b/internal/orchestrator/bricks/types.go index 7310a359..b7dc9b1b 100644 --- a/internal/orchestrator/bricks/types.go +++ b/internal/orchestrator/bricks/types.go @@ -15,6 +15,8 @@ package bricks +import "github.com/arduino/arduino-app-cli/internal/orchestrator/modelsindex" + type BrickListResult struct { Bricks []BrickListItem `json:"bricks"` } @@ -66,15 +68,16 @@ type AppReference struct { } type BrickDetailsResult struct { - ID string `json:"id"` - Name string `json:"name"` - Author string `json:"author"` - Description string `json:"description"` - Category string `json:"category"` - Status string `json:"status"` - Variables map[string]BrickVariable `json:"variables,omitempty"` - Readme string `json:"readme"` - ApiDocsPath string `json:"api_docs_path"` - CodeExamples []CodeExample `json:"code_examples"` - UsedByApps []AppReference `json:"used_by_apps"` + ID string `json:"id"` + Name string `json:"name"` + Author string `json:"author"` + Description string `json:"description"` + Category string `json:"category"` + Status string `json:"status"` + Variables map[string]BrickVariable `json:"variables,omitempty"` + Readme string `json:"readme"` + ApiDocsPath string `json:"api_docs_path"` + CodeExamples []CodeExample `json:"code_examples"` + UsedByApps []AppReference `json:"used_by_apps"` + Models []modelsindex.AIModelLite `json:"models"` } diff --git a/internal/orchestrator/modelsindex/models_index.go b/internal/orchestrator/modelsindex/models_index.go index e18797f1..54c9247a 100644 --- a/internal/orchestrator/modelsindex/models_index.go +++ b/internal/orchestrator/modelsindex/models_index.go @@ -53,6 +53,12 @@ type AIModel struct { ModelConfiguration map[string]string `yaml:"model_configuration,omitempty"` } +type AIModelLite struct { + ID string `yaml:"-"` + Name string `yaml:"name"` + ModuleDescription string `yaml:"description"` +} + type ModelsIndex struct { models []AIModel } @@ -82,6 +88,25 @@ func (m *ModelsIndex) GetModelsByBrick(brick string) []AIModel { return matches } +func (m *ModelsIndex) GetModelsLiteInfoByBrick(brick string) []AIModelLite { + var matches []AIModelLite + for i := range m.models { + if len(m.models[i].Bricks) > 0 && slices.Contains(m.models[i].Bricks, brick) { + matches = append(matches, + AIModelLite{ + ID: m.models[i].ID, + Name: m.models[i].Name, + ModuleDescription: m.models[i].ModuleDescription, + }, + ) + } + } + if len(matches) == 0 { + return []AIModelLite{} + } + return matches +} + func (m *ModelsIndex) GetModelsByBricks(bricks []string) []AIModel { var matchingModels []AIModel for _, model := range m.models { diff --git a/internal/orchestrator/modelsindex/modelsindex_test.go b/internal/orchestrator/modelsindex/modelsindex_test.go index 53ffb585..5f59666e 100644 --- a/internal/orchestrator/modelsindex/modelsindex_test.go +++ b/internal/orchestrator/modelsindex/modelsindex_test.go @@ -69,4 +69,15 @@ func TestModelsIndex(t *testing.T) { assert.Equal(t, "face-detection", models[0].ID) assert.Equal(t, "yolox-object-detection", models[1].ID) }) + + t.Run("it gets models lite by a brick", func(t *testing.T) { + model := modelsIndex.GetModelsLiteInfoByBrick("not-existing-brick") + assert.Nil(t, model) + + model = modelsIndex.GetModelsLiteInfoByBrick("arduino:object_detection") + assert.Len(t, model, 1) + assert.Equal(t, "face-detection", model[0].ID) + assert.Equal(t, "Face bounding box detection. This model is trained on the WIDER FACE dataset and can detect faces in images.", model[0].ModuleDescription) + assert.Equal(t, "Lightweight-Face-Detection", model[0].Name) + }) } From 24d1b09f39087bfdf0a7af63406fa6667ce44784 Mon Sep 17 00:00:00 2001 From: mirkoCrobu Date: Thu, 20 Nov 2025 17:41:28 +0100 Subject: [PATCH 3/7] fix test --- internal/orchestrator/modelsindex/modelsindex_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/orchestrator/modelsindex/modelsindex_test.go b/internal/orchestrator/modelsindex/modelsindex_test.go index 5f59666e..238f043a 100644 --- a/internal/orchestrator/modelsindex/modelsindex_test.go +++ b/internal/orchestrator/modelsindex/modelsindex_test.go @@ -72,7 +72,7 @@ func TestModelsIndex(t *testing.T) { t.Run("it gets models lite by a brick", func(t *testing.T) { model := modelsIndex.GetModelsLiteInfoByBrick("not-existing-brick") - assert.Nil(t, model) + assert.Empty(t, model) model = modelsIndex.GetModelsLiteInfoByBrick("arduino:object_detection") assert.Len(t, model, 1) From c70184146f78dc4ac1f5f9e6dae03e6d8ce479d0 Mon Sep 17 00:00:00 2001 From: mirkoCrobu Date: Thu, 20 Nov 2025 17:52:44 +0100 Subject: [PATCH 4/7] fix test end2end --- internal/api/docs/openapi.yaml | 7 +++++++ internal/e2e/client/client.gen.go | 6 +++++- internal/e2e/daemon/brick_test.go | 15 +++++++-------- internal/orchestrator/modelsindex/models_index.go | 6 +++--- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/internal/api/docs/openapi.yaml b/internal/api/docs/openapi.yaml index 3d0e30d2..93f772f1 100644 --- a/internal/api/docs/openapi.yaml +++ b/internal/api/docs/openapi.yaml @@ -1172,6 +1172,13 @@ components: type: string type: object AIModelLite: + properties: + description: + type: string + id: + type: string + name: + type: string type: object AIModelsListResult: properties: diff --git a/internal/e2e/client/client.gen.go b/internal/e2e/client/client.gen.go index d08272ac..1c83417d 100644 --- a/internal/e2e/client/client.gen.go +++ b/internal/e2e/client/client.gen.go @@ -53,7 +53,11 @@ type AIModelItem struct { } // AIModelLite defines model for AIModelLite. -type AIModelLite = map[string]interface{} +type AIModelLite struct { + Description *string `json:"description,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} // AIModelsListResult defines model for AIModelsListResult. type AIModelsListResult struct { diff --git a/internal/e2e/daemon/brick_test.go b/internal/e2e/daemon/brick_test.go index aaebe31f..c65b4194 100644 --- a/internal/e2e/daemon/brick_test.go +++ b/internal/e2e/daemon/brick_test.go @@ -30,7 +30,6 @@ import ( "github.com/arduino/arduino-app-cli/internal/e2e/client" "github.com/arduino/arduino-app-cli/internal/orchestrator/bricksindex" "github.com/arduino/arduino-app-cli/internal/orchestrator/config" - "github.com/arduino/arduino-app-cli/internal/orchestrator/modelsindex" "github.com/arduino/arduino-app-cli/internal/store" ) @@ -116,16 +115,16 @@ func TestBricksDetails(t *testing.T) { }, } - expectedModelLiteInfo := []modelsindex.AIModelLite{ + expectedModelLiteInfo := []client.AIModelLite{ { - ID: "mobilenet-image-classification", - Name: "General purpose image classification", - ModuleDescription: "General purpose image classification model based on MobileNetV2. This model is trained on the ImageNet dataset and can classify images into 1000 categories.", + Id: f.Ptr("mobilenet-image-classification"), + Name: f.Ptr("General purpose image classification"), + Description: f.Ptr("General purpose image classification model based on MobileNetV2. This model is trained on the ImageNet dataset and can classify images into 1000 categories."), }, { - ID: "person-classification", - Name: "Person classification", - ModuleDescription: "Person classification model based on WakeVision dataset. This model is trained to classify images into two categories: person and not-person.", + Id: f.Ptr("person-classification"), + Name: f.Ptr("Person classification"), + Description: f.Ptr("Person classification model based on WakeVision dataset. This model is trained to classify images into two categories: person and not-person."), }} response, err := httpClient.GetBrickDetailsWithResponse(t.Context(), validBrickID, func(ctx context.Context, req *http.Request) error { return nil }) require.NoError(t, err) diff --git a/internal/orchestrator/modelsindex/models_index.go b/internal/orchestrator/modelsindex/models_index.go index 54c9247a..90748ba9 100644 --- a/internal/orchestrator/modelsindex/models_index.go +++ b/internal/orchestrator/modelsindex/models_index.go @@ -54,9 +54,9 @@ type AIModel struct { } type AIModelLite struct { - ID string `yaml:"-"` - Name string `yaml:"name"` - ModuleDescription string `yaml:"description"` + ID string `json:"id"` + Name string `json:"name"` + ModuleDescription string `json:"description"` } type ModelsIndex struct { From 2b7e96642e60b5135508ceb9211e72db28d7c400 Mon Sep 17 00:00:00 2001 From: mirkoCrobu Date: Fri, 21 Nov 2025 15:52:31 +0100 Subject: [PATCH 5/7] refactoring --- internal/orchestrator/bricks/bricks.go | 8 ++++- internal/orchestrator/bricks/types.go | 32 +++++++++++-------- .../orchestrator/modelsindex/models_index.go | 25 --------------- .../modelsindex/modelsindex_test.go | 11 ------- 4 files changed, 25 insertions(+), 51 deletions(-) diff --git a/internal/orchestrator/bricks/bricks.go b/internal/orchestrator/bricks/bricks.go index 9c9c8711..098db55b 100644 --- a/internal/orchestrator/bricks/bricks.go +++ b/internal/orchestrator/bricks/bricks.go @@ -202,7 +202,13 @@ func (s *Service) BricksDetails(id string, idProvider *app.IDProvider, ApiDocsPath: apiDocsPath, CodeExamples: codeExamples, UsedByApps: usedByApps, - Models: s.modelsIndex.GetModelsLiteInfoByBrick(brick.ID), + Models: f.Map(s.modelsIndex.GetModelsByBrick(brick.ID), func(m modelsindex.AIModel) AIModelLite { + return AIModelLite{ + ID: m.ID, + Name: m.Name, + Description: m.ModuleDescription, + } + }), }, nil } diff --git a/internal/orchestrator/bricks/types.go b/internal/orchestrator/bricks/types.go index b7dc9b1b..73b585b3 100644 --- a/internal/orchestrator/bricks/types.go +++ b/internal/orchestrator/bricks/types.go @@ -15,8 +15,6 @@ package bricks -import "github.com/arduino/arduino-app-cli/internal/orchestrator/modelsindex" - type BrickListResult struct { Bricks []BrickListItem `json:"bricks"` } @@ -68,16 +66,22 @@ type AppReference struct { } type BrickDetailsResult struct { - ID string `json:"id"` - Name string `json:"name"` - Author string `json:"author"` - Description string `json:"description"` - Category string `json:"category"` - Status string `json:"status"` - Variables map[string]BrickVariable `json:"variables,omitempty"` - Readme string `json:"readme"` - ApiDocsPath string `json:"api_docs_path"` - CodeExamples []CodeExample `json:"code_examples"` - UsedByApps []AppReference `json:"used_by_apps"` - Models []modelsindex.AIModelLite `json:"models"` + ID string `json:"id"` + Name string `json:"name"` + Author string `json:"author"` + Description string `json:"description"` + Category string `json:"category"` + Status string `json:"status"` + Variables map[string]BrickVariable `json:"variables,omitempty"` + Readme string `json:"readme"` + ApiDocsPath string `json:"api_docs_path"` + CodeExamples []CodeExample `json:"code_examples"` + UsedByApps []AppReference `json:"used_by_apps"` + Models []AIModelLite `json:"models"` +} + +type AIModelLite struct { + ID string `json:"id"` + Name string `json:"name"` + Description string `json:"description"` } diff --git a/internal/orchestrator/modelsindex/models_index.go b/internal/orchestrator/modelsindex/models_index.go index 90748ba9..e18797f1 100644 --- a/internal/orchestrator/modelsindex/models_index.go +++ b/internal/orchestrator/modelsindex/models_index.go @@ -53,12 +53,6 @@ type AIModel struct { ModelConfiguration map[string]string `yaml:"model_configuration,omitempty"` } -type AIModelLite struct { - ID string `json:"id"` - Name string `json:"name"` - ModuleDescription string `json:"description"` -} - type ModelsIndex struct { models []AIModel } @@ -88,25 +82,6 @@ func (m *ModelsIndex) GetModelsByBrick(brick string) []AIModel { return matches } -func (m *ModelsIndex) GetModelsLiteInfoByBrick(brick string) []AIModelLite { - var matches []AIModelLite - for i := range m.models { - if len(m.models[i].Bricks) > 0 && slices.Contains(m.models[i].Bricks, brick) { - matches = append(matches, - AIModelLite{ - ID: m.models[i].ID, - Name: m.models[i].Name, - ModuleDescription: m.models[i].ModuleDescription, - }, - ) - } - } - if len(matches) == 0 { - return []AIModelLite{} - } - return matches -} - func (m *ModelsIndex) GetModelsByBricks(bricks []string) []AIModel { var matchingModels []AIModel for _, model := range m.models { diff --git a/internal/orchestrator/modelsindex/modelsindex_test.go b/internal/orchestrator/modelsindex/modelsindex_test.go index 238f043a..53ffb585 100644 --- a/internal/orchestrator/modelsindex/modelsindex_test.go +++ b/internal/orchestrator/modelsindex/modelsindex_test.go @@ -69,15 +69,4 @@ func TestModelsIndex(t *testing.T) { assert.Equal(t, "face-detection", models[0].ID) assert.Equal(t, "yolox-object-detection", models[1].ID) }) - - t.Run("it gets models lite by a brick", func(t *testing.T) { - model := modelsIndex.GetModelsLiteInfoByBrick("not-existing-brick") - assert.Empty(t, model) - - model = modelsIndex.GetModelsLiteInfoByBrick("arduino:object_detection") - assert.Len(t, model, 1) - assert.Equal(t, "face-detection", model[0].ID) - assert.Equal(t, "Face bounding box detection. This model is trained on the WIDER FACE dataset and can detect faces in images.", model[0].ModuleDescription) - assert.Equal(t, "Lightweight-Face-Detection", model[0].Name) - }) } From 4cf253576a2beb84f7367e40cdb4c1885f601372 Mon Sep 17 00:00:00 2001 From: mirkoCrobu Date: Fri, 21 Nov 2025 16:38:24 +0100 Subject: [PATCH 6/7] rename struct --- internal/api/docs/openapi.yaml | 20 ++++++++++---------- internal/e2e/client/client.gen.go | 16 ++++++++-------- internal/orchestrator/bricks/bricks.go | 4 ++-- internal/orchestrator/bricks/types.go | 4 ++-- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/internal/api/docs/openapi.yaml b/internal/api/docs/openapi.yaml index 93f772f1..0b767d6f 100644 --- a/internal/api/docs/openapi.yaml +++ b/internal/api/docs/openapi.yaml @@ -1147,6 +1147,15 @@ components: $ref: '#/components/schemas/ErrorResponse' description: Precondition Failed schemas: + AIModel: + properties: + description: + type: string + id: + type: string + name: + type: string + type: object AIModelItem: properties: brick_ids: @@ -1171,15 +1180,6 @@ components: runner: type: string type: object - AIModelLite: - properties: - description: - type: string - id: - type: string - name: - type: string - type: object AIModelsListResult: properties: models: @@ -1325,7 +1325,7 @@ components: type: string models: items: - $ref: '#/components/schemas/AIModelLite' + $ref: '#/components/schemas/AIModel' nullable: true type: array name: diff --git a/internal/e2e/client/client.gen.go b/internal/e2e/client/client.gen.go index 1c83417d..2325f388 100644 --- a/internal/e2e/client/client.gen.go +++ b/internal/e2e/client/client.gen.go @@ -41,6 +41,13 @@ const ( StarsDesc ListLibrariesParamsSort = "stars_desc" ) +// AIModel defines model for AIModel. +type AIModel struct { + Description *string `json:"description,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} + // AIModelItem defines model for AIModelItem. type AIModelItem struct { BrickIds *[]string `json:"brick_ids"` @@ -52,13 +59,6 @@ type AIModelItem struct { Runner *string `json:"runner,omitempty"` } -// AIModelLite defines model for AIModelLite. -type AIModelLite struct { - Description *string `json:"description,omitempty"` - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` -} - // AIModelsListResult defines model for AIModelsListResult. type AIModelsListResult struct { Models *[]AIModelItem `json:"models"` @@ -148,7 +148,7 @@ type BrickDetailsResult struct { CodeExamples *[]CodeExample `json:"code_examples"` Description *string `json:"description,omitempty"` Id *string `json:"id,omitempty"` - Models *[]AIModelLite `json:"models"` + Models *[]AIModel `json:"models"` Name *string `json:"name,omitempty"` Readme *string `json:"readme,omitempty"` Status *string `json:"status,omitempty"` diff --git a/internal/orchestrator/bricks/bricks.go b/internal/orchestrator/bricks/bricks.go index 098db55b..ae3cd3aa 100644 --- a/internal/orchestrator/bricks/bricks.go +++ b/internal/orchestrator/bricks/bricks.go @@ -202,8 +202,8 @@ func (s *Service) BricksDetails(id string, idProvider *app.IDProvider, ApiDocsPath: apiDocsPath, CodeExamples: codeExamples, UsedByApps: usedByApps, - Models: f.Map(s.modelsIndex.GetModelsByBrick(brick.ID), func(m modelsindex.AIModel) AIModelLite { - return AIModelLite{ + Models: f.Map(s.modelsIndex.GetModelsByBrick(brick.ID), func(m modelsindex.AIModel) AIModel { + return AIModel{ ID: m.ID, Name: m.Name, Description: m.ModuleDescription, diff --git a/internal/orchestrator/bricks/types.go b/internal/orchestrator/bricks/types.go index 73b585b3..f27b0652 100644 --- a/internal/orchestrator/bricks/types.go +++ b/internal/orchestrator/bricks/types.go @@ -77,10 +77,10 @@ type BrickDetailsResult struct { ApiDocsPath string `json:"api_docs_path"` CodeExamples []CodeExample `json:"code_examples"` UsedByApps []AppReference `json:"used_by_apps"` - Models []AIModelLite `json:"models"` + Models []AIModel `json:"models"` } -type AIModelLite struct { +type AIModel struct { ID string `json:"id"` Name string `json:"name"` Description string `json:"description"` From ebda234c736d1ff307bcd07012695a70d850e0c2 Mon Sep 17 00:00:00 2001 From: mirkoCrobu Date: Fri, 21 Nov 2025 16:53:21 +0100 Subject: [PATCH 7/7] fix tests --- internal/e2e/daemon/brick_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/e2e/daemon/brick_test.go b/internal/e2e/daemon/brick_test.go index c65b4194..488a670a 100644 --- a/internal/e2e/daemon/brick_test.go +++ b/internal/e2e/daemon/brick_test.go @@ -115,7 +115,7 @@ func TestBricksDetails(t *testing.T) { }, } - expectedModelLiteInfo := []client.AIModelLite{ + expectedModelLiteInfo := []client.AIModel{ { Id: f.Ptr("mobilenet-image-classification"), Name: f.Ptr("General purpose image classification"),