⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Commit 0b27e86

Browse files
Add FIM auto-detection and fix database initialization
This commit implements automatic Fill-in-the-Middle (FIM) detection for code completion models and resolves critical database schema initialization issues. Major Features: - Add auto_detect_fim field to Provider model for automatic FIM capability detection from Ollama models - Implement dual model registration for FIM-capable models (chat + completion) - Add comprehensive FIM documentation with integration guides for Continue.dev and Cursor Database Improvements: - Fix transaction rollback issue in ensure_minimum_schema() that prevented auto_detect_fim column from persisting - Change from engine.begin() to engine.connect() with manual commit to avoid auto-rollback on constraint violations - Add init_database.py script for reliable schema initialization on fresh installs - Improve startup sequence: init_database → alembic stamp → start service Migration Fixes: - Update migrations 002 and 003 to use direct SQL for SQLite compatibility - Remove unsupported ALTER COLUMN and DROP CONSTRAINT operations - Add idempotent column creation with try/except for concurrent initialization - Create migration 006 for auto_detect_fim field Documentation: - Add FIM_CODE_COMPLETION.md with detailed implementation guide - Add COMPAT_MAPPING_PROPOSAL.md for OpenAI-compatible model mappings - Document workarounds for LiteLLM FIM limitations Testing & Utilities: - Add check_models.py and check_models_simple.py for model verification - Add startup scripts (start_web.sh, start_backend.sh) for proper service initialization order This ensures the system can be created from scratch without schema issues and properly detects FIM capabilities for code completion workflows. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
1 parent c76575d commit 0b27e86

26 files changed

+1151
-104
lines changed

COMPAT_MAPPING_PROPOSAL.md

