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

1607 add llm genrated tag #1655

Merged
merged 19 commits into from
Jan 16, 2025

Conversation

HuanFengYeh
Copy link
Collaborator

@HuanFengYeh HuanFengYeh commented Dec 4, 2024

Summary

A functional LLM tags Hierarchical filter

Checklist

  1. A new Instantsearch Facet that filters on Tags

  2. This new content should be toggleable by a new flag in FeatureFlags

Screenshots
Screenshot 2025-01-05 at 1 13 05 PM

Known issues
To improve the functionality we can add search bar to the filer.

Steps to test/reproduce

Go to the browse bill page.
Click on "+" to expand the tag
Click on subtitle to do the filter and check if tag shows on the top of search result.

Copy link

vercel bot commented Dec 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
maple-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 15, 2025 2:38am

Comment on lines 181 to 188
.ais-HierarchicalMenu-list .ais-HierarchicalMenu-list--child {
display: block;
display: inline-block;
overflow-y: visible;
margin: 0;
padding: 0 0 0 0rem;
width: 100%;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

For each item under .ais-HierarchicalMenu-list--child, could you add padding to the left, so we can differentiate between the parent and child tags?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The current version is close to what UI team design, but I also think add padding will help the readability.

@kiminkim724
Copy link
Collaborator

Also one thing to note, I think the styling is affecting the author RefinementList under Browse Testimony, so we might have to add another className to make sure the styles apply only to Browse Bill?

@HuanFengYeh
Copy link
Collaborator Author

Good Call! It is because I put the HierarchicalMenu in useRefinement. I should create another useHierarchical and combine two filter when creating the page.

Copy link
Collaborator

@Mephistic Mephistic left a comment

Choose a reason for hiding this comment

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

Overall looks pretty solid - a few notes with one noticeable bug I think should be addressed before we merge.

Bug Report:
Screenshot 2025-01-06 at 4 31 29 AM

Repro Steps: (Using Firefox)

  • Filter by a subtopic
  • Click on a Bill Result to navigate to that bill's detail page
  • Hit "Back" in your browser

Results:

  • The Hierarchical filter seem to get added to the search state hundreds of times

tsconfig.json Outdated
@@ -14,7 +14,8 @@
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true
"incremental": true,
"downlevelIteration": true
Copy link
Collaborator

Choose a reason for hiding this comment

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

OOC, why is this necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is for iteration, but it is not necessary I can rewrite the code!

@@ -30,6 +31,31 @@ const searchClient = new TypesenseInstantSearchAdapter({
}
}).searchClient

const extractLastSegmentOfRefinements = (items: any[]) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Could we put a more specific type on items than any?

Copy link
Collaborator

Choose a reason for hiding this comment

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

And I feel like we could put a more specific name on this function since it doesn't apply to all refinements? It's specifically for cleaning up the labels for HierarchicalMenu refinements - so maybe something more like displayLowestTierForHierarchical / extractLowestTierForHierarchical?

@@ -30,6 +31,31 @@ const searchClient = new TypesenseInstantSearchAdapter({
}
}).searchClient

