Skip to content
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(tags): added tags to ai lab recipes #2522

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

gastoner
Copy link
Contributor

@gastoner gastoner commented Feb 13, 2025

What does this PR do?

Adds tags to recipes in AI lab

Screenshot / video of UI

Screenshot 2025-02-17 110633

What issues does this PR fix or reference?

Closes #2104

How to test this PR?

Use this PR merging to PD podman-desktop/podman-desktop#11213 in combination with this PR, otherwise you wont see the colors
Go to recipes in ai lab

@MariaLeonova
Copy link

@gastoner can you please add screenshots and/or video of the changes?

@gastoner
Copy link
Contributor Author

@gastoner can you please add screenshots and/or video of the changes?

Yes, when it is done I will, it is not done yet

Signed-off-by: Evzen Gasta <evzen.ml@seznam.cz>
@gastoner gastoner marked this pull request as ready for review February 17, 2025 12:11
@gastoner gastoner requested review from benoitf, jeffmaury and a team as code owners February 17, 2025 12:11
@gastoner gastoner force-pushed the ai_lab_tags branch 2 times, most recently from 79464d9 to 33c1413 Compare February 17, 2025 12:19
Signed-off-by: Evzen Gasta <evzen.ml@seznam.cz>
@gastoner gastoner marked this pull request as draft February 17, 2025 12:38
Copy link

@MariaLeonova MariaLeonova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gastoner thank you for the screenshot! One question to clarify the behavior: so when a user presses 2 more, and one card expends, will the other cards in the same row expand as well?

@gastoner
Copy link
Contributor Author

@gastoner thank you for the screenshot! One question to clarify the behavior: so when a user presses 2 more, and one card expends, will the other cards in the same row expand as well?

No, only the card that was clicked will expand

@gastoner
Copy link
Contributor Author

@MariaLeonova which colors should I use for the tags (text and background) for the light/dark theme respectively?

@MariaLeonova
Copy link

@gastoner these were the initial proposed colors:
Screenshot 2025-02-18 at 9 35 18

@gastoner
Copy link
Contributor Author

gastoner commented Feb 18, 2025

Needs to be merged after podman-desktop/podman-desktop#11213 - colors for AI Lab Tags

@gastoner gastoner marked this pull request as ready for review February 18, 2025 13:28
Signed-off-by: Evzen Gasta <evzen.ml@seznam.cz>
Signed-off-by: Evzen Gasta <evzen.ml@seznam.cz>
@axel7083
Copy link
Contributor

Needs to be merged after #2522 - colors for AI Lab Tags

@gastoner you linked this PR?

Copy link
Contributor

@axel7083 axel7083 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

I don't have any colors ? 🤔

@gastoner
Copy link
Contributor Author

Needs to be merged after #2522 - colors for AI Lab Tags

@gastoner you linked this PR?

Yess, you need to use this PR from PD repository in combination with this PR

@gastoner gastoner requested a review from axel7083 February 18, 2025 15:04
Copy link
Contributor

@axel7083 axel7083 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM on my side

