diff --git a/internal/api/docs/openapi.yaml b/internal/api/docs/openapi.yaml index f2b3a999..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: @@ -1314,6 +1323,11 @@ components: type: string id: type: string + models: + items: + $ref: '#/components/schemas/AIModel' + nullable: true + type: array name: type: string readme: @@ -1365,11 +1379,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..2325f388 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 ( @@ -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"` @@ -141,6 +148,7 @@ type BrickDetailsResult struct { CodeExamples *[]CodeExample `json:"code_examples"` Description *string `json:"description,omitempty"` Id *string `json:"id,omitempty"` + Models *[]AIModel `json:"models"` Name *string `json:"name,omitempty"` Readme *string `json:"readme,omitempty"` Status *string `json:"status,omitempty"` @@ -164,13 +172,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/e2e/daemon/brick_test.go b/internal/e2e/daemon/brick_test.go index fa1cab40..488a670a 100644 --- a/internal/e2e/daemon/brick_test.go +++ b/internal/e2e/daemon/brick_test.go @@ -115,6 +115,17 @@ func TestBricksDetails(t *testing.T) { }, } + expectedModelLiteInfo := []client.AIModel{ + { + 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: 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) require.Equal(t, http.StatusOK, response.StatusCode(), "status code should be 200 ok") @@ -133,5 +144,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 e8dea9da..ae3cd3aa 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 @@ -193,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, @@ -206,6 +202,13 @@ 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) AIModel { + return AIModel{ + 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 868c563a..f27b0652 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 { @@ -78,4 +77,11 @@ type BrickDetailsResult struct { ApiDocsPath string `json:"api_docs_path"` CodeExamples []CodeExample `json:"code_examples"` UsedByApps []AppReference `json:"used_by_apps"` + Models []AIModel `json:"models"` +} + +type AIModel struct { + ID string `json:"id"` + Name string `json:"name"` + Description string `json:"description"` }