const extractLastSegmentOfRefinements = (items: any[]) => {
return items.map(item => {
console.log(item)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: We should probably remove this console.log before merging

const extractLastSegmentOfRefinements = (items: any[]) => {
return items.map(item => {
console.log(item)
if (item.label != "topics.lvl1") return item
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not a blocker, just curious: Is there a type field on item that would identify hierarchical facets so we could make this more generic? (e.g. if item's type is actually something like CurrentRefinementsConnectorParamsRefinement, it would have a type enum field that has a hierarchical option - we'd have to test to see if that applies in our case, but it'd be preferable to not have to call out specific fields if it's a straightforward adjustment).

Copy link
Collaborator

@Mephistic Mephistic Jan 16, 2025

Choose a reason for hiding this comment

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

For posterity - we addressed this offline and it seems this info is sadly not readily available in the state we'd like. This is fine as is.

@seatuna
Copy link
Collaborator

seatuna commented Jan 8, 2025

Overall looks pretty solid - a few notes with one noticeable bug I think should be addressed before we merge.

Bug Report: Screenshot 2025-01-06 at 4 31 29 AM

Repro Steps: (Using Firefox)

  • Filter by a subtopic
  • Click on a Bill Result to navigate to that bill's detail page
  • Hit "Back" in your browser

Results:

  • The Hierarchical filter seem to get added to the search state hundreds of times

For an extra data point: I just followed these steps in Opera and Chrome, and it crashes the page so I don't even see the bill results anymore. The warning in the console tells me it's trying to add the little chip tag to the UI 1000+ times
image

Copy link
Collaborator

@Mephistic Mephistic left a comment

Choose a reason for hiding this comment

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

LGTM - thanks again for all your hard work on getting this over the finish line!

@Mephistic Mephistic merged commit 491fb83 into codeforboston:main Jan 16, 2025
7 checks passed
Mephistic added a commit that referenced this pull request Jan 28, 2025
* Create adminPage test

* Admin account sign in

* Setup login to admin account and create no user report test

* Setting admin account

* Update yarn.lock adn package.json

* Add icon display test

* Add e2e test for admin page

* Add sorting, user reports and upgrade requests page test

* Merged with upstream main

* modified follow button to prevent navigating to another page

* Make test serial and rewrite reslove report test

* LLM summarization and tagging features added

* Added readme.md file

* fixed follow button to accurately show following or not

* Remove setup from playwright congig and delte the auth file

* Run prettier

* Update llm/demo_app_functions.py

Co-authored-by: Nathan E. Sanders <[email protected]>

* Update llm/demo_app_functions.py

Co-authored-by: Nathan E. Sanders <[email protected]>

* Update llm/readme.md

Co-authored-by: Nathan E. Sanders <[email protected]>

* Update llm/readme.md

Co-authored-by: Nathan E. Sanders <[email protected]>

* Update llm/readme.md

Co-authored-by: Nathan E. Sanders <[email protected]>

* Update llm/readme.md

Co-authored-by: Nathan E. Sanders <[email protected]>

* Merged changes from remote to local

* Changed the file names as per code review

* Added necessary instrcutions for openAI API key

* Updated requirements.txt file

* Move the credentials to .env

* fixed the follow button on the bill details page

* Adding topics to bills to prep for LLM data, Hard-coding the category -> topic map because that should be frozen as a product decision, Updating search indexing for bills to hydrate topic categories and properly format the bill topics so they can be used in the front-end by the Instantsearch hierarchical menu widget

* Added python version in readme.md file

* Added more detailed explanation on why we chunk with a length of 2000

* Updating topics and categories to reflect the finalized assignments, making capitalization consistent across topics, making topics an optional field across both Bill data types

* Extracting category/topic building to helper function, fixing type error

* Adding base summary field to bill models

* Adding kiminkim724 as CODEOWNER

* Add .env.example and Updated README with instructions

* Update README

* Update README

* Extracting PaginationButtons for translation

* Extracting translatable strings from HearingsScheduled component

* Extracting translation strings from Legislative Process learn page

* Extracting strings from Testimony Panel CTAs

* Extracting translation strings for YourTestimony component

* Extracting strings for translation for ThankYouModal

* Using translated string for EditTestimonyButton tooltip

* Extracting translation strings from SubmitTestimonyForm

* Extracting translatable strings from ChooseStance component

* Extracting translatable strings for SelectLegislatorsCta component

* Extracting translatable strings for KeepNote component

* Extracting translatable strings from WriteTestimony component in publish flow

* Capitalizing all headers for legislative process learn page per PR feedback

* Update publishNotifications to include Bill History Updates

* Added 2 new API functions, one to generate summaries and tags using summaries combined and the second one is to generate only tags using summaries

* Updated prettierignore to ignore llm directory for Prettier check

* Bill Topic Updates (#1647)

* Switching bill topic format per dev feedback, extracting topic parser for later use, adding unit tests for topic parser

* Prettier fixes

* Llm bill summary (#1645)

* initial dividers

* translations for literal strings

* update common.json

* mobile sizing for smart summary

* smart disclaimer

* feature flagging

* smart tags

* mobile pruning

* cleanup

* cleaned up old court banner translation

* added icon files

* remaining icons

* nowrap enforced on SmartTagButton to fix firefox issue

* switch smart-summary image from png to svg and moved to subfolder

* cleanup common.json

* translation

* navigation

* footer

* added auth translation file to newsfeed page

* adjust filter positioning

* newsfeed bill card work

* bill card almost done

* polished newsfeed bill card

* enable follow organizations tab display

* userLookup

* Create notificationEvent on BillHistory Updates (#1648)

* Create notificationEvent on BillHistory Updates

* Add authorUid

* Updated Notification types to be more explicit with possible undefined fields

* Add useState

* fix following button

* isBillMatch

* reminder to clean out old code

* cleanup

* upgrade Profile page to use new follow context

* cleanup

* change Orgs -> Users You Follow

* renamed components

* update stories to new naming scheme

* testimony card title

* cleanup

* fixed broken Bill Updates filter

* testimony card body basic

* cleaned up NewsfeedCard

* fixed stories

* mobile spacing

* adjust mobile breakpoint

* cleanup

* refactored CardTitle using switch

* Update firestore indexes to include topicName

* Added notification fields on back-end to supply more information to Newsfeed

* Make the Notification types more explicit for Testimony vs Bill History notifications (#1659)

* Make the notification return type more explicit

* Added billId field to types

* Fix lint

* Revert ignoreUndefinedProperties

* updated testimony author link

* cleanup

* cleanup props

* prop cleanup

* bill notifications updated

* replaced header with billId on CardTitleFollowing

* more cleanup

* updated stories

* polish

* translations

* Follow btn individual users (#1654)

* feat: follow buttons for individual users

* fix: remove second follow user button

* fix: user cannot follow their own testimony hit

* fix: rn prettier

* link to Edit Profile - Following Tab

* mobile nav link

* cleanup

* removed useless code line

* removed more useless code

* fixed mobile nav double light up bug

* dev comments

* combined navbar files

* move social info to own row

* added FollowedContent and YourTestimonies buttons

* connected SettingsModal to View Profile page

* recolored buttons

* bug fix

* cleaned up integration tests

* updated stories

* deactivated ProfileHeader story - to be updated later

* updated ProfileSettingsModal story

* updated personalInfoTal.stories

* updated EditProfilePage.stories

* cleanup

* fixed modal not updating after save

* cleanup

* cleanup

* fixed Edit Profile button to link to correct tab

* deactivated outdated stories

* resized Edit Profile button

* fix: hide follow btn for logged out users bill detail pg

* Used query instead of function in Firebase

* Remove unused imports and functions

* fix: ran prettier

* count fixed (#1673)

* count fixed

* Forgot to commit changes before push

* 1607 add llm genrated tag (#1655)

* add hierarchicalMenu(fake data)

* Update HierarchialMenu

* Update menu with llm data

* Create useHierarchicalMenu and fix add padding to the left of child

* Craete a customize HierarchicalMenuWidget

* update css for llm tag menu

* Delete the parent counting and sort parent Alphabetical

* Baypass typesense error

* Delete the algoliasearch dependncy

* Add Col to testimony Search

* Add refinement

* Implement sorting logic for llm tags display

* Extract the subtitle for filter tags

* Add updated facets into getItems and remove redinment from useHierarachicalMenu

* Run prettier

* Change the iteration and detelet the downlevelIteration

* Add filter to getWidgetSearchParameter

* Newsfeed Content Buttons (#1672)

* newsfeed content buttons

* repositioned newsfeed buttons

* added prop on ProfileHeader

* added / to image src (#1678)

* added / to image src

* cleanup

* typo

* feat: bill follow and unfollow functionality to testimony page (#1661)

* feat: bill follow and unfollow functionality to testimony page

* ran prettier

* fix: remove unnecesary code

* fix: run linter

---------

Co-authored-by: Merritt Baggett <[email protected]>

* V2 style copy updates (#1680)

* undo main commit

* fix: v2 styple copy and updates

* feat: fixed hyperlink and summary

* feat: fixed hyperlink and summary

* fix: remove summary spacing

* Add HierarchicalMenu after InstantSearch initialize (#1684)

* Add HierarchicalMenu after InstantSearch initialize

* Run prettier

* removed obsolete spinner (#1686)

---------

Co-authored-by: huanfeng <[email protected]>
Co-authored-by: LauraUmana <[email protected]>
Co-authored-by: pranay8297 <[email protected]>
Co-authored-by: Nathan E. Sanders <[email protected]>
Co-authored-by: huanfeng <[email protected]>
Co-authored-by: kiminkim724 <[email protected]>
Co-authored-by: Kimin Kim <[email protected]>
Co-authored-by: mertbagt <[email protected]>
Co-authored-by: Merritt Baggett <[email protected]>
Co-authored-by: Aaron <[email protected]>
Co-authored-by: aerhartic <[email protected]>
Co-authored-by: ananyasinghz <[email protected]>
Co-authored-by: Huanfeng <[email protected]>
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.

4 participants