-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: make recipes uses models based on backend property #1210
Merged
axel7083
merged 8 commits into
containers:main
from
axel7083:feature/recipes-should-list-models-based-on-backend
Jun 17, 2024
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6a3ca94
feat: make recipes uses models based on backend property
axel7083 87ded99
fix: recipe models tests
axel7083 3a6658f
fix: prettier&linter
axel7083 65dacd9
fix: recommended column tests
axel7083 2035239
fix: typecheck
axel7083 c3a1532
tests: remove old recommendation tests
axel7083 183ec02
fix: svelte check
axel7083 d7cd435
fix: multiple models recommendation
axel7083 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
packages/frontend/src/lib/table/model/ModelColumnRecipeRecommended.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
<script lang="ts"> | ||
import type { RecipeModelInfo } from '/@/models/RecipeModelInfo'; | ||
export let object: RecipeModelInfo; | ||
export let object: boolean; | ||
</script> | ||
|
||
{#if object.recommended} | ||
{#if object} | ||
<i class="fas fa-star fa-xs text-gray-900" title="Recommended model"></i> | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,44 @@ | ||
<script lang="ts"> | ||
import ModelColumnName from '/@/lib/table/model/ModelColumnName.svelte'; | ||
import { catalog } from '/@/stores/catalog'; | ||
import ModelColumnRecipeSelection from '../lib/table/model/ModelColumnRecipeSelection.svelte'; | ||
import ModelColumnRecipeRecommended from '../lib/table/model/ModelColumnRecipeRecommended.svelte'; | ||
import type { RecipeModelInfo } from '../models/RecipeModelInfo'; | ||
import ModelColumnIcon from '/@/lib/table/model/ModelColumnIcon.svelte'; | ||
import { Table, TableColumn, TableRow } from '@podman-desktop/ui-svelte'; | ||
import type { ModelInfo } from '@shared/src/models/IModelInfo'; | ||
|
||
export let modelsIds: string[] | undefined; | ||
export let selectedModelId: string; | ||
export let models: ModelInfo[]; | ||
export let recommended: string[]; | ||
export let selected: string; | ||
export let setSelectedModel: (modelId: string) => void; | ||
|
||
$: models = $catalog.models | ||
.filter(m => modelsIds?.includes(m.id)) | ||
.map((m, i) => { | ||
return { | ||
...m, | ||
recommended: i === 0, | ||
inUse: m.id === selectedModelId, | ||
} as RecipeModelInfo; | ||
}); | ||
$: models = models.map((m, i) => { | ||
return { | ||
...m, | ||
inUse: m.id === selected, | ||
}; | ||
}); | ||
|
||
const columns: TableColumn<RecipeModelInfo>[] = [ | ||
new TableColumn<RecipeModelInfo>('', { width: '20px', renderer: ModelColumnRecipeSelection }), | ||
new TableColumn<RecipeModelInfo>('', { width: '20px', renderer: ModelColumnRecipeRecommended }), | ||
new TableColumn<RecipeModelInfo>('', { width: '32px', renderer: ModelColumnIcon }), | ||
new TableColumn<RecipeModelInfo>('Name', { width: '4fr', renderer: ModelColumnName }), | ||
const columns = [ | ||
new TableColumn<ModelInfo>('', { width: '20px', renderer: ModelColumnRecipeSelection }), | ||
new TableColumn<ModelInfo, boolean>('', { | ||
width: '20px', | ||
renderer: ModelColumnRecipeRecommended, | ||
renderMapping: object => recommended.includes(object.id), | ||
}), | ||
new TableColumn<ModelInfo>('', { width: '32px', renderer: ModelColumnIcon }), | ||
new TableColumn<ModelInfo>('Name', { width: '4fr', renderer: ModelColumnName }), | ||
]; | ||
const row = new TableRow<RecipeModelInfo>({}); | ||
const row = new TableRow<ModelInfo>({}); | ||
|
||
function setModelToUse(selected: RecipeModelInfo) { | ||
function setModelToUse(selected: ModelInfo) { | ||
setSelectedModel(selected.id); | ||
} | ||
</script> | ||
|
||
{#if models} | ||
<div class="flex flex-col grow min-h-full"> | ||
<div class="w-full min-h-full flex-1"> | ||
<div class="h-full"> | ||
<Table kind="model" data="{models}" columns="{columns}" row="{row}" on:update="{e => setModelToUse(e.detail)}"> | ||
</Table> | ||
</div> | ||
<div class="flex flex-col grow min-h-full"> | ||
<div class="w-full min-h-full flex-1"> | ||
<div class="h-full"> | ||
<Table kind="model" data="{models}" columns="{columns}" row="{row}" on:update="{e => setModelToUse(e.detail)}" /> | ||
</div> | ||
</div> | ||
{/if} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There maybe several recommended models now