Skip to content

Enhance Wiki Structure Generation and Refinement #84

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

Closed
wants to merge 4 commits into from

Conversation

hanerx
Copy link

@hanerx hanerx commented May 10, 2025

Enhance Wiki Structure Generation and Refinement

Changes

  1. Add Feature to generate a tree struct pages
  2. Add Feature to generate detailed sub pages from generated page

4fb099a1-bd9b-4279-b741-7be2705073ed

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Hello @hanerx, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request enhances the wiki structure generation and refinement process. It introduces the ability to generate a tree structure for pages and create detailed sub-pages from the generated pages. The changes include modifications to the API to support parent-child relationships between wiki pages, a new TreeView component in the React frontend to visualize the wiki structure, and updates to the prompt used for the LLM to generate wiki content, including instructions on how to create subpages and assign parent pages.

Highlights

  • Tree Structure Generation: The pull request introduces a TreeView component in the React frontend (src/app/[owner]/[repo]/page.tsx) to display the wiki pages in a hierarchical tree structure. This allows users to easily navigate the wiki and understand the relationships between pages.
  • Parent-Child Relationships: The pull request adds support for parent-child relationships between wiki pages. This is achieved by adding a parentPage field to the WikiPage model in the API (api/api.py and src/app/[owner]/[repo]/page.tsx) and updating the LLM prompt to include instructions on how to create subpages and assign parent pages (src/app/[owner]/[repo]/page.tsx).
  • Wiki Refinement: The refineWikiStructure function in src/app/[owner]/[repo]/page.tsx is updated to send the parent page content to the LLM, so that the LLM can generate more relevant subpages. The prompt is also updated to instruct the LLM to generate subpages and assign parent pages.
  • Merging Pages: The mergePages function in src/app/[owner]/[repo]/page.tsx is updated to handle the merging of existing pages with new pages generated by the LLM. This ensures that existing pages are not overwritten and that new pages are properly integrated into the wiki structure.

Changelog

Click here to see the changelog
  • .gitignore
    • Added .venv to the ignore list.
  • api/api.py
    • Added parentPage field to the WikiPage model.
  • api/openrouter_client.py
    • Added logic to extract parent page information from the wiki structure XML.
  • src/app/[owner]/[repo]/page.tsx
    • Added FaSitemap and FaChevronRight icons.
    • Added parentPage field to the WikiPage interface.
    • Implemented the TreeView component to display the wiki structure.
    • Modified the refineWikiStructure function to generate subpages and assign parent pages.
    • Modified the mergePages function to handle the merging of existing pages with new pages.
    • Added a button to refine the current page.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


A wiki's a garden,
Pages bloom, knowledge unfurls,
Linked roots, stories grow.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request introduces significant enhancements to the wiki structure generation and refinement process. The addition of the TreeView component and the ability to generate detailed subpages are valuable features. However, there are some areas where the code could be improved in terms of error handling, efficiency, and maintainability.

Summary of Findings

  • Missing Error Handling: The code extracts the parent page but does not handle the case where the parent page is not found or if there's an error during the search. This could lead to unexpected behavior or crashes.
  • Potential Infinite Loop in TreeView Component: The TreeView component uses a renderedPages ref to prevent circular references, but there's a potential issue if the pages prop changes frequently, as renderedPages.clear() is called before each render. This could lead to performance issues or an infinite loop if the component re-renders before the set is fully cleared.
  • Inconsistent XML Parsing: The code attempts to parse XML using both DOMParser and regex. While this provides a fallback mechanism, it introduces complexity and potential inconsistencies in how the XML is interpreted. It's better to rely on a single, robust XML parsing method.

Merge Readiness

The pull request introduces some valuable features, but there are several issues that need to be addressed before merging. The missing error handling, potential infinite loop in the TreeView component, and inconsistent XML parsing are all concerns that should be resolved. I recommend addressing these issues before merging. I am unable to directly approve this pull request, and users should have others review and approve this code before merging.

@sng-asyncfunc
Copy link
Contributor

Amazing!

@sng-asyncfunc
Copy link
Contributor

@hanerx Would love to invite you to join our discord server to further discuss: https://discord.gg/yJGR4JA7

@hanerx
Copy link
Author

hanerx commented May 10, 2025

@sng-asyncfunc Yeah, my discord name is hanerx

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.

2 participants