Since we are depending on Podman Desktop colors merged in (podman-desktop/podman-desktop#11213)

We need to update the minimum version we need to run on

io.podman-desktop.api.version=">= 1.8.0"

to 1.17.0.

Signed-off-by: Evzen Gasta <evzen.ml@seznam.cz>
@gastoner gastoner requested a review from axel7083 February 18, 2025 16:14
content: string;
backgroundColor?: string;
textColor?: string;
className?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use class the in the props do class: className, so we use traditional props

interface Props {
icon?: IconDefinition;
content: string;
backgroundColor?: string;
Copy link
Contributor

@axel7083 axel7083 Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to use backgroundColor? I feel like this should be included in the class prop?

Comment on lines 37 to 44
class ResizeObserver {
observe = vi.fn();
disconnect = vi.fn();
unobserve = vi.fn();
}

beforeAll(() => {
Object.defineProperty(window, 'ResizeObserver', { value: ResizeObserver });
Copy link
Contributor

@axel7083 axel7083 Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should move the ResizeObserver to the setup.vitest.js to avoid repeating it everywhere? (can be a follow up)

Comment on lines 12 to 22
const useCases = ['natural-language-processing', 'audio', 'computer-vision'];
const languages = ['java', 'javascript', 'python'];
const frameworks = ['langchain', 'langchain4j', 'quarkus', 'react', 'streamlit', 'vectordb'];
const tools = ['none', 'llama-cpp', 'whisper-cpp'];

const tags: string[] = [
...recipe.categories,
...(recipe.backend !== undefined ? [recipe.backend] : []),
...(recipe.frameworks ?? []),
...(recipe.languages ?? []),
];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this to a dedicated constants / tags-constant / please find a nice name file ? as those are constants ? (user uppercase for constants

Comment on lines 33 to 42
if (useCases.includes(tag)) {
return 'bg-[var(--pd-label-primary-bg)]';
} else if (languages.includes(tag)) {
return 'bg-[var(--pd-label-secondary-bg)]';
} else if (frameworks.includes(tag)) {
return 'bg-[var(--pd-label-tertiary-bg)]';
} else if (tools.includes(tag)) {
return 'bg-[var(--pd-label-quaternary-bg)]';
}
return 'bg-[var(--pd-label-primary-bg)]';
Copy link
Contributor

@axel7083 axel7083 Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is computation heavy, lot of includes O(n * count) (with count number of condition check).

You could create a map such as

const TAG_BG_COLOR = new Map([
    ...useCases.map((useCase) => [useCase, 'bg-[var(--pd-label-primary-bg)]']),
    ...languages.map((useCase) => [useCase, 'bg-[var(--pd-label-secondary-bg)]']),
    ...frameworks.map((useCase) => [useCase, 'bg-[var(--pd-label-tertiary-bg)]']),
    ...tools.map((useCase) => [useCase, 'bg-[var(--pd-label-quaternary-bg)]']),
]);

and determineBackgroundColor became

function determineBackgroundColor(tag: string): string {
return TAG_BG_COLOR.get(tag) ?? 'bg-[var(--pd-label-primary-bg)]';
}

Please the TAG_BG_COLOR should be created in a dedicated constants file, creating a map in each component would waste resources

Same for the text colors

Copy link
Contributor

@axel7083 axel7083 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, so in todays daily, I mention this PR, and how it depends on colors, that will be available only in podman desktop >= 1.17

@jeffmaury confirmed, that we should do one of the following

  • hardcode the colors in the tailwindcss to avoid having this hard dependency on a recent version of podman-desktop (Because we want to release ai-lab 1.5 before podman desktop 1.17).
  • Delay this PR for next release (ai-lab 1.6).

I would rather have the colors hardcoded (at least for the 1.5, and have an issue created with a 1.6 milestone, to remove those hardcoded colors)

@gastoner
Copy link
Contributor Author

Okay, so in todays daily, I mention this PR, and how it depends on colors, that will be available only in podman desktop >= 1.17

@jeffmaury confirmed, that we should do one of the following

* hardcode the colors in the tailwindcss to avoid having this hard dependency on a recent version of podman-desktop (Because we want to release ai-lab 1.5 before podman desktop 1.17).

* Delay this PR for next release (ai-lab 1.6).

I would rather have the colors hardcoded (at least for the 1.5, and have an issue created with a 1.6 milestone, to remove those hardcoded colors)

I agree, I don't want to hard-code colors. So I would (since the colors are merged already):

  1. Hardcode the colors until the 1.15 is out
  2. After 1.15 remove the hardcoded values and use ones from PD + update the min version of PD

@gastoner gastoner force-pushed the ai_lab_tags branch 2 times, most recently from 05d528e to 875d02d Compare February 19, 2025 13:01
Signed-off-by: Evzen Gasta <evzen.ml@seznam.cz>
Copy link

@MariaLeonova MariaLeonova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good from the UX POV.

Signed-off-by: Evzen Gasta <evzen.ml@seznam.cz>
Signed-off-by: Evzen Gasta <evzen.ml@seznam.cz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implementation of tags on the recipes
3 participants