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

add buildin plugin #5508

Merged
merged 3 commits into from
Sep 24, 2024
Merged

Conversation

lloydzhou
Copy link
Contributor

@lloydzhou lloydzhou commented Sep 23, 2024

💻 变更类型 | Change Type

  • feat
  • fix
  • refactor
  • perf
  • style
  • test
  • docs
  • ci
  • chore
  • build

🔀 变更说明 | Description of Change

  1. add buildin plugin
  2. remove usingProxy

📝 补充信息 | Additional Information

Summary by CodeRabbit

  • New Features
    • Simplified plugin management interface by removing conditional rendering for built-in plugins.
    • Introduced new plugins: "Dalle3," "ArxivSearch," and "DuckDuckGoLiteSearch" with integrated functionalities.
  • Bug Fixes
    • Streamlined proxy usage configuration, enhancing user experience.
  • Refactor
    • Updated plugin initialization logic for better performance and clarity.

Copy link

vercel bot commented Sep 23, 2024

@lloydzhou is attempting to deploy a commit to the NextChat Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Sep 23, 2024

Walkthrough

The changes involve modifications to the plugin management system, including the removal of certain UI elements in the PluginPage component, updates to the plugin store logic, and the introduction of a new JSON file containing plugin definitions. The EyeIcon and proxy-related features have been eliminated to streamline the user interface. Additionally, the plugin store now supports enhanced configuration and initialization based on the application's build mode, along with new plugin entries defined in a JSON format.

Changes

Files Change Summary
app/components/plugin.tsx Removed EyeIcon import and related conditional rendering; simplified UI to show only EditIcon for all plugins; eliminated checkbox for proxy usage based on client configuration.
app/store/plugin.ts Added getClientConfig import; removed usingProxy from Plugin type; updated logic for baseURL and headers; modified usePluginStore to allow specified id for plugins; added onRehydrateStorage method for plugin rehydration.
public/plugins.json Introduced a JSON file with three plugin entries: "Dalle3," "ArxivSearch," and "DuckDuckGoLiteSearch," each with an id, name, and schema URL.

Suggested reviewers

  • Dogtiti

Poem

In the garden where plugins play,
A new dawn breaks, brightening the way.
No more eyes to peek and pry,
Just edit tools for us to try.
With JSON seeds, our dreams take flight,
Hopping forward, all feels right! 🐇✨


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 90e7b5a and f9f9963.

