NextChat

repository·main·Indexed 13 days ago

https://github.com/chatgptnextweb/nextchat

A lightweight, fast, and privacy-focused AI assistant client supporting multiple LLM providers including OpenAI, Claude, Gemini, and self-hosted models. Features include prompt templates (masks), artifacts, plugins, and Model Context Protocol (MCP) support. Designed for easy deployment on Vercel and Docker, with local browser-based data storage for enhanced privacy.

Tokens
22K
Snippets
63
Records
120
Agent score
99%

What's inside NextChat

  1. NextChat Core Features

    main

    NextChat is a lightweight AI assistant client with the following key capabilities:

    • Multi-Model Support: Works with Claude, DeepSeek, GPT-4, Gemini Pro, and more.
    • Privacy First: All chat data is stored locally in the user's browser.
    • Self-Hosted LLM Compatibility: Fully compatible with self-deployed models via RWKV-Runner or LocalAI.
    • Prompt Templates: Create, share, and debug chat tools using prompt templates (masks).
    • Artifacts: Preview and share generated content or webpages in a separate window.
    • Plugins: Supports network search, calculators, and other APIs.
    • Markdown Support: Full support for LaTeX, Mermaid diagrams, and code highlighting.
    • Desktop Support: Compact clients (~5MB) available for Linux, Windows, and MacOS.
  2. NextChat Enterprise Edition overview

    main

    The Enterprise Edition is designed for private corporate deployments and customization. Key features include:

    • Brand Customization: Tailored UI/VI to match corporate branding.
    • Resource Integration: Centralized management of multiple AI resources for teams.
    • Permission Management: Unified Admin Panel for managing member, resource, and knowledge base permissions.
    • Knowledge Integration: Connecting internal corporate knowledge bases with AI capabilities.
    • Security Auditing: Automatic blocking of sensitive queries and full conversation tracking.
    • Private Deployment: Support for private cloud deployments to ensure data security and privacy.

    For inquiries, contact: business@nextchat.dev

  3. Understand what is sent to the ChatGPT API

    main

    When a user sends a message, NextChat constructs a payload containing several layers of context to provide a rich experience. The payload includes:

    1. System-level Prompts: Instructions used to mimic the official ChatGPT WebUI experience (can be disabled in settings).
    2. History Summary: Provides long-term,
  4. How History Summary (历史摘要) works

    main

    History Summary is a lossy compression mechanism designed to maintain long-term context while staying within the API's token limits (e.g., the 4096 token limit for GPT-3.5).

    Mechanism

    When the chat history exceeds the defined History Compression Threshold:

    1. NextChat sends the unsummarized messages to the LLM.
    2. The LLM generates a concise summary (approx. 100 words).
    3. The original long text is replaced by this summary, effectively compressing the context.

    Best Practices

    • When to use: For long-running, continuous conversations where you need to maintain a general sense of the topic.
    • When to disable: For single-turn tasks like translation or information extraction. If you disable History Summary, it is recommended to also set the Attached History Count to 0 to ensure the model only sees the current prompt.
  5. Configure Proxies (Forward and Reverse)

    main

    If you cannot connect directly to the OpenAI API due to IP restrictions, you can use a proxy:

    • Forward Proxy: Use this if you have a proxy server address. For Docker deployments, set the HTTP_PROXY environment variable to your proxy address (e.g., 10.10.10.10:8002).
    • Reverse Proxy: Use this if you are using a proxy URL provided by someone else or set up via Cloudflare. Set the BASE_URL environment variable to the proxy address.
  6. Understand the concept of Masks (面具)

    main

    A Mask in NextChat is a composite preset that combines multiple elements to define a specific AI persona or behavior. It is more than just a prompt; it is a bundle containing:

    • Contextual Prompts: Multiple preset prompts used for In-Context Learning to guide output style or inject specific knowledge.
    • Model Settings: Default model parameters (like temperature or model name) applied to any conversation created with this mask.
    • Chat Settings: Configuration related to the conversation experience (e.g., role name, avatar).

    Use Masks to quickly switch between different specialized AI personalities without manually reconfiguring settings every time.

  7. Manage Chat vs. Global Settings

    main

    NextChat distinguishes between Global Settings (applied to all new chats) and Chat Settings (specific to the current conversation).

    Relationship and Synchronization

    • New Chats: By default, a new chat inherits all settings from the Global Settings.
    • Manual Overrides: If you manually change a setting within a specific chat (via the Chat Settings button), that chat de-synchronizes from the Global Settings. Changes made to Global Settings will no longer affect this specific chat.
    • Restoring Sync: To make a specific chat follow Global Settings again, enable the 使用全局设置 (Use Global Settings) option within the Chat Settings menu.

    Accessing Settings

    • Global Settings: Accessed via the settings icon at the bottom left of the page.
    • Chat Settings: Accessed via the settings icon located above the chat input box.
  8. Difference between GPT-3.5-TURBO and snapshot models

    main

    When selecting models, understand the difference between the rolling release and specific snapshots:

    • GPT-3.5-Turbo: The latest model version, which is constantly updated by OpenAI.
    • GPT-3.5-turbo-0301 (or similar date-based suffixes like MMDD): A frozen snapshot of the model from a specific date (e.g., March 1st). These versions are static and are expected to be replaced by newer snapshots periodically.
  9. Quickstart: Deploy NextChat via Vercel

    main

    To deploy your own private ChatGPT web application supporting Claude, GPT4, and Gemini Pro, follow these steps:

    1. Prepare your OpenAI API Key from the OpenAI platform.
    2. Deploy to Vercel: Click the Vercel deployment button (available in the repository) to clone the project.
    3. Configure Environment Variables: During the Vercel setup, you must provide the OPENAI_API_KEY. It is also highly recommended to set a CODE variable to restrict access.
    4. (Optional) Bind a Custom Domain: If you encounter DNS issues with the default Vercel domain, bind a custom domain via Vercel settings.
    # No CLI command required for Vercel deployment, use the web interface.
  10. Keep NextChat updated on Vercel

    main

    If you deployed NextChat by cloning the repository directly rather than forking it, you may see an "Updates Available" message. To ensure you can receive updates easily, follow these steps:

    1. Delete your existing Vercel deployment/repository.
    2. Go to the official NextChat repository and click the "Fork" button to create your own fork.
    3. Deploy your fork to Vercel.

    For more detailed instructions, refer to the Vercel tutorial.

  11. Configure Page Access Password using `CODE`

    main

    To prevent unauthorized users from consuming your API tokens, you can set an access password.

    1. Add an environment variable named CODE in your Vercel project dashboard.
    2. Set the value as a comma-separated list of passwords (e.g., pass1,pass2).
    3. Warning: Use passwords at least 7 characters long to prevent brute-force attacks.
    4. Important: You must re-deploy the project after changing this variable for it to take effect.

    Once configured, users must manually enter one of these codes in the settings page to chat.

    CODE=your_secure_password_here
  12. Set up local development environment

    main

    To develop on NextChat locally:

    1. Prerequisites: Install Node.js 18 and Yarn.

    2. Configuration: Create a .env.local file in the project root and add your API key:

      OPENAI_API_KEY=<your api key here>
    3. Run Development Server:

      yarn install && yarn dev

      Note: This command is for local development only. Do not use it for production deployment.

    4. Local Production Build: To simulate a production environment locally:

      yarn install && yarn build && yarn start
    yarn install && yarn dev