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

fix: user catalog #916

Merged
merged 6 commits into from
Apr 18, 2024
Merged

fix: user catalog #916

merged 6 commits into from
Apr 18, 2024

Conversation

axel7083
Copy link
Contributor

What does this PR do?

See #792 (comment) for details

When we were importing a model we were copying to existing catalog, and creating a new one with the user's models in it. This lead to the issue that the catalog was not updated.

This PR fixes this issue, by having the user's catalog a complementary catalog, being merged at startup with the one provided by the extension. By this method, the user can define recipes, models or categories in a json file, and they will be added to the existing one if properly formatted.

When importing models, this file is automatically created and filled with the user's models details.

Screenshot / video of UI

Enregistrement.2024-04-17.151545.mp4

What issues does this PR fix or reference?

Fixes #792

How to test this PR?

  • existing tests ensure no regression.

Manually

  • (1) Go to the models catalog and import models
  • (2) Delete imported models
  • (3) Restart AI-Lab
  • (4) Delete the user-catalog.json file

Signed-off-by: axel7083 <[email protected]>
@axel7083 axel7083 requested review from benoitf and a team as code owners April 17, 2024 13:16
@axel7083 axel7083 requested review from jeffmaury and lstocchi April 17, 2024 13:16
@axel7083 axel7083 changed the title fix: catalog user fix: user catalogue Apr 17, 2024

const sanitize = this.sanitize(content);
this.catalog = {
models: [...defaultCatalog.models, ...sanitize.models],
Copy link
Contributor

Choose a reason for hiding this comment

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

Here we give priority on the bundled catalog, what is user wants to override a recipe or model

Copy link
Contributor Author

@axel7083 axel7083 Apr 18, 2024

Choose a reason for hiding this comment

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

He can't. What would be the use case ?

ℹ️ There is no priority as it is an array. All recipe provided will appear, potential issue could append if multiple recipe/models have the same id however, do you want to fix that by giving the priority to the user's content ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should check if there are multiple items with the same id. In the rare case that it may happen we could have issues as we manage the models as a map.

Copy link
Contributor

Choose a reason for hiding this comment

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

He can't. What would be the use case ?

ℹ️ There is no priority as it is an array. All recipe provided will appear, potential issue could append if multiple recipe/models have the same id however, do you want to fix that by giving the priority to the user's content ?

Overriding a recipe because either you want to test a specific commit (more devs) or add a new model to a recipe

Copy link
Contributor

@lstocchi lstocchi Apr 18, 2024

Choose a reason for hiding this comment

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

If that's the goal it already works this way. If you have in the user catalog an entry with an id = one item in the default catalog you will see the custom one. Atleast for the models

@benoitf benoitf changed the title fix: user catalogue fix: user catalog Apr 17, 2024
Copy link
Contributor

@jeffmaury jeffmaury left a comment

Choose a reason for hiding this comment

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

README.Md should be updaed as well as the file name changed

@axel7083 axel7083 requested a review from jeffmaury April 18, 2024 08:19
Signed-off-by: axel7083 <[email protected]>
Copy link
Contributor

@lstocchi lstocchi left a comment

Choose a reason for hiding this comment

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

Works fine for me. There is just the edge case when there are two items having the same id to be decided how to be handled

@jeffmaury
Copy link
Contributor

Works fine for me. There is just the edge case when there are two items having the same id to be decided how to be handled

I would be to give preference to the user one but that could be a follow up PR

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
axel7083 and others added 2 commits April 18, 2024 11:23
Co-authored-by: Luca Stocchi <[email protected]>
Signed-off-by: axel7083 <[email protected]>
@axel7083
Copy link
Contributor Author

@lstocchi @jeffmaury

I updated the code to let the user's item overwrite the default items when ids are conflicting.

image

ℹ️ Here is an example overwriting the ChatBot.

I also added two tests to ensure the expected behaviour.

@axel7083 axel7083 requested a review from lstocchi April 18, 2024 09:32
Copy link
Contributor

@lstocchi lstocchi left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

Signed-off-by: axel7083 <[email protected]>
Copy link
Contributor

@jeffmaury jeffmaury left a comment

Choose a reason for hiding this comment

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

LGTM

@axel7083 axel7083 merged commit cf01470 into containers:main Apr 18, 2024
4 checks passed
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.

ai.json updates may not be seen by users using a custom catalog
3 participants