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

Feature: include category #2021

Merged
merged 11 commits into from
Oct 23, 2024

Conversation

bnodir
Copy link
Contributor

@bnodir bnodir commented Oct 5, 2024

Purpose

Adding "Include category" functionality in developer settings, with "All" as a default option. By combining data categorization with the prepdocs.py scripts, it lets you filter Azure AI Search based on categories. This functionality allows category-based inquiries and informs the user about the categories present in the search index.

This PR is somehow related to the following past issues:

Changes

  • Modified approach.py and models.ts to include category logic
  • Added translations for category ("All") in en, es, fr, and ja locales
  • Updated Ask.tsx and Chat.tsx to handle category
  • Updated data ingestion documentation

Quick insight

Here is an example of how categories appear when ingested into the search index:

  1. "category": "BenefitOptions"
  2. "category": "RoleLibrary"
  3. "category": "EmployeeHandbook"

image

Let's add category keys like this:
image

Then, in the default "All" category, we get answers from all three categories, like this:
image

When specifying a particular category, we get generated answers from that category's data:
image
image

Does this introduce a breaking change?

When developers merge from main and run the server, azd up, or azd deploy, will this produce an error?
If you're not sure, try it out on an old environment.

[ ] Yes
[x] No

Does this require changes to learn.microsoft.com docs?

This repository is referenced by this tutorial
which includes deployment, settings and usage instructions. If text or screenshot need to change in the tutorial,
check the box below and notify the tutorial author. A Microsoft employee can do this for you if you're an external contributor.

[x] Yes
[ ] No

Type of change

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:

Code quality checklist

See CONTRIBUTING.md for more details.

  • The current tests all pass (python -m pytest).
  • I added tests that prove my fix is effective or that my feature works
  • I ran python -m pytest --cov to verify 100% coverage of added lines
  • I ran python -m mypy to check for type errors
  • I either used the pre-commit hooks or ran ruff and black manually on my code.

- Modified approach.py to include category logic
- Updated models.ts with category types
- Added translations for category("All") in en, es, fr, and ja locales
- Updated Ask.tsx and Chat.tsx to handle category
- Updated data ingestion documentation
@jeannot-prvlimburg
Copy link

Are there any updates on this feature?

docs/data_ingestion.md Outdated Show resolved Hide resolved
@pamelafox
Copy link
Collaborator

@glaucia86 Could you suggest the pt-br strings for "All" and "Include category" so @bnodir can add to the new pt-br file for this PR?

Copy link
Contributor

@glaucia86 glaucia86 left a comment

Choose a reason for hiding this comment

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

For Spanish, sounds pretty good for me

app/frontend/src/locales/es/translation.json Outdated Show resolved Hide resolved
app/frontend/src/locales/es/translation.json Show resolved Hide resolved
Copy link
Collaborator

@pamelafox pamelafox left a comment

Choose a reason for hiding this comment

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

We need pt-br strings since I just merged that file, and I've asked humans to review the other strings.

@pamelafox
Copy link
Collaborator

@glaucia86 Thank you! Can you also provide the portuguese translations of those strings? The pt-br file isn't showing up in this PR since I just merged it in, but it needs updating with the same new strings.

app/frontend/src/locales/es/translation.json Outdated Show resolved Hide resolved
app/frontend/src/locales/es/translation.json Outdated Show resolved Hide resolved
app/frontend/src/locales/es/translation.json Outdated Show resolved Hide resolved
@bnodir
Copy link
Contributor Author

bnodir commented Oct 19, 2024

Thank you, everyone. I have made the changes based on the reviewers' feedback.

@zedhaque
Copy link
Contributor

Just wondering, if the category isn't mandatory and some documents don't have a category, will the "All" option include them? Thanks

@bnodir
Copy link
Contributor Author

bnodir commented Oct 19, 2024

@zedhaque - Yes, the "All" option includes documents that don't have a category as well.

@bnodir bnodir changed the title Add include category feature Feature: include category Oct 22, 2024
Copy link
Collaborator

@pamelafox pamelafox left a comment

Choose a reason for hiding this comment

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

I think we may have some confusion with "All", with people wondering if that includes uncategorized, but we can watch and see if any issues come in about that. Thank you! I'll ask @mattgotteiner for a review as well since this adds a search filter.

Copy link
Collaborator

@mattgotteiner mattgotteiner left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution!

@pamelafox pamelafox merged commit 0946893 into Azure-Samples:main Oct 23, 2024
17 checks passed
@bnodir bnodir deleted the feature/add-include-category branch October 24, 2024 10:41
@cforce
Copy link

cforce commented Oct 25, 2024

Does "All" also includes Uploaded Documents? It would be great to have as well "Uploaded" or "MyDocs"

@jeannot-prvlimburg
Copy link

Does "All" also includes Uploaded Documents? It would be great to have as well "Uploaded" or "MyDocs"

Yes, it does! It would indeed be helpful to tag manually uploaded documents with an "Uploaded" or "MyDocs" category to distinguish them easily. Additionally, supporting multiple categories would enable users to filter and select specific document subsets more precisely.

@bnodir
Copy link
Contributor Author

bnodir commented Oct 25, 2024

@jeannot-prvlimburg

I extended the list of choices in app/frontend/src/locales/en/translation.json to include:
"includeCategoryOptions": { "all": "All", "digitalisering": "Digitalisering" }
However, only "All" appears as an option in the dropdown, even though I'm using English as the language. Could you advise on what might be missing for the dropdown to display the additional option(s)?

Ensure your code looks like this:

                        aria-labelledby={includeCategoryId}
                        options={[
                            { key: "", text: t("labels.includeCategoryOptions.all") },   // ← Add comma
                            { key: "digitalisering", text: "Digitalisering" }   // ← Added new category line
                            // You can add a category key here for ingested data like below:
                            // { key: 'categoryName', text: 'Meaningful Category Name' }
                            // Alternatively, display the key to guide the user on what to type
                            // in the "Exclude category" field (e.g., 'Meaningful Category Name(categoryName)').
                        ]}

This should display the additional option in the dropdown. Additionally, please ensure to refresh your browser to see the changes.

@jeannot-prvlimburg
Copy link

@jeannot-prvlimburg

I extended the list of choices in app/frontend/src/locales/en/translation.json to include:
"includeCategoryOptions": { "all": "All", "digitalisering": "Digitalisering" }
However, only "All" appears as an option in the dropdown, even though I'm using English as the language. Could you advise on what might be missing for the dropdown to display the additional option(s)?

Ensure your code looks like this:

                        aria-labelledby={includeCategoryId}
                        options={[
                            { key: "", text: t("labels.includeCategoryOptions.all") },   // ← Add comma
                            { key: "digitalisering", text: "Digitalisering" }   // ← Added new category line
                            // You can add a category key here for ingested data like below:
                            // { key: 'categoryName', text: 'Meaningful Category Name' }
                            // Alternatively, display the key to guide the user on what to type
                            // in the "Exclude category" field (e.g., 'Meaningful Category Name(categoryName)').
                        ]}

This should display the additional option in the dropdown. Additionally, please ensure to refresh your browser to see the changes.

I found out indeed. Thanks for the help!

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.

10 participants