@ssmeo/mcp-local-rag 0.18.10 → 0.18.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.de.md +23 -2
- package/README.es.md +23 -2
- package/README.fr.md +23 -2
- package/README.md +34 -2
- package/README.pt-BR.md +23 -2
- package/README.zh-CN.md +23 -2
- package/dist/cli/common.d.ts.map +1 -1
- package/dist/cli/common.js +15 -2
- package/dist/cli/common.js.map +1 -1
- package/dist/cli/options.d.ts +19 -0
- package/dist/cli/options.d.ts.map +1 -1
- package/dist/cli/options.js +72 -8
- package/dist/cli/options.js.map +1 -1
- package/dist/rerank/command.d.ts +21 -0
- package/dist/rerank/command.d.ts.map +1 -0
- package/dist/rerank/command.js +20 -0
- package/dist/rerank/command.js.map +1 -0
- package/dist/rerank/index.d.ts +21 -0
- package/dist/rerank/index.d.ts.map +1 -0
- package/dist/rerank/index.js +104 -0
- package/dist/rerank/index.js.map +1 -0
- package/dist/rerank/response.d.ts +29 -0
- package/dist/rerank/response.d.ts.map +1 -0
- package/dist/rerank/response.js +77 -0
- package/dist/rerank/response.js.map +1 -0
- package/dist/server/index.d.ts +5 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +59 -27
- package/dist/server/index.js.map +1 -1
- package/dist/server/tool-definitions.js +1 -1
- package/dist/server/tool-definitions.js.map +1 -1
- package/dist/server/tool-input.d.ts.map +1 -1
- package/dist/server/tool-input.js +5 -5
- package/dist/server/tool-input.js.map +1 -1
- package/dist/server/types.d.ts +4 -0
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server-main.d.ts +13 -22
- package/dist/server-main.d.ts.map +1 -1
- package/dist/server-main.js +50 -59
- package/dist/server-main.js.map +1 -1
- package/dist/utils/limits.d.ts +16 -1
- package/dist/utils/limits.d.ts.map +1 -1
- package/dist/utils/limits.js +16 -1
- package/dist/utils/limits.js.map +1 -1
- package/dist/vectordb/types.d.ts +4 -1
- package/dist/vectordb/types.d.ts.map +1 -1
- package/dist/vectordb/types.js.map +1 -1
- package/package.json +1 -1
- package/skills/mcp-local-rag/SKILL.md +3 -3
- package/skills/mcp-local-rag/references/cli-reference.md +1 -1
package/README.de.md
CHANGED
|
@@ -273,9 +273,11 @@ npx mcp-local-rag --db-path ./my-db query "Authentifizierung"
|
|
|
273
273
|
|
|
274
274
|
Die CLI liest keine MCP-Client-Konfiguration. Wenn beide Schnittstellen denselben Index verwenden sollen, müssen dieselben Umgebungsvariablen oder Optionen gesetzt sein. Insbesondere müssen `MODEL_NAME` und die CLI-Option `--model-name` für eine gemeinsam verwendete Datenbank übereinstimmen.
|
|
275
275
|
|
|
276
|
+
`query` schreibt seine Ergebnisse als JSON nach stdout, den besten Treffer zuerst, sodass sie sich per Pipe an ein anderes Werkzeug übergeben lassen. Die Definition der einzelnen Felder steht in [`docs/schema/query-output.schema.json`](docs/schema/query-output.schema.json).
|
|
277
|
+
|
|
276
278
|
## Suchparameter anpassen
|
|
277
279
|
|
|
278
|
-
Die Stichwortgewichtung ist standardmäßig aktiv. Für Korpora, die eine strengere Auswahl erfordern, stehen außerdem die Gruppierung anhand von Relevanzsprüngen sowie Distanz- und Dateifilter zur Verfügung.
|
|
280
|
+
Die Stichwortgewichtung ist standardmäßig aktiv. Für Korpora, die eine strengere Auswahl erfordern, stehen außerdem die Gruppierung anhand von Relevanzsprüngen sowie Distanz- und Dateifilter zur Verfügung. Alle vier gelten für den MCP-Server und für `query` in der CLI gleichermaßen.
|
|
279
281
|
|
|
280
282
|
| Variable | Standard | Beschreibung |
|
|
281
283
|
|----------|---------|-------------|
|
|
@@ -283,6 +285,8 @@ Die Stichwortgewichtung ist standardmäßig aktiv. Für Korpora, die eine streng
|
|
|
283
285
|
| `RAG_GROUPING` | nicht gesetzt | `similar` behält die erste Relevanzgruppe; `related` behält bis zu zwei Gruppen und trennt sie an deutlichen Sprüngen der Vektordistanz. |
|
|
284
286
|
| `RAG_MAX_DISTANCE` | nicht gesetzt | Filtert wenig relevante Treffer heraus, zum Beispiel mit `0.5`. |
|
|
285
287
|
| `RAG_MAX_FILES` | nicht gesetzt | Beschränkt die Treffer auf die besten N Dateien, zum Beispiel mit `1` auf die beste Datei. |
|
|
288
|
+
| `RAG_RERANK_CMD` | nicht gesetzt | Nur MCP-Server: externer Befehl, der die Treffer neu ordnet. Deine Suchanfrage und der gefundene Text gehen an ihn. |
|
|
289
|
+
| `RAG_RERANK_TIMEOUT_MS` | `10000` | Zeitbudget pro Neuordnung in Millisekunden (100–600000). |
|
|
286
290
|
|
|
287
291
|
Bei API-Spezifikationen und anderen Dokumenten mit vielen Bezeichnern kann ein höheres Stichwortgewicht die Rangfolge exakter Treffer verbessern:
|
|
288
292
|
|
|
@@ -295,6 +299,23 @@ Bei API-Spezifikationen und anderen Dokumenten mit vielen Bezeichnern kann ein h
|
|
|
295
299
|
- `0.7`: etwas stärkere Gewichtung exakter Begriffe als in der Standardeinstellung
|
|
296
300
|
- `1.0`: höchste Stichwortgewichtung
|
|
297
301
|
|
|
302
|
+
### Externes Neuordnen (`RAG_RERANK_CMD`)
|
|
303
|
+
|
|
304
|
+
Nenne hier einen Befehl, und der Server übergibt ihm jede Trefferliste zum Neuordnen, zusammen mit deiner Suchanfrage und dem Text der gefundenen Abschnitte. Ein Befehl, der einen entfernten Dienst aufruft, sendet all das von diesem Rechner fort.
|
|
305
|
+
|
|
306
|
+
Gib den Befehl und seine Argumente durch Leerzeichen getrennt an. Es muss eine ausführbare Datei sein: Der Server startet sie ohne Shell, deshalb lässt sich ein von npm installierter `.cmd`-Wrapper unter Windows nicht starten.
|
|
307
|
+
|
|
308
|
+
```json
|
|
309
|
+
"env": {
|
|
310
|
+
"RAG_RERANK_CMD": "/path/to/reranker",
|
|
311
|
+
"RAG_RERANK_TIMEOUT_MS": "10000"
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
Der Befehl erhält jeden Treffer in der unter [`docs/schema/query-output.schema.json`](docs/schema/query-output.schema.json) veröffentlichten Form und muss in derselben Form antworten. Darin entscheidet er alles: was er behält, wie er es ordnet und was im Text steht. Was er zurückgibt, bekommst du zu sehen.
|
|
316
|
+
|
|
317
|
+
Schlägt der Befehl fehl, läuft er in die Zeitgrenze oder antwortet er mit etwas, das diese Form nicht hat, bleibt die ursprüngliche Reihenfolge erhalten.
|
|
318
|
+
|
|
298
319
|
## Funktionsweise
|
|
299
320
|
|
|
300
321
|
Beim Import:
|
|
@@ -380,7 +401,7 @@ Ein Beispiel für deutschsprachige Dokumente ist das Modell `jinaai/jina-embeddi
|
|
|
380
401
|
|
|
381
402
|
- Dateizugriffe sind auf die mit `BASE_DIR`, `BASE_DIRS` oder der CLI-Option `--base-dir` festgelegten Stammverzeichnisse beschränkt.
|
|
382
403
|
- Symbolische Links, deren Ziel außerhalb aller konfigurierten Stammverzeichnisse liegt, werden abgelehnt.
|
|
383
|
-
- Sobald die benötigten Modelle im Cache liegen, greifen Dokumentverarbeitung und Suche nicht mehr auf das Netzwerk zu.
|
|
404
|
+
- Sobald die benötigten Modelle im Cache liegen, greifen Dokumentverarbeitung und Suche nicht mehr auf das Netzwerk zu, sofern `RAG_RERANK_CMD` nicht einen Befehl benennt, der das tut.
|
|
384
405
|
- Der Server ist für einen einzelnen lokalen Benutzer ausgelegt und bietet keine Authentifizierung oder Zugriffskontrolle.
|
|
385
406
|
- Mehrere CLI- oder MCP-Schreibprozesse dürfen nicht gleichzeitig denselben `DB_PATH` verwenden. Reine Leseabfragen sind während einer Synchronisierung möglich.
|
|
386
407
|
- Sichere den Index, indem du das `DB_PATH`-Verzeichnis kopierst, während kein Schreibprozess läuft.
|
package/README.es.md
CHANGED
|
@@ -273,9 +273,11 @@ Ejecuta `npx mcp-local-rag --help` para ver la referencia completa de comandos.
|
|
|
273
273
|
|
|
274
274
|
La CLI no lee la configuración del cliente MCP. Configura las mismas variables de entorno u opciones si ambas interfaces deben compartir un índice. En particular, `MODEL_NAME` y la opción `--model-name` de la CLI deben coincidir cuando usan la misma base de datos.
|
|
275
275
|
|
|
276
|
+
`query` escribe sus resultados en stdout como JSON, con la mejor coincidencia primero, de modo que puedes canalizarlos hacia otra herramienta. La definición de cada campo está en [`docs/schema/query-output.schema.json`](docs/schema/query-output.schema.json).
|
|
277
|
+
|
|
276
278
|
## Ajuste de la búsqueda
|
|
277
279
|
|
|
278
|
-
El refuerzo de palabras clave está activado de forma predeterminada. Para corpus que necesiten una selección más estricta, también se pueden configurar la agrupación por saltos de relevancia y los filtros de distancia y de archivos.
|
|
280
|
+
El refuerzo de palabras clave está activado de forma predeterminada. Para corpus que necesiten una selección más estricta, también se pueden configurar la agrupación por saltos de relevancia y los filtros de distancia y de archivos. Las cuatro se aplican por igual al servidor MCP y a `query` en la CLI.
|
|
279
281
|
|
|
280
282
|
| Variable | Valor predeterminado | Descripción |
|
|
281
283
|
|----------|---------|-------------|
|
|
@@ -283,6 +285,8 @@ El refuerzo de palabras clave está activado de forma predeterminada. Para corpu
|
|
|
283
285
|
| `RAG_GROUPING` | sin configurar | `similar` conserva el primer grupo de relevancia; `related` conserva hasta dos y usa saltos importantes de distancia vectorial como límites. |
|
|
284
286
|
| `RAG_MAX_DISTANCE` | sin configurar | Descarta resultados poco relevantes (por ejemplo, `0.5`). |
|
|
285
287
|
| `RAG_MAX_FILES` | sin configurar | Limita los resultados a los N archivos mejor clasificados (por ejemplo, `1` deja solo el mejor archivo). |
|
|
288
|
+
| `RAG_RERANK_CMD` | sin configurar | Solo servidor MCP: comando externo que reordena los resultados. Tu consulta y el texto encontrado se le envían. |
|
|
289
|
+
| `RAG_RERANK_TIMEOUT_MS` | `10000` | Tiempo máximo por llamada de reordenamiento en milisegundos (100–600000). |
|
|
286
290
|
|
|
287
291
|
En especificaciones de API y otros documentos con muchos identificadores, un peso mayor de palabras clave puede mejorar la clasificación de términos exactos:
|
|
288
292
|
|
|
@@ -295,6 +299,23 @@ En especificaciones de API y otros documentos con muchos identificadores, un pes
|
|
|
295
299
|
- `0.7`: reajuste de términos exactos algo más fuerte que el valor predeterminado
|
|
296
300
|
- `1.0`: refuerzo máximo de palabras clave
|
|
297
301
|
|
|
302
|
+
### Reordenamiento externo (`RAG_RERANK_CMD`)
|
|
303
|
+
|
|
304
|
+
Indica aquí un comando y el servidor le entrega cada conjunto de resultados para reordenarlo, junto con tu consulta y el texto de los fragmentos encontrados. Un comando que contacta con un servicio remoto envía todo eso fuera de esta máquina.
|
|
305
|
+
|
|
306
|
+
Escribe el comando y sus argumentos separados por espacios. Tiene que ser un ejecutable: el servidor lo lanza sin shell, así que en Windows un adaptador `.cmd` instalado por npm no arranca.
|
|
307
|
+
|
|
308
|
+
```json
|
|
309
|
+
"env": {
|
|
310
|
+
"RAG_RERANK_CMD": "/path/to/reranker",
|
|
311
|
+
"RAG_RERANK_TIMEOUT_MS": "10000"
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
El comando recibe cada resultado con la forma publicada en [`docs/schema/query-output.schema.json`](docs/schema/query-output.schema.json) y debe responder con esa misma forma. Dentro de ella lo decide todo: qué conservar, cómo ordenarlo y qué dice el texto. Lo que devuelva es lo que verás.
|
|
316
|
+
|
|
317
|
+
Los resultados conservan su orden original si el comando falla, agota el tiempo o responde con algo que no tiene esa forma.
|
|
318
|
+
|
|
298
319
|
## Cómo funciona
|
|
299
320
|
|
|
300
321
|
Durante la incorporación:
|
|
@@ -380,7 +401,7 @@ Un ejemplo de modelo disponible para documentos en español es `jinaai/jina-embe
|
|
|
380
401
|
|
|
381
402
|
- El acceso a archivos está limitado a los directorios raíz configurados con `BASE_DIR`, `BASE_DIRS` o `--base-dir` en la CLI.
|
|
382
403
|
- Se rechazan los enlaces simbólicos cuyo destino esté fuera de todos los directorios raíz configurados.
|
|
383
|
-
- El procesamiento de documentos y las búsquedas no realizan solicitudes de red una vez que los modelos necesarios están en cach
|
|
404
|
+
- El procesamiento de documentos y las búsquedas no realizan solicitudes de red una vez que los modelos necesarios están en caché, salvo que `RAG_RERANK_CMD` indique un comando que sí las realice.
|
|
384
405
|
- El servidor está diseñado para un único usuario local y no ofrece autenticación ni control de acceso.
|
|
385
406
|
- No ejecutes varios procesos de escritura de la CLI o MCP sobre el mismo `DB_PATH`. Las consultas de solo lectura pueden ejecutarse mientras hay una sincronización en curso.
|
|
386
407
|
- Para crear una copia de seguridad del índice, copia el directorio `DB_PATH` cuando no haya ningún proceso de escritura activo.
|
package/README.fr.md
CHANGED
|
@@ -273,9 +273,11 @@ Exécutez `npx mcp-local-rag --help` pour afficher la référence complète des
|
|
|
273
273
|
|
|
274
274
|
La CLI ne lit pas la configuration du client MCP. Définissez les mêmes variables d'environnement ou options si les deux interfaces doivent partager un index. En particulier, `MODEL_NAME` et l'option CLI `--model-name` doivent correspondre pour une base de données partagée.
|
|
275
275
|
|
|
276
|
+
`query` écrit ses résultats sur stdout au format JSON, la meilleure correspondance en premier, ce qui permet de les rediriger vers un autre outil. La définition de chaque champ se trouve dans [`docs/schema/query-output.schema.json`](docs/schema/query-output.schema.json).
|
|
277
|
+
|
|
276
278
|
## Réglage de la recherche
|
|
277
279
|
|
|
278
|
-
Le renforcement par mots-clés est activé par défaut. Pour les corpus qui nécessitent une sélection plus stricte, vous pouvez aussi configurer le regroupement par écarts de pertinence ainsi que les filtres de distance et de fichiers.
|
|
280
|
+
Le renforcement par mots-clés est activé par défaut. Pour les corpus qui nécessitent une sélection plus stricte, vous pouvez aussi configurer le regroupement par écarts de pertinence ainsi que les filtres de distance et de fichiers. Les quatre s'appliquent aussi bien au serveur MCP qu'à `query` dans la CLI.
|
|
279
281
|
|
|
280
282
|
| Variable | Valeur par défaut | Description |
|
|
281
283
|
|----------|---------|-------------|
|
|
@@ -283,6 +285,8 @@ Le renforcement par mots-clés est activé par défaut. Pour les corpus qui néc
|
|
|
283
285
|
| `RAG_GROUPING` | non définie | `similar` conserve le premier groupe de pertinence ; `related` en conserve jusqu'à deux et utilise les écarts importants de distance vectorielle comme limites. |
|
|
284
286
|
| `RAG_MAX_DISTANCE` | non définie | Écarte les résultats peu pertinents, par exemple avec `0.5`. |
|
|
285
287
|
| `RAG_MAX_FILES` | non définie | Limite les résultats aux N fichiers les mieux classés, par exemple `1` pour le meilleur fichier uniquement. |
|
|
288
|
+
| `RAG_RERANK_CMD` | non définie | Serveur MCP uniquement : commande externe qui reclasse les résultats. Votre requête et le texte trouvé lui sont transmis. |
|
|
289
|
+
| `RAG_RERANK_TIMEOUT_MS` | `10000` | Délai maximal par reclassement, en millisecondes (100–600000). |
|
|
286
290
|
|
|
287
291
|
Pour les spécifications d'API et les autres documents comportant de nombreux identifiants, un poids plus élevé des mots-clés peut améliorer le classement des termes exacts :
|
|
288
292
|
|
|
@@ -295,6 +299,23 @@ Pour les spécifications d'API et les autres documents comportant de nombreux id
|
|
|
295
299
|
- `0.7` : reclassement des termes exacts légèrement plus fort que la valeur par défaut
|
|
296
300
|
- `1.0` : renforcement maximal des mots-clés
|
|
297
301
|
|
|
302
|
+
### Reclassement externe (`RAG_RERANK_CMD`)
|
|
303
|
+
|
|
304
|
+
Indiquez ici une commande et le serveur lui confie chaque liste de résultats à reclasser, avec votre requête et le texte des passages trouvés. Une commande qui appelle un service distant envoie tout cela hors de cette machine.
|
|
305
|
+
|
|
306
|
+
Donnez la commande et ses arguments séparés par des espaces. Ce doit être un exécutable : le serveur le lance sans shell, si bien qu'un script `.cmd` installé par npm ne démarre pas sous Windows.
|
|
307
|
+
|
|
308
|
+
```json
|
|
309
|
+
"env": {
|
|
310
|
+
"RAG_RERANK_CMD": "/path/to/reranker",
|
|
311
|
+
"RAG_RERANK_TIMEOUT_MS": "10000"
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
La commande reçoit chaque résultat dans la forme publiée à [`docs/schema/query-output.schema.json`](docs/schema/query-output.schema.json) et doit répondre dans cette même forme. À l'intérieur, elle décide de tout : ce qu'elle garde, comment elle l'ordonne et ce que dit le texte. Ce qu'elle renvoie est ce que vous voyez.
|
|
316
|
+
|
|
317
|
+
Les résultats conservent leur ordre d'origine si la commande échoue, dépasse le délai ou répond avec autre chose que cette forme.
|
|
318
|
+
|
|
298
319
|
## Fonctionnement
|
|
299
320
|
|
|
300
321
|
Pendant l'import :
|
|
@@ -380,7 +401,7 @@ Un exemple de modèle disponible pour les documents en français est `sentence-t
|
|
|
380
401
|
|
|
381
402
|
- L'accès aux fichiers est limité aux racines définies par `BASE_DIR`, `BASE_DIRS` ou l'option CLI `--base-dir`.
|
|
382
403
|
- Les liens symboliques qui pointent hors de toutes les racines configurées sont refusés.
|
|
383
|
-
- Le traitement des documents et la recherche n'effectuent plus de requêtes réseau une fois les modèles nécessaires en cache.
|
|
404
|
+
- Le traitement des documents et la recherche n'effectuent plus de requêtes réseau une fois les modèles nécessaires en cache, sauf si `RAG_RERANK_CMD` désigne une commande qui en effectue.
|
|
384
405
|
- Le serveur est conçu pour un seul utilisateur local et ne fournit ni authentification ni contrôle d'accès.
|
|
385
406
|
- Ne lancez pas plusieurs processus d'écriture CLI ou MCP sur le même `DB_PATH`. Les requêtes en lecture seule restent possibles pendant une synchronisation.
|
|
386
407
|
- Pour sauvegarder un index, copiez le répertoire `DB_PATH` lorsqu'aucun processus d'écriture n'est actif.
|
package/README.md
CHANGED
|
@@ -347,10 +347,15 @@ The CLI does not read MCP client configuration. Set the same environment variabl
|
|
|
347
347
|
both interfaces should share an index. In particular, `MODEL_NAME` and the CLI `--model-name`
|
|
348
348
|
must match for a shared database.
|
|
349
349
|
|
|
350
|
+
`query` writes its results to stdout as JSON, best match first, so it can be piped into
|
|
351
|
+
another tool. The field-by-field contract is in
|
|
352
|
+
[`docs/schema/query-output.schema.json`](docs/schema/query-output.schema.json).
|
|
353
|
+
|
|
350
354
|
## Search Tuning
|
|
351
355
|
|
|
352
356
|
Keyword boost is enabled by default. Relevance-gap grouping and the distance and file filters are
|
|
353
|
-
optional controls for corpora that need tighter result selection.
|
|
357
|
+
optional controls for corpora that need tighter result selection. All four apply to the MCP
|
|
358
|
+
server and to CLI `query` alike.
|
|
354
359
|
|
|
355
360
|
| Variable | Default | Description |
|
|
356
361
|
|----------|---------|-------------|
|
|
@@ -358,6 +363,8 @@ optional controls for corpora that need tighter result selection.
|
|
|
358
363
|
| `RAG_GROUPING` | (not set) | `similar` keeps the first relevance group; `related` keeps up to two, using significant vector-distance gaps as boundaries. |
|
|
359
364
|
| `RAG_MAX_DISTANCE` | (not set) | Filter out low-relevance results (e.g., `0.5`). |
|
|
360
365
|
| `RAG_MAX_FILES` | (not set) | Limit results to top N files (e.g., `1` for single best file). |
|
|
366
|
+
| `RAG_RERANK_CMD` | (not set) | MCP server only: external command that reorders results. Your query and the matched text are sent to it. |
|
|
367
|
+
| `RAG_RERANK_TIMEOUT_MS` | `10000` | Time budget per rerank call in milliseconds (100–600000). |
|
|
361
368
|
|
|
362
369
|
For API specifications and other documents containing many identifiers, a stronger keyword
|
|
363
370
|
weight can improve exact-term ranking:
|
|
@@ -371,6 +378,30 @@ weight can improve exact-term ranking:
|
|
|
371
378
|
- `0.7`: slightly stronger exact-term reranking than the default
|
|
372
379
|
- `1.0`: maximum keyword boost
|
|
373
380
|
|
|
381
|
+
### External Reranking (`RAG_RERANK_CMD`)
|
|
382
|
+
|
|
383
|
+
Name a command here and the server hands it each set of search results to reorder, together with
|
|
384
|
+
your query and the text of the matched chunks. A command that calls a remote service sends all of
|
|
385
|
+
that off this machine.
|
|
386
|
+
|
|
387
|
+
Give the command and its arguments separated by spaces. It has to be an executable: the server
|
|
388
|
+
runs it without a shell, so an npm-installed `.cmd` shim on Windows will not start.
|
|
389
|
+
|
|
390
|
+
```json
|
|
391
|
+
"env": {
|
|
392
|
+
"RAG_RERANK_CMD": "/path/to/reranker",
|
|
393
|
+
"RAG_RERANK_TIMEOUT_MS": "10000"
|
|
394
|
+
}
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
The command receives each result in the form published at
|
|
398
|
+
[`docs/schema/query-output.schema.json`](docs/schema/query-output.schema.json) and has to answer
|
|
399
|
+
in that same form. Within it the command decides everything: what to keep, how to order it, and
|
|
400
|
+
what the text says. Whatever it returns is what you see.
|
|
401
|
+
|
|
402
|
+
Results keep their original order if the command fails, times out, or answers with something that
|
|
403
|
+
is not that form.
|
|
404
|
+
|
|
374
405
|
## How It Works
|
|
375
406
|
|
|
376
407
|
During ingestion:
|
|
@@ -468,7 +499,8 @@ An example model for English documents is `Xenova/bge-small-en-v1.5`.
|
|
|
468
499
|
|
|
469
500
|
- File access is restricted to `BASE_DIR`, `BASE_DIRS`, or CLI `--base-dir` roots.
|
|
470
501
|
- Symlinks that resolve outside every configured root are rejected.
|
|
471
|
-
- Document processing and search make no network requests after the required models are cached
|
|
502
|
+
- Document processing and search make no network requests after the required models are cached,
|
|
503
|
+
unless `RAG_RERANK_CMD` names a command that makes them.
|
|
472
504
|
- The server is designed for one local user and does not provide authentication or access control.
|
|
473
505
|
- Do not run multiple CLI or MCP writers against the same `DB_PATH`. Read-only queries can run
|
|
474
506
|
while a sync is active.
|
package/README.pt-BR.md
CHANGED
|
@@ -273,9 +273,11 @@ Execute `npx mcp-local-rag --help` para consultar a referência completa dos com
|
|
|
273
273
|
|
|
274
274
|
A CLI não lê a configuração do cliente MCP. Defina as mesmas variáveis de ambiente ou opções se as duas interfaces precisarem compartilhar um índice. Em particular, `MODEL_NAME` e a opção `--model-name` da CLI devem ser iguais quando usam o mesmo banco de dados.
|
|
275
275
|
|
|
276
|
+
`query` grava os resultados em stdout como JSON, com a melhor correspondência primeiro, para que você possa encaminhá-los por pipe a outra ferramenta. A definição de cada campo está em [`docs/schema/query-output.schema.json`](docs/schema/query-output.schema.json).
|
|
277
|
+
|
|
276
278
|
## Ajuste da busca
|
|
277
279
|
|
|
278
|
-
O reforço por palavras-chave é ativado por padrão. Para acervos que exigem uma seleção mais restrita, também é possível configurar o agrupamento por saltos de relevância e os filtros de distância e de arquivos.
|
|
280
|
+
O reforço por palavras-chave é ativado por padrão. Para acervos que exigem uma seleção mais restrita, também é possível configurar o agrupamento por saltos de relevância e os filtros de distância e de arquivos. As quatro valem tanto para o servidor MCP quanto para `query` na CLI.
|
|
279
281
|
|
|
280
282
|
| Variável | Padrão | Descrição |
|
|
281
283
|
|----------|---------|-------------|
|
|
@@ -283,6 +285,8 @@ O reforço por palavras-chave é ativado por padrão. Para acervos que exigem um
|
|
|
283
285
|
| `RAG_GROUPING` | não definido | `similar` mantém o primeiro grupo de relevância; `related` mantém até dois e usa saltos relevantes na distância vetorial como limites. |
|
|
284
286
|
| `RAG_MAX_DISTANCE` | não definido | Descarta resultados pouco relevantes, por exemplo, com `0.5`. |
|
|
285
287
|
| `RAG_MAX_FILES` | não definido | Limita os resultados aos N arquivos mais bem classificados, por exemplo, `1` para apenas o melhor arquivo. |
|
|
288
|
+
| `RAG_RERANK_CMD` | não definido | Somente servidor MCP: comando externo que reordena os resultados. Sua consulta e o texto encontrado são enviados a ele. |
|
|
289
|
+
| `RAG_RERANK_TIMEOUT_MS` | `10000` | Tempo máximo por reordenamento em milissegundos (100–600000). |
|
|
286
290
|
|
|
287
291
|
Em especificações de API e outros documentos com muitos identificadores, um peso maior para palavras-chave pode melhorar a classificação de termos exatos:
|
|
288
292
|
|
|
@@ -295,6 +299,23 @@ Em especificações de API e outros documentos com muitos identificadores, um pe
|
|
|
295
299
|
- `0.7`: reordenamento de termos exatos um pouco mais forte que o padrão
|
|
296
300
|
- `1.0`: reforço máximo por palavras-chave
|
|
297
301
|
|
|
302
|
+
### Reordenamento externo (`RAG_RERANK_CMD`)
|
|
303
|
+
|
|
304
|
+
Informe aqui um comando e o servidor entrega a ele cada conjunto de resultados para reordenar, junto com sua consulta e o texto dos trechos encontrados. Um comando que acessa um serviço remoto envia tudo isso para fora desta máquina.
|
|
305
|
+
|
|
306
|
+
Escreva o comando e seus argumentos separados por espaços. Precisa ser um executável: o servidor o inicia sem shell, então no Windows um atalho `.cmd` instalado pelo npm não abre.
|
|
307
|
+
|
|
308
|
+
```json
|
|
309
|
+
"env": {
|
|
310
|
+
"RAG_RERANK_CMD": "/path/to/reranker",
|
|
311
|
+
"RAG_RERANK_TIMEOUT_MS": "10000"
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
O comando recebe cada resultado no formato publicado em [`docs/schema/query-output.schema.json`](docs/schema/query-output.schema.json) e precisa responder nesse mesmo formato. Dentro dele o comando decide tudo: o que manter, como ordenar e o que o texto diz. O que ele devolver é o que você vê.
|
|
316
|
+
|
|
317
|
+
Os resultados mantêm a ordem original se o comando falhar, estourar o tempo ou responder com algo fora desse formato.
|
|
318
|
+
|
|
298
319
|
## Como funciona
|
|
299
320
|
|
|
300
321
|
Durante a importação:
|
|
@@ -380,7 +401,7 @@ Um exemplo de modelo disponível para documentos em português é `Xenova/paraph
|
|
|
380
401
|
|
|
381
402
|
- O acesso a arquivos fica restrito aos diretórios raiz definidos em `BASE_DIR`, `BASE_DIRS` ou pela opção `--base-dir` da CLI.
|
|
382
403
|
- Links simbólicos que apontam para fora de todos os diretórios raiz configurados são rejeitados.
|
|
383
|
-
- O processamento dos documentos e as buscas não fazem solicitações de rede depois que os modelos necessários estão no cache.
|
|
404
|
+
- O processamento dos documentos e as buscas não fazem solicitações de rede depois que os modelos necessários estão no cache, a menos que `RAG_RERANK_CMD` indique um comando que as faça.
|
|
384
405
|
- O servidor foi projetado para um único usuário local e não oferece autenticação nem controle de acesso.
|
|
385
406
|
- Não execute vários processos de escrita da CLI ou do MCP no mesmo `DB_PATH`. Consultas somente leitura podem ser executadas durante uma sincronização.
|
|
386
407
|
- Para fazer backup do índice, copie o diretório `DB_PATH` enquanto não houver nenhum processo de escrita ativo.
|
package/README.zh-CN.md
CHANGED
|
@@ -273,9 +273,11 @@ npx mcp-local-rag --db-path ./my-db query "身份验证"
|
|
|
273
273
|
|
|
274
274
|
CLI 不读取 MCP 客户端配置。如果两个接口需要共用索引,请设置相同的环境变量或命令行参数。特别是共享同一数据库时,`MODEL_NAME` 必须与 CLI 的 `--model-name` 一致。
|
|
275
275
|
|
|
276
|
+
`query` 会以 JSON 格式将结果写入 stdout,最匹配的结果排在最前,因此可以通过管道传给其他工具。各字段的定义见 [`docs/schema/query-output.schema.json`](docs/schema/query-output.schema.json)。
|
|
277
|
+
|
|
276
278
|
## 搜索调优
|
|
277
279
|
|
|
278
|
-
|
|
280
|
+
关键词加权默认开启。对于需要更严格筛选结果的语料库,还可以使用相关度间隔分组、距离过滤和文件数量限制。这四项对 MCP 服务器和 CLI 的 `query` 同样生效。
|
|
279
281
|
|
|
280
282
|
| 变量 | 默认值 | 说明 |
|
|
281
283
|
|----------|---------|-------------|
|
|
@@ -283,6 +285,8 @@ CLI 不读取 MCP 客户端配置。如果两个接口需要共用索引,请
|
|
|
283
285
|
| `RAG_GROUPING` | 未设置 | `similar` 保留第一个相关度分组;`related` 最多保留两个分组,并以明显的向量距离间隔为边界。 |
|
|
284
286
|
| `RAG_MAX_DISTANCE` | 未设置 | 过滤相关度较低的结果(例如 `0.5`)。 |
|
|
285
287
|
| `RAG_MAX_FILES` | 未设置 | 将结果限制在排名最靠前的 N 个文件中(例如 `1` 表示只保留最佳文件)。 |
|
|
288
|
+
| `RAG_RERANK_CMD` | 未设置 | 仅 MCP 服务器:用于重排结果的外部命令。查询与命中片段的文本会发送给它。 |
|
|
289
|
+
| `RAG_RERANK_TIMEOUT_MS` | `10000` | 单次重排的超时时间,单位为毫秒(100–600000)。 |
|
|
286
290
|
|
|
287
291
|
对于包含大量标识符的 API 规范及类似文档,提高关键词权重可以改善精确术语的排名:
|
|
288
292
|
|
|
@@ -295,6 +299,23 @@ CLI 不读取 MCP 客户端配置。如果两个接口需要共用索引,请
|
|
|
295
299
|
- `0.7`:比默认值稍强的精确术语重排
|
|
296
300
|
- `1.0`:最大关键词加权
|
|
297
301
|
|
|
302
|
+
### 外部重排(`RAG_RERANK_CMD`)
|
|
303
|
+
|
|
304
|
+
在此指定一个命令,服务器会把每一批搜索结果连同查询和命中片段的文本交给它重新排序。调用远程服务的命令会把这些内容发送到本机之外。
|
|
305
|
+
|
|
306
|
+
填写命令及其参数,以空格分隔。它必须是可执行文件:服务器不经过 shell 启动它,因此 Windows 上由 npm 安装的 `.cmd` 包装脚本无法启动。
|
|
307
|
+
|
|
308
|
+
```json
|
|
309
|
+
"env": {
|
|
310
|
+
"RAG_RERANK_CMD": "/path/to/reranker",
|
|
311
|
+
"RAG_RERANK_TIMEOUT_MS": "10000"
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
该命令收到的每条结果都是 [`docs/schema/query-output.schema.json`](docs/schema/query-output.schema.json) 中公开的形式,并且必须以同样的形式返回。在此范围内,保留哪些、如何排序、正文写什么都由命令决定,返回的内容会直接呈现给你。
|
|
316
|
+
|
|
317
|
+
命令失败、超时,或返回的内容不符合该形式时,结果保持原有顺序。
|
|
318
|
+
|
|
298
319
|
## 工作原理
|
|
299
320
|
|
|
300
321
|
导入时:
|
|
@@ -380,7 +401,7 @@ mcp-local-rag 使用平均池化和 L2 归一化生成嵌入。选择模型时
|
|
|
380
401
|
|
|
381
402
|
- 文件访问仅限 `BASE_DIR`、`BASE_DIRS` 或 CLI 的 `--base-dir` 所指定的根目录。
|
|
382
403
|
- 指向所有已配置根目录之外的符号链接会被拒绝。
|
|
383
|
-
-
|
|
404
|
+
- 所需模型缓存完成后,文档处理和搜索不会再发起网络请求;如果 `RAG_RERANK_CMD` 指定的命令会发起网络请求,则不在此列。
|
|
384
405
|
- 服务器面向单个本地用户设计,不提供身份验证或访问控制。
|
|
385
406
|
- 不要让多个 CLI 或 MCP 写入进程同时操作同一个 `DB_PATH`。同步进行时仍可执行只读查询。
|
|
386
407
|
- 没有写入进程运行时,可以复制 `DB_PATH` 目录来备份索引。
|
package/dist/cli/common.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/cli/common.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,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HANGED
|
@@ -28,10 +28,23 @@ export function formatCliError(error) {
|
|
|
28
28
|
* Callers are responsible for calling initialize() before use.
|
|
29
29
|
*/
|
|
30
30
|
export function createVectorStore(config) {
|
|
31
|
-
|
|
31
|
+
const storeConfig = {
|
|
32
32
|
dbPath: config.dbPath,
|
|
33
33
|
tableName: 'chunks',
|
|
34
|
-
}
|
|
34
|
+
};
|
|
35
|
+
if (config.maxDistance !== undefined) {
|
|
36
|
+
storeConfig.maxDistance = config.maxDistance;
|
|
37
|
+
}
|
|
38
|
+
if (config.grouping !== undefined) {
|
|
39
|
+
storeConfig.grouping = config.grouping;
|
|
40
|
+
}
|
|
41
|
+
if (config.maxFiles !== undefined) {
|
|
42
|
+
storeConfig.maxFiles = config.maxFiles;
|
|
43
|
+
}
|
|
44
|
+
if (config.hybridWeight !== undefined) {
|
|
45
|
+
storeConfig.hybridWeight = config.hybridWeight;
|
|
46
|
+
}
|
|
47
|
+
return new VectorStore(storeConfig);
|
|
35
48
|
}
|
|
36
49
|
/**
|
|
37
50
|
* Create an uninitialized Embedder from resolved global config.
|
package/dist/cli/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/cli/common.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,8EAA8E;AAE9E,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAGL,gBAAgB,EAChB,eAAe,GAChB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAEL,aAAa,EACb,YAAY,EACZ,yBAAyB,EACzB,YAAY,GACb,MAAM,cAAc,CAAA;AAEr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AAM,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAA;AAC7D,CAAC"}
|
package/dist/cli/options.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type QualityProfile } from '../utils/visual-profile.js';
|
|
2
|
+
import type { GroupingMode } from '../vectordb/index.js';
|
|
2
3
|
/**
|
|
3
4
|
* Delegates to `checkSensitivePath`, so the CLI and MCP entry points share one
|
|
4
5
|
* policy. Returns an error message, or `undefined` when valid.
|
|
@@ -52,6 +53,11 @@ export interface ResolvedGlobalConfig {
|
|
|
52
53
|
dbPath: string;
|
|
53
54
|
cacheDir: string;
|
|
54
55
|
modelName: string;
|
|
56
|
+
/** Search tuning, read from the same environment variables the MCP server uses. */
|
|
57
|
+
maxDistance?: number;
|
|
58
|
+
grouping?: GroupingMode;
|
|
59
|
+
maxFiles?: number;
|
|
60
|
+
hybridWeight?: number;
|
|
55
61
|
}
|
|
56
62
|
export declare const GLOBAL_DEFAULTS: {
|
|
57
63
|
readonly dbPath: './lancedb/';
|
|
@@ -68,6 +74,19 @@ export declare function parseGlobalOptions(args: string[]): ParsedGlobalResult;
|
|
|
68
74
|
* Resolve global config with priority: CLI flags > environment variables > defaults.
|
|
69
75
|
* Validates all resolved values before returning.
|
|
70
76
|
*/
|
|
77
|
+
/** Result of parsing an environment variable. */
|
|
78
|
+
export interface ParseResult<T> {
|
|
79
|
+
value: T | undefined;
|
|
80
|
+
warning?: string;
|
|
81
|
+
}
|
|
82
|
+
/** Parse `RAG_GROUPING`. */
|
|
83
|
+
export declare function parseGroupingMode(value: string | undefined): ParseResult<GroupingMode>;
|
|
84
|
+
/** Parse `RAG_MAX_DISTANCE`. */
|
|
85
|
+
export declare function parseMaxDistance(value: string | undefined): ParseResult<number>;
|
|
86
|
+
/** Parse `RAG_MAX_FILES`. */
|
|
87
|
+
export declare function parseMaxFiles(value: string | undefined): ParseResult<number>;
|
|
88
|
+
/** Parse `RAG_HYBRID_WEIGHT`. */
|
|
89
|
+
export declare function parseHybridWeight(value: string | undefined): ParseResult<number>;
|
|
71
90
|
export declare function resolveGlobalConfig(options: GlobalOptions): ResolvedGlobalConfig;
|
|
72
91
|
/**
|
|
73
92
|
* Resolve RAG_DEVICE. The value is passed through to transformers.js — no
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/cli/options.ts"],"names":[],"mappings":"AAIA,OAAO,EAAoB,KAAK,cAAc,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/cli/options.ts"],"names":[],"mappings":"AAIA,OAAO,EAAoB,KAAK,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAClF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAMxD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEhF;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CASnE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAKrE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAKxE;AAMD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,CAShG;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAOxF;AAED;;;;GAIG;AACH,wBAAgB,o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C,MAAM,CAAC,CAU/E;AAED,6BAA6B;AAC7B,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,CAU5E;AAED,iCAAiC;AACjC,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,CAUhF;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,aAAa,GAAG,oBAAoB,CAkDhF;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAK/D;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAK1E;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAKvF"}
|
package/dist/cli/options.js
CHANGED
|
@@ -179,13 +179,54 @@ export function parseGlobalOptions(args) {
|
|
|
179
179
|
}
|
|
180
180
|
return { globalOptions, remainingArgs: [] };
|
|
181
181
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
182
|
+
/** Parse `RAG_GROUPING`. */
|
|
183
|
+
export function parseGroupingMode(value) {
|
|
184
|
+
if (!value) {
|
|
185
|
+
return { value: undefined };
|
|
186
|
+
}
|
|
187
|
+
const normalized = value.toLowerCase().trim();
|
|
188
|
+
if (normalized === 'similar' || normalized === 'related') {
|
|
189
|
+
return { value: normalized };
|
|
190
|
+
}
|
|
191
|
+
const warning = `Invalid RAG_GROUPING value: "${value.slice(0, 100)}". Expected "similar" or "related". Ignoring.`;
|
|
192
|
+
return { value: undefined, warning };
|
|
193
|
+
}
|
|
194
|
+
/** Parse `RAG_MAX_DISTANCE`. */
|
|
195
|
+
export function parseMaxDistance(value) {
|
|
196
|
+
if (!value) {
|
|
197
|
+
return { value: undefined };
|
|
198
|
+
}
|
|
199
|
+
const parsed = Number.parseFloat(value);
|
|
200
|
+
if (Number.isNaN(parsed) || parsed <= 0 || !Number.isFinite(parsed)) {
|
|
201
|
+
const warning = `Invalid RAG_MAX_DISTANCE value: "${value.slice(0, 100)}". Expected positive number. Ignoring.`;
|
|
202
|
+
return { value: undefined, warning };
|
|
203
|
+
}
|
|
204
|
+
return { value: parsed };
|
|
205
|
+
}
|
|
206
|
+
/** Parse `RAG_MAX_FILES`. */
|
|
207
|
+
export function parseMaxFiles(value) {
|
|
208
|
+
if (!value) {
|
|
209
|
+
return { value: undefined };
|
|
210
|
+
}
|
|
211
|
+
const parsed = Number.parseInt(value, 10);
|
|
212
|
+
if (Number.isNaN(parsed) || parsed < 1) {
|
|
213
|
+
const warning = `Invalid RAG_MAX_FILES value: "${value.slice(0, 100)}". Expected positive integer (>= 1). Ignoring.`;
|
|
214
|
+
return { value: undefined, warning };
|
|
215
|
+
}
|
|
216
|
+
return { value: parsed };
|
|
217
|
+
}
|
|
218
|
+
/** Parse `RAG_HYBRID_WEIGHT`. */
|
|
219
|
+
export function parseHybridWeight(value) {
|
|
220
|
+
if (!value) {
|
|
221
|
+
return { value: undefined };
|
|
222
|
+
}
|
|
223
|
+
const parsed = Number.parseFloat(value);
|
|
224
|
+
if (Number.isNaN(parsed) || parsed < 0 || parsed > 1) {
|
|
225
|
+
const warning = `Invalid RAG_HYBRID_WEIGHT value: "${value.slice(0, 100)}". Expected 0.0-1.0. Using default (0.6).`;
|
|
226
|
+
return { value: undefined, warning };
|
|
227
|
+
}
|
|
228
|
+
return { value: parsed };
|
|
229
|
+
}
|
|
189
230
|
export function resolveGlobalConfig(options) {
|
|
190
231
|
const dbPath = options.dbPath ?? process.env['DB_PATH'] ?? GLOBAL_DEFAULTS.dbPath;
|
|
191
232
|
const cacheDir = options.cacheDir ?? process.env['CACHE_DIR'] ?? GLOBAL_DEFAULTS.cacheDir;
|
|
@@ -207,7 +248,30 @@ export function resolveGlobalConfig(options) {
|
|
|
207
248
|
console.error(modelNameError);
|
|
208
249
|
process.exit(1);
|
|
209
250
|
}
|
|
210
|
-
|
|
251
|
+
// stderr, so a JSON-output subcommand keeps stdout parseable.
|
|
252
|
+
const maxDistance = parseMaxDistance(process.env['RAG_MAX_DISTANCE']);
|
|
253
|
+
const grouping = parseGroupingMode(process.env['RAG_GROUPING']);
|
|
254
|
+
const maxFiles = parseMaxFiles(process.env['RAG_MAX_FILES']);
|
|
255
|
+
const hybridWeight = parseHybridWeight(process.env['RAG_HYBRID_WEIGHT']);
|
|
256
|
+
for (const { warning } of [maxDistance, grouping, maxFiles, hybridWeight]) {
|
|
257
|
+
if (warning !== undefined) {
|
|
258
|
+
console.error(`Warning: ${warning}`);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
const config = { dbPath, cacheDir, modelName };
|
|
262
|
+
if (maxDistance.value !== undefined) {
|
|
263
|
+
config.maxDistance = maxDistance.value;
|
|
264
|
+
}
|
|
265
|
+
if (grouping.value !== undefined) {
|
|
266
|
+
config.grouping = grouping.value;
|
|
267
|
+
}
|
|
268
|
+
if (maxFiles.value !== undefined) {
|
|
269
|
+
config.maxFiles = maxFiles.value;
|
|
270
|
+
}
|
|
271
|
+
if (hybridWeight.value !== undefined) {
|
|
272
|
+
config.hybridWeight = hybridWeight.value;
|
|
273
|
+
}
|
|
274
|
+
return config;
|
|
211
275
|
}
|
|
212
276
|
/**
|
|
213
277
|
* Resolve RAG_DEVICE. The value is passed through to transformers.js — no
|
package/dist/cli/options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/cli/options.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAE/D,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CA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AAI,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;AACzC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** An executable and the arguments configured alongside it. */
|
|
2
|
+
export interface RerankCommand {
|
|
3
|
+
/** Program to spawn. Must name a directly executable file, not a shim. */
|
|
4
|
+
executable: string;
|
|
5
|
+
/** Arguments configured by the operator, before the server's own flags. */
|
|
6
|
+
args: string[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Splits the configured command on whitespace. Quoting and other shell syntax
|
|
10
|
+
* are deliberately not interpreted: the command is spawned without a shell, so
|
|
11
|
+
* a quote this parser stripped would not mean what the operator expects.
|
|
12
|
+
*
|
|
13
|
+
* Returns undefined when the string carries no token.
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseRerankCommand(command: string): RerankCommand | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Appends the server's flags after the configured arguments. Each value is its
|
|
18
|
+
* own element, so query text is never read as command syntax.
|
|
19
|
+
*/
|
|
20
|
+
export declare function buildRerankArgv(command: RerankCommand, query: string, top: number): string[];
|
|
21
|
+
//# sourceMappingURL=command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/rerank/command.ts"],"names":[],"mappings":"AAEA,+DAA+D;AAC/D,MAAM,WAAW,aAAa;IAC5B,0EAA0E;IAC1E,UAAU,EAAE,MAAM,CAAA;IAClB,2EAA2E;IAC3E,IAAI,EAAE,MAAM,EAAE,CAAA;CACf;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAG7E;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAE5F"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Parsing of the configured rerank command into an argv vector.
|
|
2
|
+
/**
|
|
3
|
+
* Splits the configured command on whitespace. Quoting and other shell syntax
|
|
4
|
+
* are deliberately not interpreted: the command is spawned without a shell, so
|
|
5
|
+
* a quote this parser stripped would not mean what the operator expects.
|
|
6
|
+
*
|
|
7
|
+
* Returns undefined when the string carries no token.
|
|
8
|
+
*/
|
|
9
|
+
export function parseRerankCommand(command) {
|
|
10
|
+
const [executable, ...args] = command.split(/\s+/).filter((token) => token.length > 0);
|
|
11
|
+
return executable === undefined ? undefined : { executable, args };
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Appends the server's flags after the configured arguments. Each value is its
|
|
15
|
+
* own element, so query text is never read as command syntax.
|
|
16
|
+
*/
|
|
17
|
+
export function buildRerankArgv(command, query, top) {
|
|
18
|
+
return [...command.args, '--query', query, '--top', String(top)];
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/rerank/command.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAUhE;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAe;IAChD,MAAM,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IACtF,OAAO,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAA;AACpE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,OAAsB,EAAE,KAAa,EAAE,GAAW;IAChF,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;AAClE,CAAC"}
|