Skip to content

JujiuYey/ollama-chat

Repository files navigation

πŸ€– Local AI Chat Application

δΈ­ζ–‡ | English

A modern local AI chat application built with React + TypeScript + Vite, specifically designed for local Ollama AI services. Provides a ChatGPT-like conversation experience with real-time interaction with local AI models like DeepSeek-R1:8b.

✨ Core Features

  • πŸ€– Local AI Model Integration - Direct communication with local Ollama service, no cloud API required
  • πŸ’¬ Real-time Chat Interface - Smooth chat experience with streaming and non-streaming responses
  • πŸ“± Responsive Design - Perfect adaptation for desktop and mobile devices
  • πŸŒ™ Theme Switching - Support for dark/light themes, personalized interface
  • πŸ’Ύ Local Data Storage - Chat history saved locally, privacy protection
  • 🎨 Modern UI - Beautiful interface design based on shadcn/ui
  • ⚑ Zero Backend Dependencies - Pure frontend application, simple deployment
  • πŸ”’ Privacy Protection - Data completely localized, no external service communication

πŸ› οΈ Tech Stack

  • Frontend Framework: React 18 + TypeScript + Vite
  • UI Component Library: shadcn/ui + Radix UI
  • Styling Solution: Tailwind CSS
  • State Management: Zustand
  • Build Tool: Vite 6.3.5
  • Package Manager: pnpm
  • AI Service: Local Ollama + DeepSeek-R1:8b model

πŸ“‹ Prerequisites

Before getting started, please ensure your system has the following software installed:

  • Node.js 18+
  • pnpm package manager
  • Ollama local AI service

Installing Ollama

  1. Visit Ollama Official Website to download and install
  2. Start Ollama service:
    ollama serve
  3. Download DeepSeek-R1 model:
    ollama pull deepseek-r1:8b

πŸš€ Quick Start

1. Clone Project

git clone <repository-url>
cd local-ai

2. Install Dependencies

pnpm install

3. Start Development Server

pnpm dev

4. Access Application

Open your browser and visit http://localhost:5173

πŸ“¦ Available Scripts

# Start development server
pnpm dev

# Build production version
pnpm build

# Preview build results
pnpm preview

# Code linting
pnpm lint

# Type checking
pnpm check

πŸ—οΈ Project Structure

src/
β”œβ”€β”€ components/          # React components
β”‚   β”œβ”€β”€ chat/           # Chat-related components
β”‚   β”‚   β”œβ”€β”€ ChatInterface.tsx    # Main chat interface
β”‚   β”‚   β”œβ”€β”€ MessageList.tsx      # Message list
β”‚   β”‚   β”œβ”€β”€ MessageInput.tsx     # Message input box
β”‚   β”‚   β”œβ”€β”€ Message.tsx          # Single message component
β”‚   β”‚   └── Sidebar.tsx          # Sidebar
β”‚   β”œβ”€β”€ settings/       # Settings-related components
β”‚   β”œβ”€β”€ ui/            # Basic UI components (shadcn/ui)
β”‚   β”œβ”€β”€ theme-provider.tsx       # Theme provider
β”‚   └── theme-toggle.tsx         # Theme toggle
β”œβ”€β”€ hooks/              # Custom hooks
β”‚   β”œβ”€β”€ useConversations.ts      # Conversation management
β”‚   β”œβ”€β”€ useSettings.ts           # Settings management
β”‚   └── useTheme.ts             # Theme management
β”œβ”€β”€ services/           # Service layer
β”‚   └── ollama.ts               # Ollama API client
β”œβ”€β”€ store/              # State management
β”‚   └── useAppStore.ts          # Global state
β”œβ”€β”€ types/              # TypeScript type definitions
β”œβ”€β”€ utils/              # Utility functions
└── pages/              # Page components
    └── App.tsx                 # Main application component

🎯 Core Functions

Chat Features

  • βœ… Real-time AI conversation
  • βœ… Message history
  • βœ… Multi-line text input
  • βœ… Markdown rendering support
  • βœ… Code syntax highlighting
  • βœ… Auto-scroll to latest message

Conversation Management

  • βœ… Create new conversation
  • βœ… Delete conversation
  • βœ… Browse conversation history
  • βœ… Export conversation records

Settings Configuration

  • βœ… Ollama service address configuration
  • βœ… AI model selection
  • βœ… Connection status detection
  • βœ… Theme switching
  • βœ… Font size adjustment

πŸ”§ Configuration

Ollama Connection Configuration

Default configuration:

  • Service Address: http://localhost:11434
  • Default Model: deepseek-r1:8b

You can modify these configurations in the settings page to suit your environment.

Supported Models

The application supports all Ollama-compatible models, including but not limited to:

  • DeepSeek-R1:8b
  • Llama 2/3
  • Mistral
  • CodeLlama
  • Other Ollama-supported models

πŸš€ Deployment

Production Build

# Build application
pnpm build

# Build artifacts are located in the dist/ directory

Deployment Options

  1. Static Hosting: Vercel, Netlify, GitHub Pages
  2. Self-hosting: Nginx + static file service
  3. Containerization: Docker + Nginx

Docker Deployment Example

FROM node:18-alpine as builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

πŸ”’ Privacy & Security

  • Local First: All conversation data is stored locally in the browser
  • No Cloud Dependencies: No data sent to any external services
  • Open Source Transparency: Code is completely open source and auditable
  • Data Control: Users have complete control over their data

🀝 Contributing

We welcome contributions of any kind!

  1. Fork this repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ Development Guidelines

  • Use TypeScript for type-safe development
  • Follow ESLint code standards
  • Use functional programming style for components
  • Use Zustand for state management
  • Follow responsive design principles

πŸ› Issue Reporting

If you encounter any issues or have feature suggestions, please:

  1. Check Issues for existing related issues
  2. If none exist, create a new Issue
  3. Describe the problem or suggestion in detail
  4. Provide reproduction steps (if it's a bug)

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

Thanks to the following open source projects:


Enjoy your conversation experience with local AI! πŸš€ parserOptions: { project: ['./tsconfig.node.json', './tsconfig.app.json'], tsconfigRootDir: import.meta.dirname, }, }, })

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors