PureChat Documentation

website·Indexed 31 days ago

https://docs.purechat.cn/

A unified interface combining traditional instant messaging with AI-driven conversation, serving as both a functional chat application and an AI development framework. Built with Vue 3 for a reactive UI across platforms.

Tokens
1.3K
Snippets
5
Records
14
Agent score
0%

What's inside PureChat

  1. Overview of PureChat

    PureChat is a functional chat application and AI development framework that integrates traditional instant messaging with AI-driven conversations. It supports two primary operation modes: Local Mode (default) and Tencent Cloud IM SDK mode.
  2. Set up local development environment

    Ensure the following tools are installed to avoid dependency or startup errors:

    • Git: Required for version control.
    • NodeJS: Version $\ge$ 18.20.0 (recommended 18.20.0+). Use nvm for version management.
    • pnpm: Version $\ge$ 8.7.0 (latest recommended).
  3. Inspect client-side console errors in PureChat

    To debug issues in the PureChat client:

    1. Focus the PureChat client window and press Ctrl+Shift+I (Windows/Linux) or Command+Option+I (Mac).
    2. Open the console before triggering the error (e.g., before clicking 'Test' or starting a conversation).
    3. Navigate to the Network tab.
    4. Locate the request marked with a red × (typically completions or generations).
    5. Click the Response tab to view the full error details.
  4. Integrate AI models in PureChat

    PureChat integrates several large language models including OpenAI, Ollama, DeepSeek, and Zhipu. It supports context understanding, chain-of-thought (thinking process), web search integration, custom system prompts, and streaming output. Users must provide their own API keys.
  5. Deploy PureChat to Vercel

    Follow these steps to deploy the project to Vercel:

    1. Fork the PureChat repository to your GitHub account.
    2. Connect your GitHub account to Vercel.
    3. Create a new project in Vercel, select the forked repository, and configure the required environment variables.
    4. For domestic (China) access without a VPN: Add a CNAME record in your domain DNS settings pointing to cname.vercel-dns.com, then configure this domain in the Vercel project settings.
  6. Configure routing mode and dev tools in .env

    You can change the routing mode to hash to avoid 404 errors on static servers if you cannot modify the server configuration. These settings are managed in the .env file.
    # Whether to enable vue-devtools (Y/N)
    VITE_DEV_TOOLS = 'Y'
    
    # vue-router mode: hash | history
    VITE_ROUTER_HISTORY = 'hash'
    
    # Whether to generate production source maps (Y/N)
    VITE_SOURCE_MAP = 'N'
  7. Switch between Local and Tencent Cloud IM modes

    PureChat allows users to toggle between Local Mode and Tencent Cloud IM SDK mode using an environment variable in the .env configuration file.
    VITE_LOCAL_MODE=true # or false to switch modes
  8. Configure npm mirror and hoisting in .npmrc

    PureChat uses a specific .npmrc configuration to ensure dependency compatibility and use the Taobao mirror for faster installation in China.
    registry=https://registry.npmmirror.com/
    shamefully-hoist=true
    ignore-workspace-root-check=true
  9. Enable and configure Tencent IM SDK

    To switch from local AI tool mode to a full instant messaging system (supporting multi-device sync, cloud storage, and group chats), enable the Tencent Cloud SDK mode in the .env file.

    Steps to get credentials:

    1. Register a Tencent Cloud account.
    2. Create an application in the IM Console.
    3. Obtain the appid and appkey and initialize the SDK.
    # Set to 'N' to enable Tencent Cloud SDK mode (Default is 'Y' for local mode)
    VITE_LOCAL_MODE=N
  10. Fix 404 errors on page refresh after web build

    When using history routing mode, web servers like Nginx look for physical files (e.g., login.html) and return a 404 if they aren't found. To fix this, you must configure the server to redirect all requests to index.html so vue-router can handle the routing, or switch the frontend to hash mode.
    # nginx.conf
    server {
      listen 80;
      server_name localhost;
    
      location / {
        root /usr/share/nginx/html;
        index index.html index.htm;
        try_files $uri $uri/ /index.html;
      }
    
      error_page 500 502 503 504 /50x.html;
      location = /50x.html {
        root /usr/share/nginx/html;
      }
    }
  11. Configure PureChat via environment variables

    PureChat uses environment variables for high-level configuration across three main categories:

    1. Core Application Settings: Local/Cloud mode, router history mode, storage prefixes, and base URLs.
    2. AI Provider Settings: API keys, base URLs, and model configurations for various providers.
    3. Build Configuration: CDN usage, development tools, and source mapping.
  12. PureChat Desktop (Electron) Features

    The Electron-based desktop version of PureChat includes specific OS-level integrations:

    • Taskbar icon flashing notifications for new messages.
    • Custom screenshot generation and sharing.
    • Support for external protocol URI schemes to open the app.
    • Real-time file download progress tracking.
    • Custom Notification window styles.
    • System tray integration for background operation.