Lines changed: 270 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
# Propuesta de Mapeo Mejorado para Modelos Compat
2+
3+
## Análisis de Modelos Disponibles
4+
5+
### Proveedores
6+
- **mks** (Ollama): 81 modelos
7+
- **localai** (OpenAI-compatible): 37 modelos
8+
9+
### Modelos por Características
10+
11+
#### Chat General (con razonamiento)
12+
Los modelos Qwen3 TODOS tienen capacidad de razonamiento según la DB:
13+
- `qwen3:4b` - 32K context, reasoning ✓
14+
- `qwen3:8b` - 32K context, reasoning ✓
15+
- `qwen3:14b` - 32K context, reasoning ✓
16+
- `qwen3:30b` - 32K context, reasoning ✓
17+
- `qwen3:32b` - 32K context, reasoning ✓
18+
19+
Otros modelos de chat:
20+
- `llama3.2:3b` - 128K context
21+
- `llama3.1:8b` - 128K context
22+
- `llama3.3:70b` - 8K context
23+
- `mistral:7b` - 32K context
24+
- `mistral-small:22b` - 32K context
25+
26+
#### Modelos de Razonamiento Dedicados
27+
- `deepseek-r1:7b` - reasoning ✓
28+
- `deepseek-r1:8b` - reasoning ✓
29+
- `deepseek-r1:14b` - reasoning ✓
30+
- `deepseek-r1:32b` - reasoning ✓
31+
- `gpt-oss:20b` - reasoning ✓
32+
- `magistral:24b` - reasoning ✓ (mistral con razonamiento)
33+
- `qwq:32b` - modelo de razonamiento especializado
34+
35+
#### Modelos Multimodales (Vision + Razonamiento)
36+
**Los modelos Qwen3-VL tienen VISION + REASONING:**
37+
- `qwen3-vl:4b` - 32K context, vision ✓, reasoning ✓
38+
- `qwen3-vl:8b` - 32K context, vision ✓, reasoning ✓
39+
- `qwen3-vl:30b` - 32K context, vision ✓, reasoning ✓
40+
- `qwen3-vl:32b` - 32K context, vision ✓, reasoning ✓
41+
42+
Otros modelos de visión:
43+
- `llama3.2-vision:11b` - 128K context, vision ✓
44+
- `gemma3:12b` - 8K context, vision ✓
45+
- `mistral-small3.1:24b` - 32K context, vision ✓
46+
- `mistral-small3.2:24b` - 32K context, vision ✓
47+
- `qwen2.5vl:7b` - 32K context, vision ✓
48+
49+
#### Código
50+
- `qwen2.5-coder:1.5b` - 32K context
51+
- `qwen2.5-coder:7b` - 32K context
52+
- `qwen2.5-coder:14b` - 32K context
53+
- `qwen3-coder:30b` - 32K context
54+
55+
#### Embeddings
56+
- `qwen3-embedding:0.6b` - 32K context
57+
- `qwen3-embedding:8b` - 32K context
58+
- `nomic-embed-text`
59+
- `bge-large`
60+
- `bge-m3`
61+
- `mxbai-embed-large`
62+
63+
---
64+
65+
## 🔥 PROPUESTA DE MAPEO MEJORADO
66+
67+
### 1. CHAT MODELS (Progressive Scale)
68+
69+
#### `gpt-3.5-turbo`**`qwen3:4b`** (proveedor: `mks`)
70+
**Cambio:** De `qwen3:4b` → sigue igual ✓
71+
- Contexto: 32K (suficiente para GPT-3.5)
72+
- Razonamiento: ✓
73+
- Uso: Fast, general chat
74+
75+
#### `gpt-3.5-turbo-16k`**`qwen3:8b`** (proveedor: `mks`)
76+
**Cambio:** De `qwen3:4b`**`qwen3:8b`** (más apropiado para 16K)
77+
- Contexto: 32K
78+
- Razonamiento: ✓
79+
- Más capacidad que el modelo base
80+
81+
#### `gpt-4o-mini`**`qwen3:8b`** (proveedor: `mks`)
82+
**Cambio:** Sigue igual ✓
83+
- Contexto: 32K
84+
- Razonamiento: ✓
85+
- Balanced performance
86+
87+
#### `gpt-4`**`qwen3:32b`** (proveedor: `mks`)
88+
**Cambio:** De `gpt-oss:20b`**`qwen3:32b`**
89+
**Razón:** Qwen3:32b tiene razonamiento nativo Y más parámetros
90+
- Contexto: 32K
91+
- Razonamiento: ✓
92+
- Premium quality
93+
94+
#### `gpt-4-32k`**`llama3.1:8b`** (proveedor: `mks`)
95+
**Cambio:** De `gpt-oss:20b`**`llama3.1:8b`**
96+
**Razón:** El nombre enfatiza contexto grande (128K > 32K)
97+
- Contexto: 128K ✓✓✓
98+
- Large context capability
99+
100+
#### `gpt-4o`**`qwen3:32b`** (proveedor: `mks`)
101+
**Cambio:** Sigue igual ✓
102+
- Contexto: 32K
103+
- Razonamiento: ✓
104+
- Premium model
105+
106+
#### **NUEVO:** `gpt-4-turbo`**`llama3.3:70b`** (proveedor: `mks`)
107+
**Razón:** El modelo más grande y potente disponible
108+
- Contexto: 8K (suficiente para la mayoría de casos)
109+
- Parámetros: 70B (máxima calidad)
110+
- Best quality available
111+
112+
---
113+
114+
### 2. VISION MODELS
115+
116+
#### `gpt-4-vision-preview`**`llama3.2-vision:11b`** (proveedor: `mks`)
117+
**Cambio:** Sigue igual ✓
118+
- Contexto: 128K ✓✓
119+
- Visión: ✓
120+
- Estable y bien probado
121+
122+
#### `gpt-4-turbo-vision`**`qwen3-vl:8b`** (proveedor: `mks`)
123+
**Cambio:** De `qwen3-vl:8b` → sigue igual ✓
124+
**VENTAJA ESPECIAL:** Vision + Reasoning!
125+
- Contexto: 32K
126+
- Visión: ✓
127+
- Razonamiento: ✓ (único!)
128+
129+
#### `gpt-4o-vision`**`qwen3-vl:32b`** (proveedor: `mks`)
130+
**Cambio:** Sigue igual ✓
131+
**VENTAJA ESPECIAL:** Vision + Reasoning en modelo grande!
132+
- Contexto: 32K
133+
- Visión: ✓
134+
- Razonamiento: ✓
135+
- Premium quality
136+
137+
#### **NUEVO:** `gpt-4-vision-mini`**`qwen3-vl:4b`** (proveedor: `mks`)
138+
**Razón:** Opción rápida para visión
139+
- Contexto: 32K
140+
- Visión: ✓
141+
- Razonamiento: ✓
142+
- Fast processing
143+
144+
---
145+
146+
### 3. EMBEDDING MODELS
147+
148+
#### `text-embedding-3-small`**`nomic-embed-text`** (proveedor: `mks`)
149+
**Cambio:** Sigue igual ✓
150+
- Lightweight, fast
151+
- Bien optimizado
152+
153+
#### `text-embedding-ada-002`**`nomic-embed-text`** (proveedor: `mks`)
154+
**Cambio:** Sigue igual ✓
155+
- Legacy compatibility
156+
157+
#### `text-embedding-3-large`**`qwen3-embedding:8b`** (proveedor: `mks`)
158+
**Cambio:** Sigue igual ✓
159+
- Contexto: 32K
160+
- High quality
161+
- Large dimensions (4096)
162+
163+
---
164+
165+
### 4. REASONING MODELS
166+
167+
#### `o1-mini`**`deepseek-r1:7b`** (proveedor: `mks`)
168+
**Cambio:** Sigue igual ✓
169+
- Razonamiento: ✓
170+
- Fast, lightweight
171+
172+
#### `o1-preview`**`deepseek-r1:14b`** (proveedor: `mks`)
173+
**Cambio:** Sigue igual ✓
174+
- Razonamiento: ✓
175+
- Balanced
176+
177+
#### `o1`**`deepseek-r1:32b`** (proveedor: `mks`)
178+
**Cambio:** Sigue igual ✓
179+
- Razonamiento: ✓
180+
- Premium reasoning
181+
182+
#### **NUEVO:** `o3-mini`**`deepseek-r1:8b`** (proveedor: `mks`)
183+
**Razón:** Opción intermedia entre o1-mini y o1-preview
184+
- Razonamiento: ✓
185+
- Balanced performance
186+
187+
#### **NUEVO:** `o1-pro`**`qwq:32b`** (proveedor: `mks`)
188+
**Razón:** Modelo especializado en razonamiento complejo
189+
- Razonamiento avanzado
190+
- 32B parámetros
191+
192+
---
193+
194+
### 5. CODE MODELS
195+
196+
#### `code-davinci-002`**`qwen2.5-coder:14b`** (proveedor: `mks`)
197+
**Cambio:** Sigue igual ✓
198+
- Contexto: 32K
199+
- Code specialized
200+
201+
#### `gpt-4-code`**`qwen3-coder:30b`** (proveedor: `mks`)
202+
**Cambio:** Sigue igual ✓
203+
- Contexto: 32K
204+
- Premium code model
205+
206+
#### **NUEVO:** `gpt-3.5-turbo-instruct`**`qwen2.5-coder:7b`** (proveedor: `mks`)
207+
**Razón:** Modelo rápido para code completion
208+
- Contexto: 32K
209+
- Fast code generation
210+
211+
---
212+
213+
## 📊 RESUMEN DE CAMBIOS
214+
215+
### Cambios Principales
216+
1. **`gpt-4`**: `gpt-oss:20b`**`qwen3:32b`** (mejor razonamiento, más parámetros)
217+
2. **`gpt-4-32k`**: `gpt-oss:20b`**`llama3.1:8b`** (128K contexto)
218+
3. **`gpt-3.5-turbo-16k`**: `qwen3:4b`**`qwen3:8b`** (más apropiado)
219+
220+
### Modelos Nuevos Agregados
221+
1. **`gpt-4-turbo`**`llama3.3:70b` (máxima calidad)
222+
2. **`gpt-4-vision-mini`**`qwen3-vl:4b` (visión rápida)
223+
3. **`o3-mini`**`deepseek-r1:8b` (razonamiento intermedio)
224+
4. **`o1-pro`**`qwq:32b` (razonamiento premium)
225+
5. **`gpt-3.5-turbo-instruct`**`qwen2.5-coder:7b` (code completion)
226+
227+
### Ventajas Clave
228+
- ✓ Uso de modelos con **razonamiento nativo** (qwen3 series)
229+
- ✓ Modelos **multimodales únicos** (qwen3-vl con vision + reasoning)
230+
- ✓ Mejor escalado por **tamaño y capacidades**
231+
- ✓ Aprovechamiento de **contextos largos** (llama3 128K)
232+
- ✓ Especialización apropiada (embeddings, code, reasoning, vision)
233+
234+
---
235+
236+
## 🎯 MAPEO RECOMENDADO POR CASO DE USO
237+
238+
| Caso de Uso | Modelo OpenAI | Modelo Ollama | Características |
239+
|-------------|---------------|---------------|-----------------|
240+
| Chat rápido | gpt-3.5-turbo | qwen3:4b | 32K ctx, reasoning |
241+
| Chat balanceado | gpt-4o-mini | qwen3:8b | 32K ctx, reasoning |
242+
| Chat premium | gpt-4, gpt-4o | qwen3:32b | 32K ctx, reasoning |
243+
| Máxima calidad | gpt-4-turbo | llama3.3:70b | 70B params |
244+
| Contexto largo | gpt-4-32k | llama3.1:8b | 128K ctx |
245+
| Visión estable | gpt-4-vision-preview | llama3.2-vision:11b | 128K ctx, vision |
246+
| Visión + razonamiento | gpt-4-turbo-vision | qwen3-vl:8b | vision + reasoning |
247+
| Visión premium | gpt-4o-vision | qwen3-vl:32b | vision + reasoning |
248+
| Visión rápida | gpt-4-vision-mini | qwen3-vl:4b | vision + reasoning |
249+
| Embeddings rápidos | text-embedding-3-small | nomic-embed-text | lightweight |
250+
| Embeddings quality | text-embedding-3-large | qwen3-embedding:8b | 32K ctx, 4096 dim |
251+
| Razonamiento rápido | o1-mini | deepseek-r1:7b | reasoning |
252+
| Razonamiento balanceado | o1-preview | deepseek-r1:14b | reasoning |
253+
| Razonamiento intermedio | o3-mini | deepseek-r1:8b | reasoning |
254+
| Razonamiento premium | o1 | deepseek-r1:32b | reasoning |
255+
| Razonamiento avanzado | o1-pro | qwq:32b | advanced reasoning |
256+
| Código rápido | gpt-3.5-turbo-instruct | qwen2.5-coder:7b | code |
257+
| Código balanceado | code-davinci-002 | qwen2.5-coder:14b | code |
258+
| Código premium | gpt-4-code | qwen3-coder:30b | code |
259+
260+
---
261+
262+
## 🚀 IMPLEMENTACIÓN
263+
264+
Para implementar este mapeo mejorado, se debe actualizar el archivo:
265+
`shared/default_compat_models.py`
266+
267+
Con los cambios mencionados arriba, especialmente:
268+
1. Cambiar los modelos indicados
269+
2. Agregar los 5 nuevos modelos
270+
3. Actualizar las definiciones de `litellm_params` y `model_info` con las características correctas

0 commit comments

Comments
 (0)