-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add search to website #8624
Add search to website #8624
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-builds.s3.amazonaws.com/5c8645ac6c49943aac2db9b1a597672c348d70bb/gradio-4.37.2-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@5c8645ac6c49943aac2db9b1a597672c348d70bb#subdirectory=client/python" Install Gradio JS Client from this PR npm install https://gradio-builds.s3.amazonaws.com/5c8645ac6c49943aac2db9b1a597672c348d70bb/gradio-client-1.2.1.tgz |
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
Maintainers or the PR author can modify the PR title to modify this entry.
|
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.
Just looked at the functionality and I think it works well @aliabd ! Sometimes the ranking of the matches was a bit off. For example, I'd expect the Oauth guide to be near the top when searching "oauth" but it's the sixth result. Something we can fix in v2 if it isn't an obvious fix.
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.
Heck yeah @aliabd! Works super well in my tests
The only nit I have is: would it be possible to automatically select the first search result, so that you could press enter and it would navigate to that page without having to navigate down and select it?
I thought I commented about this, but it seems to have disappeared: navigating to the right section in the page. For some searches, like "iframe" or "WaveformOptions", it would be great if it navigated to the right section in the page. Overall, not a huge pain point though. |
return results | ||
.map((index) => pages[index as number]) | ||
.map(({ slug, title, content, type }) => { | ||
return { | ||
slug, | ||
title: replace_text_with_marker(title, match), | ||
content: get_matches(content, match), | ||
type | ||
}; | ||
}); |
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.
i'm getting a type error here locally (though the CI seems to pass lol)
return results | |
.map((index) => pages[index as number]) | |
.map(({ slug, title, content, type }) => { | |
return { | |
slug, | |
title: replace_text_with_marker(title, match), | |
content: get_matches(content, match), | |
type | |
}; | |
}); | |
return results | |
.map((index: number) => pages[index as number]) | |
.map(({ slug, title, content, type }: Page) => { | |
return { | |
slug, | |
title: replace_text_with_marker(title, match), | |
content: get_matches(content, match), | |
type | |
}; | |
}); |
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.
weird i get an error with your change:
Argument of type '(index: number) => Page' is not assignable to parameter of type '(value: Id, index: number, array: Id[]) => Page'.
Types of parameters 'index' and 'value' are incompatible.
Type 'Id' is not assignable to type 'number'.
Type 'string' is not assignable to type 'number'.ts(2345)
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.
but i don't see an error otherwise
Co-authored-by: Hannah <hannahblair@users.noreply.github.com>
…adio into aliabd/docs-search
@freddyaboulton @abidlabs you're right that the ranking is a bit off. Maybe on v2 I can rank by # of occurrences on the page. I don't think prioritizing headers makes sense for how the code is structured right now, but will look into it. Navigating to the right spot would be killer imo but i definitely will need to rework how i'm generating the content database for that to work. Will do that in v2. @abidlabs We can't autofocus the first result because it will take the cursor off the search box. @hannahblair thanks for the changes! addressed all except for the one on search.ts |
Not a big deal at all, but could pressing enter automatically go the first link? |
@abidlabs ok I made it work. First link is always in "focus" and pressing enter will go there, otherwise arrow down will move to the next link. Try it out and lmk what you think. I think it's pretty neat! |
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.
LGTM looks great to me @aliabd!
* latex fix * format * add changeset * fix demo (#8696) * Better spacing for codeblocks on docs (#8686) * styling for codeblocks * add changeset * formatting * add changeset * changes --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Add search to website (#8624) * Update action.yml (#8702) * Model3D point cloud and wireframe display modes (#8687) * display modes * add changeset * test fixes * lint * Update gradio/components/model3d.py Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * solid --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Fix playground to display errors (#8689) * Fix the Playground on the website to trigger run_code() and install() with debounce and to display errors * Remove an unused function, make_full_screen() * Format demo/hello_world/run.py * Update notebook * add changeset * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * GRADIO_ALLOWED_PATHS & GRADIO_BLOCKED_PATHS comma separated environme… (#8705) * GRADIO_ALLOWED_PATHS & GRADIO_BLOCKED_PATHS comma separated environment variables * GRADIO_ALLOWED_PATHS & GRADIO_BLOCKED_PATHS comma separated environment variables * add changeset * Document GRADIO_ALLOWED_PATHS and GRADIO_BLOCKED_PATHS --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> * Ensure JS client `status_callback` functionality works and improve status messages (#8699) * * bind handle_space_success * ensure status callbacks work correctly * add changeset * test fixes + refactor * tweak * test * Revert "test" This reverts commit db1afc4. --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * Documents auth in the guides, in the view API page, and also types the Blocks.config object (#8720) * auth docs * changes * add changeset * add changeset * add changeset * type * changes * snippets * import * add changeset * changes * fix typing --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> * remove on mount * merge * remove onmount --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: pngwn <hello@pngwn.io> Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> Co-authored-by: Yuichiro Tachibana (Tsuchiya) <t.yic.yt@gmail.com> Co-authored-by: cocktailpeanut <121128867+cocktailpeanut@users.noreply.github.com> Co-authored-by: Hannah <hannahblair@users.noreply.github.com>
Search!
closes: #2121
While this works really well as it is currently, I will probably need to do another pass to clean out all the regex. The challenge was that for docs especially some of the content exists in jsons and some in the templates. So to get the content in a searchable dictionary i need to render it first, which means i need to remove the html code using regex.
There must be a better way to do this, and hopefully its a way that will let us link to specific ids on the page so that the user can get closer to the query. I'm open to changing a lot of the code, especially all the ugly stuff in the search-api, so please leave feedback!
It searches through all the docs and guides