Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions internal/api/docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -1314,6 +1323,11 @@ components:
type: string
id:
type: string
models:
items:
$ref: '#/components/schemas/AIModel'
nullable: true
type: array
name:
type: string
readme:
Expand Down Expand Up @@ -1365,11 +1379,6 @@ components:
type: string
id:
type: string
models:
items:
type: string
nullable: true
type: array
name:
type: string
status:
Expand Down
23 changes: 15 additions & 8 deletions internal/e2e/client/client.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions internal/e2e/daemon/brick_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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))
})
}
11 changes: 7 additions & 4 deletions internal/orchestrator/bricks/bricks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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
}

Expand Down
20 changes: 13 additions & 7 deletions internal/orchestrator/bricks/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"`
}