Files selected for processing (1)
  • app/store/plugin.ts (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/store/plugin.ts

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@lloydzhou lloydzhou self-assigned this Sep 23, 2024
Copy link
Contributor

Your build has completed!

Preview deployment

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

Outside diff range and nitpick comments (2)
public/plugins.json (1)

1-17: Review the use of ghp.ci proxy for schema URLs

All schema URLs in this file use the ghp.ci proxy to access GitHub raw content. While this approach may have benefits (e.g., bypassing rate limits, caching), it also introduces potential risks:

  1. Security: Ensure that ghp.ci is a trusted service, as it will have access to the schema data.
  2. Reliability: The plugin functionality now depends on both GitHub and the proxy service being available.
  3. Maintenance: Any changes to the proxy service might require updates to these URLs.

Consider the following:

  1. Document the reason for using this proxy in a comment within the file or in the project documentation.
  2. Implement a fallback mechanism to access the schemas directly if the proxy fails.
  3. Regularly review and update the proxy usage to ensure it still meets the project's needs and security requirements.
app/store/plugin.ts (1)

234-234: Remove debugging statement before production release

The console.log("onRehydrateStorage", state); line is useful for debugging but should be removed or disabled in production code to prevent unnecessary console output and potential exposure of sensitive information.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4c3fd55 and ed20fd2.

Files selected for processing (3)
  • app/components/plugin.tsx (1 hunks)
  • app/store/plugin.ts (4 hunks)
  • public/plugins.json (1 hunks)
Additional comments not posted (6)
public/plugins.json (3)

1-17: LGTM: Well-structured JSON for plugin definitions

The overall structure of the JSON file is correct and follows best practices:

  • It uses a JSON array to store multiple plugin definitions, allowing for easy scalability.
  • Each plugin is represented as an object with consistent properties (id, name, schema).
  • The file is well-formatted and easy to read.

2-6: Verify the Dalle3 plugin schema URL

The Dalle3 plugin entry looks good overall. However, please ensure that:

  1. The schema URL is correct and accessible.
  2. The use of the ghp.ci proxy is intentional and necessary.

To verify the schema URL, you can run the following command:

#!/bin/bash
# Verify the accessibility of the Dalle3 plugin schema
curl -I "https://ghp.ci/https://raw.githubusercontent.com/ChatGPTNextWeb/NextChat-Awesome-Plugins/main/plugins/dalle/openapi.json"

This will check if the URL is accessible and returns a valid response.


7-11: Verify the ArxivSearch plugin schema URL

The ArxivSearch plugin entry is structured correctly. As with the Dalle3 plugin:

  1. Verify that the schema URL is correct and accessible.
  2. Confirm that the use of the ghp.ci proxy is intentional and necessary.

To verify the schema URL, you can run the following command:

#!/bin/bash
# Verify the accessibility of the ArxivSearch plugin schema
curl -I "https://ghp.ci/https://raw.githubusercontent.com/ChatGPTNextWeb/NextChat-Awesome-Plugins/main/plugins/arxivsearch/openapi.json"

This will check if the URL is accessible and returns a valid response.

app/components/plugin.tsx (1)

Line range hint 1-424: Verify complete removal of usingProxy feature

The changes in this file are minimal and focused on simplifying the UI for plugin actions. However, the removal of the usingProxy feature mentioned in the PR objectives is not directly visible in this file.

Please run the following script to verify the complete removal of the usingProxy feature across the codebase:

#!/bin/bash
# Description: Check for any remaining references to the 'usingProxy' feature

# Test: Search for 'usingProxy' in all TypeScript and TypeScript React files
rg --type typescript --type tsx 'usingProxy' app/

# Test: Search for proxy-related UI elements or logic
rg --type typescript --type tsx 'proxy.*checkbox|checkbox.*proxy' app/

If any results are returned, please ensure that these references are intentional or remove them to complete the feature removal.

app/store/plugin.ts (2)

57-59: Confirm the logic for setting baseURL and X-Base-URL

The baseURL and X-Base-URL are set based on the isApp variable. Ensure that this logic aligns with the desired behavior:

  • When !isApp (i.e., not in the export build mode), baseURL is set to "/api/proxy" and X-Base-URL is set to serverURL.
  • When isApp, baseURL is set to serverURL, and X-Base-URL is undefined.

Verify that this setup correctly configures the proxy usage and server URLs in different build modes.


63-69: Verify security implications when using openaiApiKey with the DALL·E 3 plugin

The code attempts to use the user's openaiApiKey for the "dalle3" plugin when tokenValue is not present. Ensure that this behavior is intentional and does not introduce security risks, such as exposing the user's API key to third-party services without explicit consent.

Run the following script to identify all usages of openaiApiKey and verify its handling:

Verification successful

**** The usage of openaiApiKey with the DALL·E 3 plugin is intentional and does not introduce apparent security risks based on current findings. Ensure that API keys are only transmitted in headers and are not exposed in logs or unintended network requests.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all instances where 'openaiApiKey' is accessed or used.

# Search for 'openaiApiKey' in the codebase with context lines.
rg 'openaiApiKey' --type js --type ts -A 5 -B 5

Length of output: 6098

public/plugins.json Show resolved Hide resolved
app/components/plugin.tsx Show resolved Hide resolved
app/store/plugin.ts Outdated Show resolved Hide resolved
app/store/plugin.ts Outdated Show resolved Hide resolved
app/store/plugin.ts Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Outside diff range and nitpick comments (2)
app/store/plugin.ts (2)

234-234: Remove unnecessary console.log statement

The console.log("onRehydrateStorage", state); statement may clutter the console output in production and potentially expose internal state information. Consider removing it to keep the console clean.


242-244: Specify concrete types instead of using 'any'

Using any reduces type safety and can lead to runtime errors. Consider specifying the appropriate types for item to enhance code reliability and maintainability.

Apply the following changes:

- res.map((item: any) =>
+ res.map((item: Plugin) =>
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ed20fd2 and 90e7b5a.

Files selected for processing (1)
  • app/store/plugin.ts (4 hunks)

app/store/plugin.ts Show resolved Hide resolved
app/store/plugin.ts Outdated Show resolved Hide resolved
@Dogtiti Dogtiti merged commit 649c5be into ChatGPTNextWeb:main Sep 24, 2024
1 of 2 checks passed
@lloydzhou lloydzhou deleted the feature-buildin-plugin branch September 26, 2024 13:35
@coderabbitai coderabbitai bot mentioned this pull request Oct 11, 2024
Closed
10 tasks
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