File size: 4,541 Bytes
9fa74cf
 
 
 
 
 
 
 
 
 
28bc3ca
9fa74cf
 
6a50e97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
---
title: Edge LLM Platform
emoji: πŸš€
colorFrom: blue
colorTo: purple
sdk: docker
sdk_version: "4.36.0"
app_file: app.py
pinned: false
license: mit
short_description: Local LLM platform with modern web interface
---

# πŸš€ Edge LLM Platform

A lightweight, local LLM inference platform with a modern web interface.

> **Note**: All development now happens directly in this repository (EdgeLLM_HF). This is both the development environment and the production Hugging Face Space.

## ✨ Features

### πŸ€– **Hybrid Model Support**
- **Local Models**: Run Qwen models locally for privacy
- **API Models**: Access powerful cloud models via [AiHubMix API](https://docs.aihubmix.com/en/api/Qwen)
- **Seamless Switching**: Switch between local and API models effortlessly
- **Thinking Models**: Support for models with visible reasoning process

### 🌐 **Available Models**

#### Local Models (Privacy-First)
- `Qwen/Qwen3-4B-Thinking-2507` - Local model with thinking process (~8GB)
- `Qwen/Qwen3-4B-Instruct-2507` - Local direct instruction model (~8GB)

#### API Models (Cloud-Powered)
- `Qwen/Qwen3-30B-A3B` - Advanced Qwen3 with dynamic thinking modes
- `qwen2.5-vl-72b-instruct` - Multimodal model with vision capabilities
- `Qwen/QVQ-72B-Preview` - Visual reasoning with thinking process

### 🎨 **Modern UI/UX**
- **Responsive Design**: Works on desktop and mobile
- **Chat Interface**: Beautiful conversation bubbles with session management
- **Model Management**: Easy switching between local and API models
- **Parameter Controls**: Temperature, max tokens, and system prompts
- **Session History**: Persistent conversations with localStorage

## πŸ“ Project Structure

```
EdgeLLM/
β”œβ”€β”€ frontend/        # 🎨 React frontend with ShadCN UI
β”œβ”€β”€ backend/         # πŸ”§ FastAPI backend
β”œβ”€β”€ static/          # πŸ“± Built frontend assets
β”œβ”€β”€ app.py           # 🌐 Production entry point
β”œβ”€β”€ requirements.txt # 🐍 Python dependencies
└── README.md        # πŸ“– Documentation
```

## 🎯 Quick Start

1. **Clone the repository**
   ```bash
   git clone https://huggingface.co/spaces/wu981526092/EdgeLLM
   cd EdgeLLM
   ```

2. **Set up environment variables**
   ```bash
   # Create .env file with your API credentials
   echo 'api_key="your-aihubmix-api-key"' > .env
   echo 'base_url="https://aihubmix.com/v1"' >> .env
   ```

3. **Install dependencies**
   ```bash
   pip install -r requirements.txt
   cd frontend && npm install && cd ..
   ```

4. **Run locally**
   ```bash
   python app.py
   ```

5. **Deploy changes**
   ```bash
   # Build frontend if needed
   cd frontend && npm run build && cd ..
   
   # Push to Hugging Face
   git add .
   git commit -m "Update: your changes"
   git push
   ```

## 🌐 Live Demo

Visit the live demo at: [https://huggingface.co/spaces/wu981526092/EdgeLLM](https://huggingface.co/spaces/wu981526092/EdgeLLM)

## πŸ”§ Configuration

### Environment Variables

For local development, create a `.env` file:
```bash
api_key="your-aihubmix-api-key"
base_url="https://aihubmix.com/v1"
```

For production (Hugging Face Spaces), set these as secrets:
- `api_key`: Your AiHubMix API key
- `base_url`: API endpoint (https://aihubmix.com/v1)

### API Integration

This platform integrates with [AiHubMix API](https://docs.aihubmix.com/en/api/Qwen) for cloud-based model access. Features include:

- OpenAI-compatible API interface
- Support for Qwen 3 series models
- Multimodal capabilities (text + vision)
- Streaming and non-streaming responses

## πŸ› οΈ Development Workflow

1. **Frontend development**: Work in `frontend/`
2. **Backend development**: Work in `backend/`
3. **Build frontend**: `cd frontend && npm run build`
4. **Deploy**: Standard git workflow
   ```bash
   git add .
   git commit -m "Your changes"
   git push
   ```

## πŸ—οΈ Architecture

### Backend (FastAPI)
- **Models Service**: Handles both local model loading and API client management
- **Chat Service**: Routes requests to appropriate generation method (local/API)
- **API Routes**: RESTful endpoints for model management and text generation
- **Configuration**: Environment-based settings for API credentials

### Frontend (React + TypeScript)
- **Modern UI**: Built with ShadCN components and Tailwind CSS
- **Chat Interface**: Real-time conversation with message bubbles
- **Model Management**: Easy switching between available models
- **Session Management**: Persistent chat history and settings

## πŸ“„ License

MIT License - see `LICENSE` for details.