Skip to content

woolcoxm/LocalChat.ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LocalChat.ai

A LocalChat.ai application powered by the DeepSeek API, featuring a modern chat interface with customizable response styles and conversation management.

Features

  • 🤖 DeepSeek API Integration - High-performance AI chat with cost-effective pricing
  • 🎨 Multiple Response Styles - Balanced, Concise, Explanatory, Formal, and Friendly modes
  • 💬 Conversation Management - Persistent chat history with local storage
  • 🔄 Real-time Streaming - Smooth, responsive chat experience
  • 📱 Responsive Design - Works seamlessly on desktop and mobile
  • 🛡️ Robust Error Handling - Graceful fallbacks and retry mechanisms
  • 💾 Data Export/Import - Backup and restore your conversations
  • Context Management - Automatic context window optimization

Quick Start

Prerequisites

Installation

  1. Clone the repository

    git clone <your-repo-url>
    cd LocalChat.ai
  2. Install dependencies

    npm install
  3. Set up environment variables

    cp .env.example .env

    Edit .env and add your DeepSeek API key:

    DEEPSEEK_API_KEY=your_api_key_here
    DEEPSEEK_BASE_URL=https://api.deepseek.com
    PORT=3001
    
  4. Start the application

    npm start

    This will start both the backend server (port 3001) and frontend (port 3000).

  5. Open in browser

    http://localhost:3000
    

Architecture

Backend (/server)

  • Express.js server with API routes
  • DeepSeek API integration with retry logic
  • Prompt templates system for style customization
  • Error handling with proper HTTP status codes

Frontend (/src)

  • React 18 with modern hooks
  • Component-based architecture
  • Local storage for conversation persistence
  • Axios for API communication
  • Markdown rendering for AI responses

Key Components

src/
├── components/
│   ├── ChatSidebar.jsx      # Conversation history
│   ├── ChatHeader.jsx       # Style selector
│   ├── ChatContainer.jsx    # Message display
│   ├── Message.jsx          # Individual message
│   └── MessageInput.jsx     # Input area
├── services/
│   ├── chatService.js       # API communication
│   └── conversationManager.js # Local storage
└── utils/
    └── errorHandling.js     # Error management

Response Styles

The application supports five different response styles:

  • Balanced - Well-rounded responses with appropriate detail
  • Concise - Brief, direct answers focused on key points
  • Explanatory - Detailed explanations with context and examples
  • Formal - Professional tone suitable for business contexts
  • Friendly - Warm, conversational tone for casual interactions

Configuration

Environment Variables

Variable Description Default
DEEPSEEK_API_KEY Your DeepSeek API key Required
DEEPSEEK_BASE_URL DeepSeek API endpoint https://api.deepseek.com
PORT Backend server port 3001

DeepSeek API Settings

The application is configured with optimal settings for chat:

  • Model: deepseek-chat
  • Temperature: 0.7 (balanced creativity)
  • Max Tokens: 4000 (substantial responses)
  • Top-p: 0.95 (diverse vocabulary)

Storage & Privacy

  • Local Storage Only - All conversations stored in browser
  • No Cloud Sync - Complete privacy and control
  • Export/Import - JSON format for backup
  • Automatic Cleanup - Limits storage to prevent bloat

Error Handling

The application includes comprehensive error handling:

  • Network Errors - Retry with exponential backoff
  • Rate Limiting - Automatic retry with appropriate delays
  • API Errors - User-friendly error messages
  • Storage Errors - Graceful degradation
  • Context Overflow - Automatic message truncation

Development

Project Structure

LocalChat.ai/
├── src/                 # React frontend
│   ├── components/      # UI components
│   ├── services/        # Business logic
│   └── utils/           # Utilities
├── server/              # Express backend
│   ├── routes/          # API endpoints
│   └── services/        # Backend services
├── package.json         # Dependencies
└── vite.config.js       # Build configuration

Available Scripts

npm run dev      # Start frontend development server
npm run server   # Start backend server only
npm start        # Start both frontend and backend
npm run build    # Build for production
npm run preview  # Preview production build

API Endpoints

  • POST /api/chat/message - Send chat message
  • GET /api/chat/styles - Get available response styles
  • GET /api/health - Health check

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Support


Built with ❤️ using DeepSeek AI and modern web technologies.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors