Spaces:
Build error
Build error
Commit ·
63e82f2
1
Parent(s): e14d9d9
feat: Implement chat interface with persistent history and modern design
Browse files- Add .gitignore to exclude unnecessary files and directories
- Create settings.json for VSCode configuration
- Introduce CHAT_INTERFACE_IMPLEMENTATION.md detailing the chat interface features and architecture
- Develop API endpoint for chat history management in chat.ts
- Update index.tsx to support chat message sending and history retrieval
- Revamp globals.css for a Material Design 3 themed UI with improved styles
- .gitignore +116 -0
- .vscode/settings.json +3 -0
- CHAT_INTERFACE_IMPLEMENTATION.md +329 -0
- pages/api/chat.ts +69 -0
- pages/index.tsx +248 -86
- styles/globals.css +493 -82
.gitignore
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
| 2 |
+
|
| 3 |
+
# dependencies
|
| 4 |
+
/node_modules
|
| 5 |
+
/.pnp
|
| 6 |
+
.pnp.js
|
| 7 |
+
.yarn/install-state.gz
|
| 8 |
+
|
| 9 |
+
# testing
|
| 10 |
+
/coverage
|
| 11 |
+
|
| 12 |
+
# next.js
|
| 13 |
+
/.next/
|
| 14 |
+
/out/
|
| 15 |
+
|
| 16 |
+
# production
|
| 17 |
+
/build
|
| 18 |
+
|
| 19 |
+
# misc
|
| 20 |
+
.DS_Store
|
| 21 |
+
*.pem
|
| 22 |
+
|
| 23 |
+
# debug
|
| 24 |
+
npm-debug.log*
|
| 25 |
+
yarn-debug.log*
|
| 26 |
+
yarn-error.log*
|
| 27 |
+
|
| 28 |
+
# local env files
|
| 29 |
+
.env*.local
|
| 30 |
+
.env
|
| 31 |
+
.env.development.local
|
| 32 |
+
.env.test.local
|
| 33 |
+
.env.production.local
|
| 34 |
+
|
| 35 |
+
# vercel
|
| 36 |
+
.vercel
|
| 37 |
+
|
| 38 |
+
# typescript
|
| 39 |
+
*.tsbuildinfo
|
| 40 |
+
next-env.d.ts
|
| 41 |
+
|
| 42 |
+
# IDE - VSCode
|
| 43 |
+
.vscode/*
|
| 44 |
+
!.vscode/settings.json
|
| 45 |
+
!.vscode/tasks.json
|
| 46 |
+
!.vscode/launch.json
|
| 47 |
+
!.vscode/extensions.json
|
| 48 |
+
.history
|
| 49 |
+
|
| 50 |
+
# IDE - IntelliJ
|
| 51 |
+
.idea/
|
| 52 |
+
*.iml
|
| 53 |
+
*.iws
|
| 54 |
+
*.ipr
|
| 55 |
+
|
| 56 |
+
# System Files
|
| 57 |
+
.DS_Store
|
| 58 |
+
Thumbs.db
|
| 59 |
+
|
| 60 |
+
# Chat history data
|
| 61 |
+
chat-history.json
|
| 62 |
+
|
| 63 |
+
# Slingshot folder
|
| 64 |
+
.slingshot/
|
| 65 |
+
|
| 66 |
+
# Optional npm cache directory
|
| 67 |
+
.npm
|
| 68 |
+
|
| 69 |
+
# Optional eslint cache
|
| 70 |
+
.eslintcache
|
| 71 |
+
|
| 72 |
+
# Optional REPL history
|
| 73 |
+
.node_repl_history
|
| 74 |
+
|
| 75 |
+
# Output of 'npm pack'
|
| 76 |
+
*.tgz
|
| 77 |
+
|
| 78 |
+
# Yarn Integrity file
|
| 79 |
+
.yarn-integrity
|
| 80 |
+
|
| 81 |
+
# parcel-bundler cache
|
| 82 |
+
.cache
|
| 83 |
+
.parcel-cache
|
| 84 |
+
|
| 85 |
+
# Next.js cache
|
| 86 |
+
.next
|
| 87 |
+
|
| 88 |
+
# Nuxt.js build / generate output
|
| 89 |
+
.nuxt
|
| 90 |
+
dist
|
| 91 |
+
|
| 92 |
+
# Gatsby files
|
| 93 |
+
.cache/
|
| 94 |
+
public
|
| 95 |
+
|
| 96 |
+
# vuepress build output
|
| 97 |
+
.vuepress/dist
|
| 98 |
+
|
| 99 |
+
# Serverless directories
|
| 100 |
+
.serverless/
|
| 101 |
+
|
| 102 |
+
# FuseBox cache
|
| 103 |
+
.fusebox/
|
| 104 |
+
|
| 105 |
+
# DynamoDB Local files
|
| 106 |
+
.dynamodb/
|
| 107 |
+
|
| 108 |
+
# TernJS port file
|
| 109 |
+
.tern-port
|
| 110 |
+
|
| 111 |
+
# Stores VSCode versions used for testing VSCode extensions
|
| 112 |
+
.vscode-test
|
| 113 |
+
|
| 114 |
+
# Temporary folders
|
| 115 |
+
tmp/
|
| 116 |
+
temp/
|
.vscode/settings.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"Slingshot.readFileLineLimit": 3000
|
| 3 |
+
}
|
CHAT_INTERFACE_IMPLEMENTATION.md
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Chat Interface Implementation Guide
|
| 2 |
+
|
| 3 |
+
## Overview
|
| 4 |
+
This document describes the complete transformation of the Ollama UI from a simple prompt-response interface to a modern, Google Material Design 3 themed chat application with persistent chat history.
|
| 5 |
+
|
| 6 |
+
## Features Implemented
|
| 7 |
+
|
| 8 |
+
### 1. **Modern Chat Interface**
|
| 9 |
+
- Real-time message display with user and assistant messages
|
| 10 |
+
- Auto-scrolling to latest messages
|
| 11 |
+
- Typing indicator during message generation
|
| 12 |
+
- Empty state with helpful instructions
|
| 13 |
+
- Message timestamps and model information
|
| 14 |
+
|
| 15 |
+
### 2. **Persistent Chat History**
|
| 16 |
+
- Local file-based storage (`chat-history.json`)
|
| 17 |
+
- Messages persist across page refreshes
|
| 18 |
+
- Automatic loading of chat history on app start
|
| 19 |
+
- Each message includes:
|
| 20 |
+
- Unique ID
|
| 21 |
+
- Role (user/assistant)
|
| 22 |
+
- Content
|
| 23 |
+
- Timestamp
|
| 24 |
+
- Model used
|
| 25 |
+
|
| 26 |
+
### 3. **Clear Chat History**
|
| 27 |
+
- Dedicated button in the header (🗑️ icon)
|
| 28 |
+
- Confirmation dialog before clearing
|
| 29 |
+
- Clears both UI state and persistent storage
|
| 30 |
+
|
| 31 |
+
### 4. **Settings Panel**
|
| 32 |
+
- Collapsible settings panel (⚙️ icon)
|
| 33 |
+
- Model selection dropdown
|
| 34 |
+
- Pull new models functionality
|
| 35 |
+
- View and delete installed models
|
| 36 |
+
- Smooth slide-down animation
|
| 37 |
+
|
| 38 |
+
### 5. **Google Material Design 3 Theme**
|
| 39 |
+
- Clean, modern aesthetic matching Google's latest design language
|
| 40 |
+
- Proper color palette:
|
| 41 |
+
- Primary: #1967d2 (Google Blue)
|
| 42 |
+
- Background: #f8f9fa (Light gray)
|
| 43 |
+
- Surface: #ffffff (White)
|
| 44 |
+
- Text: #202124 (Dark gray)
|
| 45 |
+
- Secondary text: #5f6368 (Medium gray)
|
| 46 |
+
- Rounded corners and subtle shadows
|
| 47 |
+
- Smooth transitions and animations
|
| 48 |
+
|
| 49 |
+
### 6. **Mobile Responsive Design**
|
| 50 |
+
- Fully responsive layout with breakpoints:
|
| 51 |
+
- Desktop: Full features
|
| 52 |
+
- Tablet (≤768px): Adjusted spacing and font sizes
|
| 53 |
+
- Mobile (≤480px): Optimized for small screens
|
| 54 |
+
- Touch-friendly button sizes (minimum 44px)
|
| 55 |
+
- Proper font sizing to prevent zoom on iOS (16px for inputs)
|
| 56 |
+
- Flexible layout that adapts to screen size
|
| 57 |
+
- Hidden model badge on very small screens
|
| 58 |
+
|
| 59 |
+
### 7. **Accessibility Features**
|
| 60 |
+
- ARIA labels for icon buttons
|
| 61 |
+
- Semantic HTML structure
|
| 62 |
+
- Keyboard navigation support
|
| 63 |
+
- Focus states for interactive elements
|
| 64 |
+
- Proper contrast ratios
|
| 65 |
+
|
| 66 |
+
## File Structure
|
| 67 |
+
|
| 68 |
+
```
|
| 69 |
+
ollama-server/
|
| 70 |
+
├── pages/
|
| 71 |
+
│ ├── index.tsx # Main chat interface (updated)
|
| 72 |
+
│ ├── _app.tsx # App wrapper (unchanged)
|
| 73 |
+
│ └── api/
|
| 74 |
+
│ ├── chat.ts # NEW: Chat history API
|
| 75 |
+
│ ├── generate.ts # Existing: Message generation
|
| 76 |
+
│ ├── models.ts # Existing: Model management
|
| 77 |
+
│ └── pull.ts # Existing: Model pulling
|
| 78 |
+
├── styles/
|
| 79 |
+
│ └── globals.css # Complete redesign with Material Design 3
|
| 80 |
+
├── chat-history.json # NEW: Auto-created chat storage file
|
| 81 |
+
└── CHAT_INTERFACE_IMPLEMENTATION.md # This file
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
## API Endpoints
|
| 85 |
+
|
| 86 |
+
### `/api/chat` (NEW)
|
| 87 |
+
|
| 88 |
+
#### GET - Retrieve Chat History
|
| 89 |
+
```typescript
|
| 90 |
+
Response: {
|
| 91 |
+
messages: ChatMessage[]
|
| 92 |
+
}
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
+
#### POST - Save Message
|
| 96 |
+
```typescript
|
| 97 |
+
Request: {
|
| 98 |
+
message: {
|
| 99 |
+
id: string
|
| 100 |
+
role: "user" | "assistant"
|
| 101 |
+
content: string
|
| 102 |
+
timestamp: number
|
| 103 |
+
model?: string
|
| 104 |
+
}
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
Response: {
|
| 108 |
+
success: true
|
| 109 |
+
}
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
+
#### DELETE - Clear Chat History
|
| 113 |
+
```typescript
|
| 114 |
+
Response: {
|
| 115 |
+
success: true
|
| 116 |
+
}
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
## Component Architecture
|
| 120 |
+
|
| 121 |
+
### State Management
|
| 122 |
+
```typescript
|
| 123 |
+
// Model management
|
| 124 |
+
installedModels: OllamaModel[]
|
| 125 |
+
newModel: string
|
| 126 |
+
pulling: boolean
|
| 127 |
+
pullStatus: string
|
| 128 |
+
deleting: string
|
| 129 |
+
|
| 130 |
+
// Chat interface
|
| 131 |
+
model: string
|
| 132 |
+
prompt: string
|
| 133 |
+
chatMessages: ChatMessage[]
|
| 134 |
+
loading: boolean
|
| 135 |
+
showSettings: boolean
|
| 136 |
+
chatEndRef: React.RefObject<HTMLDivElement>
|
| 137 |
+
```
|
| 138 |
+
|
| 139 |
+
### Key Functions
|
| 140 |
+
|
| 141 |
+
1. **fetchChatHistory()** - Loads messages from `/api/chat` on mount
|
| 142 |
+
2. **saveMessage()** - Persists individual messages to storage
|
| 143 |
+
3. **clearChatHistory()** - Deletes all messages with confirmation
|
| 144 |
+
4. **sendMessage()** - Handles message sending workflow:
|
| 145 |
+
- Creates user message
|
| 146 |
+
- Updates UI immediately
|
| 147 |
+
- Saves to storage
|
| 148 |
+
- Calls generation API
|
| 149 |
+
- Displays assistant response
|
| 150 |
+
- Handles errors gracefully
|
| 151 |
+
|
| 152 |
+
## User Experience Flow
|
| 153 |
+
|
| 154 |
+
### First Time Use
|
| 155 |
+
1. User sees empty chat state with instructions
|
| 156 |
+
2. Opens settings panel (⚙️)
|
| 157 |
+
3. Pulls a model (e.g., "mistral")
|
| 158 |
+
4. Selects the model from dropdown
|
| 159 |
+
5. Types message and sends
|
| 160 |
+
6. Sees conversation build up
|
| 161 |
+
|
| 162 |
+
### Returning User
|
| 163 |
+
1. App loads previous chat history automatically
|
| 164 |
+
2. Can continue conversation where left off
|
| 165 |
+
3. Can clear history if desired
|
| 166 |
+
4. Can switch models mid-conversation
|
| 167 |
+
|
| 168 |
+
## Mobile Optimizations
|
| 169 |
+
|
| 170 |
+
### Touch Interactions
|
| 171 |
+
- All buttons are minimum 44x44px (Apple HIG recommendation)
|
| 172 |
+
- Adequate spacing between interactive elements
|
| 173 |
+
- No hover-dependent functionality
|
| 174 |
+
|
| 175 |
+
### Layout Adaptations
|
| 176 |
+
- Settings panel becomes full-width on mobile
|
| 177 |
+
- Pull model input stacks vertically on small screens
|
| 178 |
+
- Model badge hidden on very small screens to save space
|
| 179 |
+
- Font sizes adjusted for readability
|
| 180 |
+
|
| 181 |
+
### Performance
|
| 182 |
+
- CSS animations use transform/opacity for GPU acceleration
|
| 183 |
+
- Minimal re-renders with proper React optimization
|
| 184 |
+
- Efficient scroll behavior with smooth scrolling
|
| 185 |
+
|
| 186 |
+
## Design Tokens (Material Design 3)
|
| 187 |
+
|
| 188 |
+
### Colors
|
| 189 |
+
```css
|
| 190 |
+
/* Primary */
|
| 191 |
+
--primary: #1967d2;
|
| 192 |
+
--primary-hover: #1557b0;
|
| 193 |
+
--primary-active: #1446a0;
|
| 194 |
+
|
| 195 |
+
/* Surfaces */
|
| 196 |
+
--surface: #ffffff;
|
| 197 |
+
--surface-variant: #f8f9fa;
|
| 198 |
+
--surface-hover: #f1f3f4;
|
| 199 |
+
|
| 200 |
+
/* Borders */
|
| 201 |
+
--border: #e8eaed;
|
| 202 |
+
--border-hover: #dadce0;
|
| 203 |
+
|
| 204 |
+
/* Text */
|
| 205 |
+
--text-primary: #202124;
|
| 206 |
+
--text-secondary: #5f6368;
|
| 207 |
+
--text-disabled: #9aa0a6;
|
| 208 |
+
|
| 209 |
+
/* Accent Colors */
|
| 210 |
+
--blue-light: #e8f0fe;
|
| 211 |
+
--blue-border: #d2e3fc;
|
| 212 |
+
--red-light: #fce8e6;
|
| 213 |
+
--red: #d93025;
|
| 214 |
+
```
|
| 215 |
+
|
| 216 |
+
### Typography
|
| 217 |
+
```css
|
| 218 |
+
/* Font Family */
|
| 219 |
+
font-family: 'Google Sans', 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
| 220 |
+
|
| 221 |
+
/* Sizes */
|
| 222 |
+
--text-xs: 12px;
|
| 223 |
+
--text-sm: 13px;
|
| 224 |
+
--text-base: 14px;
|
| 225 |
+
--text-lg: 16px;
|
| 226 |
+
--text-xl: 18px;
|
| 227 |
+
--text-2xl: 20px;
|
| 228 |
+
--text-3xl: 22px;
|
| 229 |
+
--text-4xl: 24px;
|
| 230 |
+
```
|
| 231 |
+
|
| 232 |
+
### Spacing
|
| 233 |
+
```css
|
| 234 |
+
/* Base unit: 4px */
|
| 235 |
+
--space-1: 4px;
|
| 236 |
+
--space-2: 8px;
|
| 237 |
+
--space-3: 12px;
|
| 238 |
+
--space-4: 16px;
|
| 239 |
+
--space-5: 20px;
|
| 240 |
+
--space-6: 24px;
|
| 241 |
+
--space-8: 32px;
|
| 242 |
+
```
|
| 243 |
+
|
| 244 |
+
### Border Radius
|
| 245 |
+
```css
|
| 246 |
+
--radius-sm: 8px;
|
| 247 |
+
--radius-md: 12px;
|
| 248 |
+
--radius-lg: 16px;
|
| 249 |
+
--radius-full: 50%;
|
| 250 |
+
--radius-pill: 24px;
|
| 251 |
+
```
|
| 252 |
+
|
| 253 |
+
## Browser Compatibility
|
| 254 |
+
|
| 255 |
+
- Chrome/Edge: Full support
|
| 256 |
+
- Firefox: Full support
|
| 257 |
+
- Safari: Full support (iOS 12+)
|
| 258 |
+
- Mobile browsers: Optimized for iOS Safari and Chrome Android
|
| 259 |
+
|
| 260 |
+
## Future Enhancements
|
| 261 |
+
|
| 262 |
+
### Potential Features
|
| 263 |
+
1. **Message Actions**
|
| 264 |
+
- Copy message content
|
| 265 |
+
- Regenerate response
|
| 266 |
+
- Edit user messages
|
| 267 |
+
|
| 268 |
+
2. **Conversation Management**
|
| 269 |
+
- Multiple conversation threads
|
| 270 |
+
- Search chat history
|
| 271 |
+
- Export conversations
|
| 272 |
+
|
| 273 |
+
3. **Advanced Settings**
|
| 274 |
+
- Temperature control
|
| 275 |
+
- Max tokens
|
| 276 |
+
- System prompts
|
| 277 |
+
|
| 278 |
+
4. **UI Enhancements**
|
| 279 |
+
- Dark mode toggle
|
| 280 |
+
- Markdown rendering for messages
|
| 281 |
+
- Code syntax highlighting
|
| 282 |
+
- Image support
|
| 283 |
+
|
| 284 |
+
5. **Performance**
|
| 285 |
+
- Streaming responses
|
| 286 |
+
- Virtual scrolling for long chats
|
| 287 |
+
- Message pagination
|
| 288 |
+
|
| 289 |
+
## Troubleshooting
|
| 290 |
+
|
| 291 |
+
### Chat history not persisting
|
| 292 |
+
- Check file permissions for `chat-history.json`
|
| 293 |
+
- Verify API endpoint `/api/chat` is accessible
|
| 294 |
+
- Check browser console for errors
|
| 295 |
+
|
| 296 |
+
### Messages not sending
|
| 297 |
+
- Ensure a model is selected
|
| 298 |
+
- Verify Ollama is running on `localhost:11434`
|
| 299 |
+
- Check network tab for API failures
|
| 300 |
+
|
| 301 |
+
### UI not responsive
|
| 302 |
+
- Clear browser cache
|
| 303 |
+
- Check for CSS conflicts
|
| 304 |
+
- Verify viewport meta tag in HTML
|
| 305 |
+
|
| 306 |
+
## Development Notes
|
| 307 |
+
|
| 308 |
+
### Running the Application
|
| 309 |
+
```bash
|
| 310 |
+
npm run dev
|
| 311 |
+
# App runs on http://localhost:7860
|
| 312 |
+
```
|
| 313 |
+
|
| 314 |
+
### Building for Production
|
| 315 |
+
```bash
|
| 316 |
+
npm run build
|
| 317 |
+
npm start
|
| 318 |
+
```
|
| 319 |
+
|
| 320 |
+
### Testing Chat History
|
| 321 |
+
1. Send a few messages
|
| 322 |
+
2. Refresh the page
|
| 323 |
+
3. Verify messages reappear
|
| 324 |
+
4. Click clear history button
|
| 325 |
+
5. Confirm messages are deleted
|
| 326 |
+
|
| 327 |
+
## Conclusion
|
| 328 |
+
|
| 329 |
+
The chat interface has been completely redesigned to provide a modern, intuitive experience that matches Google's Material Design 3 guidelines. The implementation includes persistent storage, mobile responsiveness, and accessibility features, making it production-ready for a wide range of users and devices.
|
pages/api/chat.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { NextApiRequest, NextApiResponse } from "next"
|
| 2 |
+
import fs from "fs"
|
| 3 |
+
import path from "path"
|
| 4 |
+
|
| 5 |
+
const CHAT_HISTORY_FILE = path.join(process.cwd(), "chat-history.json")
|
| 6 |
+
|
| 7 |
+
interface ChatMessage {
|
| 8 |
+
id: string
|
| 9 |
+
role: "user" | "assistant"
|
| 10 |
+
content: string
|
| 11 |
+
timestamp: number
|
| 12 |
+
model?: string
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
interface ChatHistory {
|
| 16 |
+
messages: ChatMessage[]
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
// Read chat history from file
|
| 20 |
+
function readChatHistory(): ChatHistory {
|
| 21 |
+
try {
|
| 22 |
+
if (fs.existsSync(CHAT_HISTORY_FILE)) {
|
| 23 |
+
const data = fs.readFileSync(CHAT_HISTORY_FILE, "utf-8")
|
| 24 |
+
return JSON.parse(data)
|
| 25 |
+
}
|
| 26 |
+
} catch (error) {
|
| 27 |
+
console.error("Error reading chat history:", error)
|
| 28 |
+
}
|
| 29 |
+
return { messages: [] }
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
// Write chat history to file
|
| 33 |
+
function writeChatHistory(history: ChatHistory): void {
|
| 34 |
+
try {
|
| 35 |
+
fs.writeFileSync(CHAT_HISTORY_FILE, JSON.stringify(history, null, 2))
|
| 36 |
+
} catch (error) {
|
| 37 |
+
console.error("Error writing chat history:", error)
|
| 38 |
+
}
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
export default async function handler(
|
| 42 |
+
req: NextApiRequest,
|
| 43 |
+
res: NextApiResponse
|
| 44 |
+
) {
|
| 45 |
+
if (req.method === "GET") {
|
| 46 |
+
// Get chat history
|
| 47 |
+
const history = readChatHistory()
|
| 48 |
+
return res.status(200).json(history)
|
| 49 |
+
} else if (req.method === "POST") {
|
| 50 |
+
// Add message to chat history
|
| 51 |
+
const { message } = req.body as { message: ChatMessage }
|
| 52 |
+
|
| 53 |
+
if (!message || !message.role || !message.content) {
|
| 54 |
+
return res.status(400).json({ error: "Invalid message format" })
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
const history = readChatHistory()
|
| 58 |
+
history.messages.push(message)
|
| 59 |
+
writeChatHistory(history)
|
| 60 |
+
|
| 61 |
+
return res.status(200).json({ success: true })
|
| 62 |
+
} else if (req.method === "DELETE") {
|
| 63 |
+
// Clear chat history
|
| 64 |
+
writeChatHistory({ messages: [] })
|
| 65 |
+
return res.status(200).json({ success: true })
|
| 66 |
+
} else {
|
| 67 |
+
return res.status(405).json({ error: "Method not allowed" })
|
| 68 |
+
}
|
| 69 |
+
}
|
pages/index.tsx
CHANGED
|
@@ -1,10 +1,18 @@
|
|
| 1 |
-
import { useState, useEffect } from "react"
|
| 2 |
|
| 3 |
interface OllamaModel {
|
| 4 |
name: string
|
| 5 |
size: number
|
| 6 |
}
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
export default function Home() {
|
| 9 |
// Model management
|
| 10 |
const [installedModels, setInstalledModels] = useState<OllamaModel[]>([])
|
|
@@ -13,11 +21,13 @@ export default function Home() {
|
|
| 13 |
const [pullStatus, setPullStatus] = useState("")
|
| 14 |
const [deleting, setDeleting] = useState("")
|
| 15 |
|
| 16 |
-
//
|
| 17 |
const [model, setModel] = useState("")
|
| 18 |
const [prompt, setPrompt] = useState("")
|
| 19 |
-
const [
|
| 20 |
const [loading, setLoading] = useState(false)
|
|
|
|
|
|
|
| 21 |
|
| 22 |
// Fetch installed models
|
| 23 |
const fetchModels = async () => {
|
|
@@ -34,10 +44,52 @@ export default function Home() {
|
|
| 34 |
}
|
| 35 |
}
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
useEffect(() => {
|
| 38 |
fetchModels()
|
|
|
|
| 39 |
}, [])
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
// Pull new model
|
| 42 |
const pullModel = async () => {
|
| 43 |
if (!newModel.trim()) return
|
|
@@ -96,118 +148,228 @@ export default function Home() {
|
|
| 96 |
return gb >= 1 ? `${gb.toFixed(1)} GB` : `${(bytes / 1e6).toFixed(0)} MB`
|
| 97 |
}
|
| 98 |
|
| 99 |
-
//
|
| 100 |
-
const
|
| 101 |
if (!prompt.trim() || !model) return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
setLoading(true)
|
| 103 |
-
setResponse("")
|
| 104 |
|
| 105 |
try {
|
| 106 |
const res = await fetch("/api/generate", {
|
| 107 |
method: "POST",
|
| 108 |
headers: { "Content-Type": "application/json" },
|
| 109 |
-
body: JSON.stringify({ model, prompt }),
|
| 110 |
})
|
| 111 |
const data = await res.json()
|
| 112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
} catch {
|
| 114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
}
|
| 116 |
|
| 117 |
setLoading(false)
|
| 118 |
}
|
| 119 |
|
| 120 |
return (
|
| 121 |
-
<
|
| 122 |
-
|
| 123 |
-
<
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
|
|
|
|
|
|
|
|
|
| 144 |
</div>
|
|
|
|
| 145 |
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
<
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
<
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
</button>
|
| 166 |
</div>
|
| 167 |
-
|
| 168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
</div>
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
{/*
|
| 173 |
-
<
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
))}
|
| 184 |
-
|
| 185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
|
| 187 |
-
|
| 188 |
-
|
|
|
|
| 189 |
<textarea
|
| 190 |
-
|
| 191 |
-
|
|
|
|
| 192 |
value={prompt}
|
| 193 |
onChange={(e) => setPrompt(e.target.value)}
|
| 194 |
onKeyDown={(e) => {
|
| 195 |
-
if (e.key === "Enter" && e.
|
|
|
|
|
|
|
|
|
|
| 196 |
}}
|
|
|
|
| 197 |
/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
</div>
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
{loading ? "⏳ Generating..." : "🚀 Generate"}
|
| 202 |
-
</button>
|
| 203 |
-
|
| 204 |
-
<div className="response">
|
| 205 |
-
<label>Response</label>
|
| 206 |
-
<div className="response-box">
|
| 207 |
-
{response || "Response will appear here..."}
|
| 208 |
-
</div>
|
| 209 |
-
</div>
|
| 210 |
-
</section>
|
| 211 |
-
</main>
|
| 212 |
)
|
| 213 |
}
|
|
|
|
| 1 |
+
import { useState, useEffect, useRef } from "react"
|
| 2 |
|
| 3 |
interface OllamaModel {
|
| 4 |
name: string
|
| 5 |
size: number
|
| 6 |
}
|
| 7 |
|
| 8 |
+
interface ChatMessage {
|
| 9 |
+
id: string
|
| 10 |
+
role: "user" | "assistant"
|
| 11 |
+
content: string
|
| 12 |
+
timestamp: number
|
| 13 |
+
model?: string
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
export default function Home() {
|
| 17 |
// Model management
|
| 18 |
const [installedModels, setInstalledModels] = useState<OllamaModel[]>([])
|
|
|
|
| 21 |
const [pullStatus, setPullStatus] = useState("")
|
| 22 |
const [deleting, setDeleting] = useState("")
|
| 23 |
|
| 24 |
+
// Chat interface
|
| 25 |
const [model, setModel] = useState("")
|
| 26 |
const [prompt, setPrompt] = useState("")
|
| 27 |
+
const [chatMessages, setChatMessages] = useState<ChatMessage[]>([])
|
| 28 |
const [loading, setLoading] = useState(false)
|
| 29 |
+
const [showSettings, setShowSettings] = useState(false)
|
| 30 |
+
const chatEndRef = useRef<HTMLDivElement>(null)
|
| 31 |
|
| 32 |
// Fetch installed models
|
| 33 |
const fetchModels = async () => {
|
|
|
|
| 44 |
}
|
| 45 |
}
|
| 46 |
|
| 47 |
+
// Fetch chat history
|
| 48 |
+
const fetchChatHistory = async () => {
|
| 49 |
+
try {
|
| 50 |
+
const res = await fetch("/api/chat")
|
| 51 |
+
const data = await res.json()
|
| 52 |
+
setChatMessages(data.messages || [])
|
| 53 |
+
} catch {
|
| 54 |
+
console.error("Failed to fetch chat history")
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
// Save message to history
|
| 59 |
+
const saveMessage = async (message: ChatMessage) => {
|
| 60 |
+
try {
|
| 61 |
+
await fetch("/api/chat", {
|
| 62 |
+
method: "POST",
|
| 63 |
+
headers: { "Content-Type": "application/json" },
|
| 64 |
+
body: JSON.stringify({ message }),
|
| 65 |
+
})
|
| 66 |
+
} catch {
|
| 67 |
+
console.error("Failed to save message")
|
| 68 |
+
}
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
// Clear chat history
|
| 72 |
+
const clearChatHistory = async () => {
|
| 73 |
+
if (!confirm("Clear all chat history?")) return
|
| 74 |
+
|
| 75 |
+
try {
|
| 76 |
+
await fetch("/api/chat", { method: "DELETE" })
|
| 77 |
+
setChatMessages([])
|
| 78 |
+
} catch {
|
| 79 |
+
console.error("Failed to clear chat history")
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
useEffect(() => {
|
| 84 |
fetchModels()
|
| 85 |
+
fetchChatHistory()
|
| 86 |
}, [])
|
| 87 |
|
| 88 |
+
// Auto-scroll to bottom
|
| 89 |
+
useEffect(() => {
|
| 90 |
+
chatEndRef.current?.scrollIntoView({ behavior: "smooth" })
|
| 91 |
+
}, [chatMessages])
|
| 92 |
+
|
| 93 |
// Pull new model
|
| 94 |
const pullModel = async () => {
|
| 95 |
if (!newModel.trim()) return
|
|
|
|
| 148 |
return gb >= 1 ? `${gb.toFixed(1)} GB` : `${(bytes / 1e6).toFixed(0)} MB`
|
| 149 |
}
|
| 150 |
|
| 151 |
+
// Send message
|
| 152 |
+
const sendMessage = async () => {
|
| 153 |
if (!prompt.trim() || !model) return
|
| 154 |
+
|
| 155 |
+
const userMessage: ChatMessage = {
|
| 156 |
+
id: `user-${Date.now()}`,
|
| 157 |
+
role: "user",
|
| 158 |
+
content: prompt.trim(),
|
| 159 |
+
timestamp: Date.now(),
|
| 160 |
+
model,
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
// Add user message to UI immediately
|
| 164 |
+
setChatMessages(prev => [...prev, userMessage])
|
| 165 |
+
await saveMessage(userMessage)
|
| 166 |
+
|
| 167 |
+
setPrompt("")
|
| 168 |
setLoading(true)
|
|
|
|
| 169 |
|
| 170 |
try {
|
| 171 |
const res = await fetch("/api/generate", {
|
| 172 |
method: "POST",
|
| 173 |
headers: { "Content-Type": "application/json" },
|
| 174 |
+
body: JSON.stringify({ model, prompt: userMessage.content }),
|
| 175 |
})
|
| 176 |
const data = await res.json()
|
| 177 |
+
|
| 178 |
+
const assistantMessage: ChatMessage = {
|
| 179 |
+
id: `assistant-${Date.now()}`,
|
| 180 |
+
role: "assistant",
|
| 181 |
+
content: data.response || data.error || "No response",
|
| 182 |
+
timestamp: Date.now(),
|
| 183 |
+
model,
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
setChatMessages(prev => [...prev, assistantMessage])
|
| 187 |
+
await saveMessage(assistantMessage)
|
| 188 |
} catch {
|
| 189 |
+
const errorMessage: ChatMessage = {
|
| 190 |
+
id: `error-${Date.now()}`,
|
| 191 |
+
role: "assistant",
|
| 192 |
+
content: "❌ Failed to connect to server",
|
| 193 |
+
timestamp: Date.now(),
|
| 194 |
+
}
|
| 195 |
+
setChatMessages(prev => [...prev, errorMessage])
|
| 196 |
+
await saveMessage(errorMessage)
|
| 197 |
}
|
| 198 |
|
| 199 |
setLoading(false)
|
| 200 |
}
|
| 201 |
|
| 202 |
return (
|
| 203 |
+
<div className="app-container">
|
| 204 |
+
{/* Header */}
|
| 205 |
+
<header className="header">
|
| 206 |
+
<div className="header-content">
|
| 207 |
+
<div className="header-title">
|
| 208 |
+
<h1>⚡ Ollama Chat</h1>
|
| 209 |
+
<span className="model-badge">{model || "No model"}</span>
|
| 210 |
+
</div>
|
| 211 |
+
<div className="header-actions">
|
| 212 |
+
<button
|
| 213 |
+
className="icon-btn"
|
| 214 |
+
onClick={clearChatHistory}
|
| 215 |
+
title="Clear chat history"
|
| 216 |
+
aria-label="Clear chat history"
|
| 217 |
+
>
|
| 218 |
+
🗑️
|
| 219 |
+
</button>
|
| 220 |
+
<button
|
| 221 |
+
className="icon-btn"
|
| 222 |
+
onClick={() => setShowSettings(!showSettings)}
|
| 223 |
+
title="Settings"
|
| 224 |
+
aria-label="Toggle settings"
|
| 225 |
+
>
|
| 226 |
+
⚙️
|
| 227 |
+
</button>
|
| 228 |
+
</div>
|
| 229 |
</div>
|
| 230 |
+
</header>
|
| 231 |
|
| 232 |
+
{/* Settings Panel */}
|
| 233 |
+
{showSettings && (
|
| 234 |
+
<div className="settings-panel">
|
| 235 |
+
<div className="settings-content">
|
| 236 |
+
<h2>⚙️ Settings</h2>
|
| 237 |
+
|
| 238 |
+
{/* Model Selection */}
|
| 239 |
+
<div className="field">
|
| 240 |
+
<label>Active Model</label>
|
| 241 |
+
<select value={model} onChange={(e) => setModel(e.target.value)}>
|
| 242 |
+
{installedModels.length === 0 ? (
|
| 243 |
+
<option value="">No models available</option>
|
| 244 |
+
) : (
|
| 245 |
+
installedModels.map((m) => (
|
| 246 |
+
<option key={m.name} value={m.name}>
|
| 247 |
+
{m.name} ({formatSize(m.size)})
|
| 248 |
+
</option>
|
| 249 |
+
))
|
| 250 |
+
)}
|
| 251 |
+
</select>
|
| 252 |
+
</div>
|
| 253 |
+
|
| 254 |
+
{/* Pull new model */}
|
| 255 |
+
<div className="field">
|
| 256 |
+
<label>Pull New Model</label>
|
| 257 |
+
<div className="pull-row">
|
| 258 |
+
<input
|
| 259 |
+
type="text"
|
| 260 |
+
placeholder="e.g. mistral, tinyllama"
|
| 261 |
+
value={newModel}
|
| 262 |
+
onChange={(e) => setNewModel(e.target.value)}
|
| 263 |
+
onKeyDown={(e) => {
|
| 264 |
+
if (e.key === "Enter") pullModel()
|
| 265 |
+
}}
|
| 266 |
+
disabled={pulling}
|
| 267 |
+
/>
|
| 268 |
+
<button onClick={pullModel} disabled={pulling} className="btn-pull">
|
| 269 |
+
{pulling ? "Pulling..." : "Pull"}
|
| 270 |
</button>
|
| 271 |
</div>
|
| 272 |
+
{pullStatus && <p className="status">{pullStatus}</p>}
|
| 273 |
+
</div>
|
| 274 |
+
|
| 275 |
+
{/* Installed models */}
|
| 276 |
+
<div className="field">
|
| 277 |
+
<label>Installed Models</label>
|
| 278 |
+
<div className="model-list">
|
| 279 |
+
{installedModels.length === 0 ? (
|
| 280 |
+
<p className="empty">No models installed yet</p>
|
| 281 |
+
) : (
|
| 282 |
+
installedModels.map((m) => (
|
| 283 |
+
<div key={m.name} className="model-item">
|
| 284 |
+
<div className="model-info">
|
| 285 |
+
<span className="model-name">{m.name}</span>
|
| 286 |
+
<span className="model-size">{formatSize(m.size)}</span>
|
| 287 |
+
</div>
|
| 288 |
+
<button
|
| 289 |
+
onClick={() => deleteModel(m.name)}
|
| 290 |
+
disabled={deleting === m.name}
|
| 291 |
+
className="btn-delete"
|
| 292 |
+
aria-label={`Delete ${m.name}`}
|
| 293 |
+
>
|
| 294 |
+
{deleting === m.name ? "..." : "🗑️"}
|
| 295 |
+
</button>
|
| 296 |
+
</div>
|
| 297 |
+
))
|
| 298 |
+
)}
|
| 299 |
+
</div>
|
| 300 |
+
</div>
|
| 301 |
+
</div>
|
| 302 |
</div>
|
| 303 |
+
)}
|
| 304 |
+
|
| 305 |
+
{/* Chat Messages */}
|
| 306 |
+
<main className="chat-container">
|
| 307 |
+
{chatMessages.length === 0 ? (
|
| 308 |
+
<div className="empty-state">
|
| 309 |
+
<div className="empty-icon">💬</div>
|
| 310 |
+
<h2>Start a conversation</h2>
|
| 311 |
+
<p>Select a model and send a message to begin</p>
|
| 312 |
+
</div>
|
| 313 |
+
) : (
|
| 314 |
+
<div className="messages">
|
| 315 |
+
{chatMessages.map((msg) => (
|
| 316 |
+
<div key={msg.id} className={`message message-${msg.role}`}>
|
| 317 |
+
<div className="message-avatar">
|
| 318 |
+
{msg.role === "user" ? "👤" : "🤖"}
|
| 319 |
+
</div>
|
| 320 |
+
<div className="message-content">
|
| 321 |
+
<div className="message-text">{msg.content}</div>
|
| 322 |
+
<div className="message-meta">
|
| 323 |
+
{new Date(msg.timestamp).toLocaleTimeString()}
|
| 324 |
+
{msg.model && <span className="message-model"> • {msg.model}</span>}
|
| 325 |
+
</div>
|
| 326 |
+
</div>
|
| 327 |
+
</div>
|
| 328 |
))}
|
| 329 |
+
{loading && (
|
| 330 |
+
<div className="message message-assistant">
|
| 331 |
+
<div className="message-avatar">🤖</div>
|
| 332 |
+
<div className="message-content">
|
| 333 |
+
<div className="typing-indicator">
|
| 334 |
+
<span></span>
|
| 335 |
+
<span></span>
|
| 336 |
+
<span></span>
|
| 337 |
+
</div>
|
| 338 |
+
</div>
|
| 339 |
+
</div>
|
| 340 |
+
)}
|
| 341 |
+
<div ref={chatEndRef} />
|
| 342 |
+
</div>
|
| 343 |
+
)}
|
| 344 |
+
</main>
|
| 345 |
|
| 346 |
+
{/* Input Area */}
|
| 347 |
+
<footer className="input-container">
|
| 348 |
+
<div className="input-wrapper">
|
| 349 |
<textarea
|
| 350 |
+
className="chat-input"
|
| 351 |
+
rows={1}
|
| 352 |
+
placeholder={model ? "Type a message..." : "Please select a model first"}
|
| 353 |
value={prompt}
|
| 354 |
onChange={(e) => setPrompt(e.target.value)}
|
| 355 |
onKeyDown={(e) => {
|
| 356 |
+
if (e.key === "Enter" && !e.shiftKey) {
|
| 357 |
+
e.preventDefault()
|
| 358 |
+
sendMessage()
|
| 359 |
+
}
|
| 360 |
}}
|
| 361 |
+
disabled={loading || !model}
|
| 362 |
/>
|
| 363 |
+
<button
|
| 364 |
+
className="send-btn"
|
| 365 |
+
onClick={sendMessage}
|
| 366 |
+
disabled={loading || !model || !prompt.trim()}
|
| 367 |
+
aria-label="Send message"
|
| 368 |
+
>
|
| 369 |
+
{loading ? "⏳" : "➤"}
|
| 370 |
+
</button>
|
| 371 |
</div>
|
| 372 |
+
</footer>
|
| 373 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 374 |
)
|
| 375 |
}
|
styles/globals.css
CHANGED
|
@@ -5,108 +5,200 @@
|
|
| 5 |
}
|
| 6 |
|
| 7 |
body {
|
| 8 |
-
background: #
|
| 9 |
-
color: #
|
| 10 |
-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
|
|
|
|
| 11 |
}
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
margin: 0 auto;
|
| 16 |
-
padding: 48px 24px;
|
| 17 |
}
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
| 22 |
}
|
| 23 |
|
| 24 |
-
|
| 25 |
-
font-size:
|
| 26 |
-
|
| 27 |
-
|
|
|
|
| 28 |
}
|
| 29 |
|
| 30 |
-
.
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
| 34 |
}
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
}
|
| 44 |
|
| 45 |
/* Fields */
|
| 46 |
.field {
|
| 47 |
-
margin-bottom:
|
| 48 |
}
|
| 49 |
|
| 50 |
label {
|
| 51 |
display: block;
|
| 52 |
-
font-size:
|
| 53 |
-
color: #
|
| 54 |
-
margin-bottom:
|
| 55 |
-
|
| 56 |
-
|
|
|
|
| 57 |
}
|
| 58 |
|
| 59 |
select,
|
| 60 |
-
textarea,
|
| 61 |
input[type="text"] {
|
| 62 |
width: 100%;
|
| 63 |
-
background: #
|
| 64 |
-
color: #
|
| 65 |
-
border: 1px solid #
|
| 66 |
border-radius: 8px;
|
| 67 |
-
padding: 12px;
|
| 68 |
-
font-size:
|
| 69 |
outline: none;
|
| 70 |
-
transition:
|
|
|
|
| 71 |
}
|
| 72 |
|
| 73 |
-
select:
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
border-color: #555;
|
| 77 |
}
|
| 78 |
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
|
|
|
| 82 |
}
|
| 83 |
|
| 84 |
/* Buttons */
|
| 85 |
button {
|
| 86 |
-
background: #
|
| 87 |
-
color: #
|
| 88 |
border: none;
|
| 89 |
-
border-radius:
|
| 90 |
-
padding:
|
| 91 |
-
font-size:
|
| 92 |
-
font-weight:
|
| 93 |
cursor: pointer;
|
| 94 |
-
transition:
|
|
|
|
| 95 |
}
|
| 96 |
|
| 97 |
button:hover {
|
| 98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
}
|
| 100 |
|
| 101 |
button:disabled {
|
| 102 |
-
|
|
|
|
| 103 |
cursor: not-allowed;
|
|
|
|
|
|
|
| 104 |
}
|
| 105 |
|
| 106 |
/* Pull row */
|
| 107 |
.pull-row {
|
| 108 |
display: flex;
|
| 109 |
-
gap:
|
| 110 |
margin-bottom: 12px;
|
| 111 |
}
|
| 112 |
|
|
@@ -116,83 +208,402 @@ button:disabled {
|
|
| 116 |
|
| 117 |
.btn-pull {
|
| 118 |
white-space: nowrap;
|
| 119 |
-
padding:
|
| 120 |
font-size: 14px;
|
| 121 |
}
|
| 122 |
|
| 123 |
.status {
|
| 124 |
font-size: 13px;
|
| 125 |
-
color: #
|
| 126 |
-
margin-
|
|
|
|
|
|
|
|
|
|
| 127 |
}
|
| 128 |
|
| 129 |
/* Model list */
|
| 130 |
.model-list {
|
| 131 |
-
margin-top:
|
|
|
|
|
|
|
| 132 |
}
|
| 133 |
|
| 134 |
.model-item {
|
| 135 |
display: flex;
|
| 136 |
align-items: center;
|
| 137 |
justify-content: space-between;
|
| 138 |
-
padding: 12px
|
| 139 |
-
background: #
|
| 140 |
-
border: 1px solid #
|
| 141 |
border-radius: 8px;
|
| 142 |
margin-bottom: 8px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
}
|
| 144 |
|
| 145 |
.model-info {
|
| 146 |
display: flex;
|
| 147 |
flex-direction: column;
|
| 148 |
-
gap:
|
| 149 |
}
|
| 150 |
|
| 151 |
.model-name {
|
| 152 |
-
font-size:
|
| 153 |
font-weight: 500;
|
| 154 |
-
color: #
|
| 155 |
}
|
| 156 |
|
| 157 |
.model-size {
|
| 158 |
font-size: 12px;
|
| 159 |
-
color: #
|
| 160 |
}
|
| 161 |
|
| 162 |
.btn-delete {
|
| 163 |
background: transparent;
|
| 164 |
-
color: #
|
| 165 |
-
padding:
|
| 166 |
-
font-size:
|
| 167 |
-
border-radius:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
}
|
| 169 |
|
| 170 |
.btn-delete:hover {
|
| 171 |
-
background: #
|
| 172 |
-
color: #
|
| 173 |
opacity: 1;
|
| 174 |
}
|
| 175 |
|
| 176 |
.empty {
|
| 177 |
-
color: #
|
| 178 |
font-size: 14px;
|
| 179 |
text-align: center;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
padding: 20px;
|
| 181 |
}
|
| 182 |
|
| 183 |
-
/*
|
| 184 |
-
.
|
| 185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
}
|
| 187 |
|
| 188 |
-
.
|
| 189 |
-
|
| 190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
border-radius: 8px;
|
| 192 |
-
|
| 193 |
-
min-height: 120px;
|
| 194 |
-
font-size: 15px;
|
| 195 |
line-height: 1.6;
|
|
|
|
| 196 |
white-space: pre-wrap;
|
| 197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
}
|
|
|
|
| 5 |
}
|
| 6 |
|
| 7 |
body {
|
| 8 |
+
background: #f8f9fa;
|
| 9 |
+
color: #202124;
|
| 10 |
+
font-family: 'Google Sans', 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
| 11 |
+
overflow: hidden;
|
| 12 |
}
|
| 13 |
|
| 14 |
+
/* App Container */
|
| 15 |
+
.app-container {
|
| 16 |
+
display: flex;
|
| 17 |
+
flex-direction: column;
|
| 18 |
+
height: 100vh;
|
| 19 |
+
max-width: 100vw;
|
| 20 |
+
background: #ffffff;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
/* Header */
|
| 24 |
+
.header {
|
| 25 |
+
background: #ffffff;
|
| 26 |
+
border-bottom: 1px solid #e8eaed;
|
| 27 |
+
padding: 12px 20px;
|
| 28 |
+
position: sticky;
|
| 29 |
+
top: 0;
|
| 30 |
+
z-index: 100;
|
| 31 |
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
.header-content {
|
| 35 |
+
display: flex;
|
| 36 |
+
justify-content: space-between;
|
| 37 |
+
align-items: center;
|
| 38 |
+
max-width: 1200px;
|
| 39 |
margin: 0 auto;
|
|
|
|
| 40 |
}
|
| 41 |
|
| 42 |
+
.header-title {
|
| 43 |
+
display: flex;
|
| 44 |
+
align-items: center;
|
| 45 |
+
gap: 12px;
|
| 46 |
}
|
| 47 |
|
| 48 |
+
.header-title h1 {
|
| 49 |
+
font-size: 22px;
|
| 50 |
+
font-weight: 500;
|
| 51 |
+
color: #202124;
|
| 52 |
+
margin: 0;
|
| 53 |
}
|
| 54 |
|
| 55 |
+
.model-badge {
|
| 56 |
+
background: #e8f0fe;
|
| 57 |
+
color: #1967d2;
|
| 58 |
+
padding: 4px 12px;
|
| 59 |
+
border-radius: 16px;
|
| 60 |
+
font-size: 13px;
|
| 61 |
+
font-weight: 500;
|
| 62 |
}
|
| 63 |
|
| 64 |
+
.header-actions {
|
| 65 |
+
display: flex;
|
| 66 |
+
gap: 8px;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
.icon-btn {
|
| 70 |
+
background: transparent;
|
| 71 |
+
border: none;
|
| 72 |
+
width: 40px;
|
| 73 |
+
height: 40px;
|
| 74 |
+
border-radius: 50%;
|
| 75 |
+
display: flex;
|
| 76 |
+
align-items: center;
|
| 77 |
+
justify-content: center;
|
| 78 |
+
cursor: pointer;
|
| 79 |
+
transition: background 0.2s;
|
| 80 |
+
font-size: 20px;
|
| 81 |
+
padding: 0;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
.icon-btn:hover {
|
| 85 |
+
background: #f1f3f4;
|
| 86 |
+
opacity: 1;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
.icon-btn:active {
|
| 90 |
+
background: #e8eaed;
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
/* Settings Panel */
|
| 94 |
+
.settings-panel {
|
| 95 |
+
background: #ffffff;
|
| 96 |
+
border-bottom: 1px solid #e8eaed;
|
| 97 |
+
max-height: 70vh;
|
| 98 |
+
overflow-y: auto;
|
| 99 |
+
animation: slideDown 0.3s ease-out;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
@keyframes slideDown {
|
| 103 |
+
from {
|
| 104 |
+
max-height: 0;
|
| 105 |
+
opacity: 0;
|
| 106 |
+
}
|
| 107 |
+
to {
|
| 108 |
+
max-height: 70vh;
|
| 109 |
+
opacity: 1;
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
.settings-content {
|
| 114 |
+
max-width: 800px;
|
| 115 |
+
margin: 0 auto;
|
| 116 |
+
padding: 24px 20px;
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
.settings-content h2 {
|
| 120 |
+
font-size: 20px;
|
| 121 |
+
font-weight: 500;
|
| 122 |
+
color: #202124;
|
| 123 |
+
margin-bottom: 20px;
|
| 124 |
}
|
| 125 |
|
| 126 |
/* Fields */
|
| 127 |
.field {
|
| 128 |
+
margin-bottom: 24px;
|
| 129 |
}
|
| 130 |
|
| 131 |
label {
|
| 132 |
display: block;
|
| 133 |
+
font-size: 14px;
|
| 134 |
+
color: #5f6368;
|
| 135 |
+
margin-bottom: 8px;
|
| 136 |
+
font-weight: 500;
|
| 137 |
+
text-transform: none;
|
| 138 |
+
letter-spacing: 0;
|
| 139 |
}
|
| 140 |
|
| 141 |
select,
|
|
|
|
| 142 |
input[type="text"] {
|
| 143 |
width: 100%;
|
| 144 |
+
background: #ffffff;
|
| 145 |
+
color: #202124;
|
| 146 |
+
border: 1px solid #dadce0;
|
| 147 |
border-radius: 8px;
|
| 148 |
+
padding: 12px 16px;
|
| 149 |
+
font-size: 14px;
|
| 150 |
outline: none;
|
| 151 |
+
transition: all 0.2s;
|
| 152 |
+
font-family: inherit;
|
| 153 |
}
|
| 154 |
|
| 155 |
+
select:hover,
|
| 156 |
+
input[type="text"]:hover {
|
| 157 |
+
border-color: #bdc1c6;
|
|
|
|
| 158 |
}
|
| 159 |
|
| 160 |
+
select:focus,
|
| 161 |
+
input[type="text"]:focus {
|
| 162 |
+
border-color: #1967d2;
|
| 163 |
+
box-shadow: 0 0 0 3px rgba(25, 103, 210, 0.1);
|
| 164 |
}
|
| 165 |
|
| 166 |
/* Buttons */
|
| 167 |
button {
|
| 168 |
+
background: #1967d2;
|
| 169 |
+
color: #ffffff;
|
| 170 |
border: none;
|
| 171 |
+
border-radius: 24px;
|
| 172 |
+
padding: 10px 24px;
|
| 173 |
+
font-size: 14px;
|
| 174 |
+
font-weight: 500;
|
| 175 |
cursor: pointer;
|
| 176 |
+
transition: all 0.2s;
|
| 177 |
+
font-family: inherit;
|
| 178 |
}
|
| 179 |
|
| 180 |
button:hover {
|
| 181 |
+
background: #1557b0;
|
| 182 |
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
|
| 183 |
+
opacity: 1;
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
button:active {
|
| 187 |
+
background: #1446a0;
|
| 188 |
}
|
| 189 |
|
| 190 |
button:disabled {
|
| 191 |
+
background: #f1f3f4;
|
| 192 |
+
color: #9aa0a6;
|
| 193 |
cursor: not-allowed;
|
| 194 |
+
box-shadow: none;
|
| 195 |
+
opacity: 1;
|
| 196 |
}
|
| 197 |
|
| 198 |
/* Pull row */
|
| 199 |
.pull-row {
|
| 200 |
display: flex;
|
| 201 |
+
gap: 12px;
|
| 202 |
margin-bottom: 12px;
|
| 203 |
}
|
| 204 |
|
|
|
|
| 208 |
|
| 209 |
.btn-pull {
|
| 210 |
white-space: nowrap;
|
| 211 |
+
padding: 10px 20px;
|
| 212 |
font-size: 14px;
|
| 213 |
}
|
| 214 |
|
| 215 |
.status {
|
| 216 |
font-size: 13px;
|
| 217 |
+
color: #5f6368;
|
| 218 |
+
margin-top: 8px;
|
| 219 |
+
padding: 8px 12px;
|
| 220 |
+
background: #f8f9fa;
|
| 221 |
+
border-radius: 8px;
|
| 222 |
}
|
| 223 |
|
| 224 |
/* Model list */
|
| 225 |
.model-list {
|
| 226 |
+
margin-top: 12px;
|
| 227 |
+
max-height: 300px;
|
| 228 |
+
overflow-y: auto;
|
| 229 |
}
|
| 230 |
|
| 231 |
.model-item {
|
| 232 |
display: flex;
|
| 233 |
align-items: center;
|
| 234 |
justify-content: space-between;
|
| 235 |
+
padding: 12px 16px;
|
| 236 |
+
background: #f8f9fa;
|
| 237 |
+
border: 1px solid #e8eaed;
|
| 238 |
border-radius: 8px;
|
| 239 |
margin-bottom: 8px;
|
| 240 |
+
transition: all 0.2s;
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
.model-item:hover {
|
| 244 |
+
background: #f1f3f4;
|
| 245 |
+
border-color: #dadce0;
|
| 246 |
}
|
| 247 |
|
| 248 |
.model-info {
|
| 249 |
display: flex;
|
| 250 |
flex-direction: column;
|
| 251 |
+
gap: 4px;
|
| 252 |
}
|
| 253 |
|
| 254 |
.model-name {
|
| 255 |
+
font-size: 14px;
|
| 256 |
font-weight: 500;
|
| 257 |
+
color: #202124;
|
| 258 |
}
|
| 259 |
|
| 260 |
.model-size {
|
| 261 |
font-size: 12px;
|
| 262 |
+
color: #5f6368;
|
| 263 |
}
|
| 264 |
|
| 265 |
.btn-delete {
|
| 266 |
background: transparent;
|
| 267 |
+
color: #5f6368;
|
| 268 |
+
padding: 8px;
|
| 269 |
+
font-size: 18px;
|
| 270 |
+
border-radius: 50%;
|
| 271 |
+
width: 36px;
|
| 272 |
+
height: 36px;
|
| 273 |
+
display: flex;
|
| 274 |
+
align-items: center;
|
| 275 |
+
justify-content: center;
|
| 276 |
}
|
| 277 |
|
| 278 |
.btn-delete:hover {
|
| 279 |
+
background: #fce8e6;
|
| 280 |
+
color: #d93025;
|
| 281 |
opacity: 1;
|
| 282 |
}
|
| 283 |
|
| 284 |
.empty {
|
| 285 |
+
color: #5f6368;
|
| 286 |
font-size: 14px;
|
| 287 |
text-align: center;
|
| 288 |
+
padding: 32px 20px;
|
| 289 |
+
}
|
| 290 |
+
|
| 291 |
+
/* Chat Container */
|
| 292 |
+
.chat-container {
|
| 293 |
+
flex: 1;
|
| 294 |
+
overflow-y: auto;
|
| 295 |
+
background: #f8f9fa;
|
| 296 |
padding: 20px;
|
| 297 |
}
|
| 298 |
|
| 299 |
+
/* Empty State */
|
| 300 |
+
.empty-state {
|
| 301 |
+
display: flex;
|
| 302 |
+
flex-direction: column;
|
| 303 |
+
align-items: center;
|
| 304 |
+
justify-content: center;
|
| 305 |
+
height: 100%;
|
| 306 |
+
text-align: center;
|
| 307 |
+
color: #5f6368;
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
.empty-icon {
|
| 311 |
+
font-size: 64px;
|
| 312 |
+
margin-bottom: 16px;
|
| 313 |
+
opacity: 0.5;
|
| 314 |
}
|
| 315 |
|
| 316 |
+
.empty-state h2 {
|
| 317 |
+
font-size: 24px;
|
| 318 |
+
font-weight: 400;
|
| 319 |
+
color: #202124;
|
| 320 |
+
margin-bottom: 8px;
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
.empty-state p {
|
| 324 |
+
font-size: 14px;
|
| 325 |
+
color: #5f6368;
|
| 326 |
+
}
|
| 327 |
+
|
| 328 |
+
/* Messages */
|
| 329 |
+
.messages {
|
| 330 |
+
max-width: 900px;
|
| 331 |
+
margin: 0 auto;
|
| 332 |
+
display: flex;
|
| 333 |
+
flex-direction: column;
|
| 334 |
+
gap: 16px;
|
| 335 |
+
}
|
| 336 |
+
|
| 337 |
+
.message {
|
| 338 |
+
display: flex;
|
| 339 |
+
gap: 12px;
|
| 340 |
+
animation: fadeIn 0.3s ease-out;
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
+
@keyframes fadeIn {
|
| 344 |
+
from {
|
| 345 |
+
opacity: 0;
|
| 346 |
+
transform: translateY(10px);
|
| 347 |
+
}
|
| 348 |
+
to {
|
| 349 |
+
opacity: 1;
|
| 350 |
+
transform: translateY(0);
|
| 351 |
+
}
|
| 352 |
+
}
|
| 353 |
+
|
| 354 |
+
.message-avatar {
|
| 355 |
+
width: 36px;
|
| 356 |
+
height: 36px;
|
| 357 |
+
border-radius: 50%;
|
| 358 |
+
display: flex;
|
| 359 |
+
align-items: center;
|
| 360 |
+
justify-content: center;
|
| 361 |
+
font-size: 20px;
|
| 362 |
+
flex-shrink: 0;
|
| 363 |
+
background: #e8eaed;
|
| 364 |
+
}
|
| 365 |
+
|
| 366 |
+
.message-user .message-avatar {
|
| 367 |
+
background: #e8f0fe;
|
| 368 |
+
}
|
| 369 |
+
|
| 370 |
+
.message-assistant .message-avatar {
|
| 371 |
+
background: #e8eaed;
|
| 372 |
+
}
|
| 373 |
+
|
| 374 |
+
.message-content {
|
| 375 |
+
flex: 1;
|
| 376 |
+
min-width: 0;
|
| 377 |
+
}
|
| 378 |
+
|
| 379 |
+
.message-text {
|
| 380 |
+
background: #ffffff;
|
| 381 |
+
padding: 12px 16px;
|
| 382 |
border-radius: 8px;
|
| 383 |
+
font-size: 14px;
|
|
|
|
|
|
|
| 384 |
line-height: 1.6;
|
| 385 |
+
color: #202124;
|
| 386 |
white-space: pre-wrap;
|
| 387 |
+
word-wrap: break-word;
|
| 388 |
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
| 389 |
+
border: 1px solid #e8eaed;
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
+
.message-user .message-text {
|
| 393 |
+
background: #e8f0fe;
|
| 394 |
+
border-color: #d2e3fc;
|
| 395 |
+
}
|
| 396 |
+
|
| 397 |
+
.message-meta {
|
| 398 |
+
font-size: 12px;
|
| 399 |
+
color: #5f6368;
|
| 400 |
+
margin-top: 6px;
|
| 401 |
+
padding: 0 4px;
|
| 402 |
+
}
|
| 403 |
+
|
| 404 |
+
.message-model {
|
| 405 |
+
color: #1967d2;
|
| 406 |
+
}
|
| 407 |
+
|
| 408 |
+
/* Typing Indicator */
|
| 409 |
+
.typing-indicator {
|
| 410 |
+
display: flex;
|
| 411 |
+
gap: 6px;
|
| 412 |
+
padding: 12px 16px;
|
| 413 |
+
}
|
| 414 |
+
|
| 415 |
+
.typing-indicator span {
|
| 416 |
+
width: 8px;
|
| 417 |
+
height: 8px;
|
| 418 |
+
border-radius: 50%;
|
| 419 |
+
background: #5f6368;
|
| 420 |
+
animation: typing 1.4s infinite;
|
| 421 |
+
}
|
| 422 |
+
|
| 423 |
+
.typing-indicator span:nth-child(2) {
|
| 424 |
+
animation-delay: 0.2s;
|
| 425 |
+
}
|
| 426 |
+
|
| 427 |
+
.typing-indicator span:nth-child(3) {
|
| 428 |
+
animation-delay: 0.4s;
|
| 429 |
+
}
|
| 430 |
+
|
| 431 |
+
@keyframes typing {
|
| 432 |
+
0%, 60%, 100% {
|
| 433 |
+
opacity: 0.3;
|
| 434 |
+
transform: translateY(0);
|
| 435 |
+
}
|
| 436 |
+
30% {
|
| 437 |
+
opacity: 1;
|
| 438 |
+
transform: translateY(-8px);
|
| 439 |
+
}
|
| 440 |
+
}
|
| 441 |
+
|
| 442 |
+
/* Input Container */
|
| 443 |
+
.input-container {
|
| 444 |
+
background: #ffffff;
|
| 445 |
+
border-top: 1px solid #e8eaed;
|
| 446 |
+
padding: 16px 20px;
|
| 447 |
+
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.05);
|
| 448 |
+
}
|
| 449 |
+
|
| 450 |
+
.input-wrapper {
|
| 451 |
+
max-width: 900px;
|
| 452 |
+
margin: 0 auto;
|
| 453 |
+
display: flex;
|
| 454 |
+
gap: 12px;
|
| 455 |
+
align-items: flex-end;
|
| 456 |
+
}
|
| 457 |
+
|
| 458 |
+
.chat-input {
|
| 459 |
+
flex: 1;
|
| 460 |
+
background: #f8f9fa;
|
| 461 |
+
color: #202124;
|
| 462 |
+
border: 1px solid #e8eaed;
|
| 463 |
+
border-radius: 24px;
|
| 464 |
+
padding: 12px 20px;
|
| 465 |
+
font-size: 14px;
|
| 466 |
+
outline: none;
|
| 467 |
+
resize: none;
|
| 468 |
+
max-height: 150px;
|
| 469 |
+
font-family: inherit;
|
| 470 |
+
line-height: 1.5;
|
| 471 |
+
transition: all 0.2s;
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
.chat-input:hover {
|
| 475 |
+
border-color: #dadce0;
|
| 476 |
+
}
|
| 477 |
+
|
| 478 |
+
.chat-input:focus {
|
| 479 |
+
background: #ffffff;
|
| 480 |
+
border-color: #1967d2;
|
| 481 |
+
box-shadow: 0 0 0 3px rgba(25, 103, 210, 0.1);
|
| 482 |
+
}
|
| 483 |
+
|
| 484 |
+
.chat-input:disabled {
|
| 485 |
+
background: #f1f3f4;
|
| 486 |
+
color: #9aa0a6;
|
| 487 |
+
cursor: not-allowed;
|
| 488 |
+
}
|
| 489 |
+
|
| 490 |
+
.send-btn {
|
| 491 |
+
width: 48px;
|
| 492 |
+
height: 48px;
|
| 493 |
+
border-radius: 50%;
|
| 494 |
+
padding: 0;
|
| 495 |
+
display: flex;
|
| 496 |
+
align-items: center;
|
| 497 |
+
justify-content: center;
|
| 498 |
+
font-size: 20px;
|
| 499 |
+
flex-shrink: 0;
|
| 500 |
+
background: #1967d2;
|
| 501 |
+
color: #ffffff;
|
| 502 |
+
}
|
| 503 |
+
|
| 504 |
+
.send-btn:hover {
|
| 505 |
+
background: #1557b0;
|
| 506 |
+
}
|
| 507 |
+
|
| 508 |
+
.send-btn:disabled {
|
| 509 |
+
background: #f1f3f4;
|
| 510 |
+
color: #9aa0a6;
|
| 511 |
+
}
|
| 512 |
+
|
| 513 |
+
/* Mobile Responsive */
|
| 514 |
+
@media (max-width: 768px) {
|
| 515 |
+
.header {
|
| 516 |
+
padding: 12px 16px;
|
| 517 |
+
}
|
| 518 |
+
|
| 519 |
+
.header-title h1 {
|
| 520 |
+
font-size: 18px;
|
| 521 |
+
}
|
| 522 |
+
|
| 523 |
+
.model-badge {
|
| 524 |
+
font-size: 11px;
|
| 525 |
+
padding: 3px 8px;
|
| 526 |
+
}
|
| 527 |
+
|
| 528 |
+
.settings-content {
|
| 529 |
+
padding: 20px 16px;
|
| 530 |
+
}
|
| 531 |
+
|
| 532 |
+
.chat-container {
|
| 533 |
+
padding: 16px;
|
| 534 |
+
}
|
| 535 |
+
|
| 536 |
+
.messages {
|
| 537 |
+
gap: 12px;
|
| 538 |
+
}
|
| 539 |
+
|
| 540 |
+
.message-avatar {
|
| 541 |
+
width: 32px;
|
| 542 |
+
height: 32px;
|
| 543 |
+
font-size: 16px;
|
| 544 |
+
}
|
| 545 |
+
|
| 546 |
+
.message-text {
|
| 547 |
+
font-size: 14px;
|
| 548 |
+
padding: 10px 14px;
|
| 549 |
+
}
|
| 550 |
+
|
| 551 |
+
.input-container {
|
| 552 |
+
padding: 12px 16px;
|
| 553 |
+
}
|
| 554 |
+
|
| 555 |
+
.chat-input {
|
| 556 |
+
padding: 10px 16px;
|
| 557 |
+
font-size: 16px; /* Prevents zoom on iOS */
|
| 558 |
+
}
|
| 559 |
+
|
| 560 |
+
.send-btn {
|
| 561 |
+
width: 44px;
|
| 562 |
+
height: 44px;
|
| 563 |
+
}
|
| 564 |
+
|
| 565 |
+
.empty-icon {
|
| 566 |
+
font-size: 48px;
|
| 567 |
+
}
|
| 568 |
+
|
| 569 |
+
.empty-state h2 {
|
| 570 |
+
font-size: 20px;
|
| 571 |
+
}
|
| 572 |
+
}
|
| 573 |
+
|
| 574 |
+
@media (max-width: 480px) {
|
| 575 |
+
.header-title {
|
| 576 |
+
gap: 8px;
|
| 577 |
+
}
|
| 578 |
+
|
| 579 |
+
.header-title h1 {
|
| 580 |
+
font-size: 16px;
|
| 581 |
+
}
|
| 582 |
+
|
| 583 |
+
.model-badge {
|
| 584 |
+
display: none;
|
| 585 |
+
}
|
| 586 |
+
|
| 587 |
+
.icon-btn {
|
| 588 |
+
width: 36px;
|
| 589 |
+
height: 36px;
|
| 590 |
+
font-size: 18px;
|
| 591 |
+
}
|
| 592 |
+
|
| 593 |
+
.settings-content h2 {
|
| 594 |
+
font-size: 18px;
|
| 595 |
+
}
|
| 596 |
+
|
| 597 |
+
.field {
|
| 598 |
+
margin-bottom: 20px;
|
| 599 |
+
}
|
| 600 |
+
|
| 601 |
+
.pull-row {
|
| 602 |
+
flex-direction: column;
|
| 603 |
+
gap: 8px;
|
| 604 |
+
}
|
| 605 |
+
|
| 606 |
+
.btn-pull {
|
| 607 |
+
width: 100%;
|
| 608 |
+
}
|
| 609 |
}
|