Spaces:
Sleeping
Sleeping
Update server.py
Browse files
server.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
from mcp.server.fastmcp import FastMCP
|
| 2 |
from datetime import datetime
|
|
|
|
| 3 |
from llama_index.core import (
|
| 4 |
StorageContext,
|
| 5 |
load_index_from_storage,
|
|
@@ -18,21 +19,21 @@ mcp = FastMCP("OnBase", port=port)
|
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
-
# Rutas a los documentos por fuente
|
| 22 |
DOCUMENTS_BASE_PATH = "./"
|
| 23 |
SOURCES = {
|
| 24 |
"oms": "oms/",
|
| 25 |
-
#"other": "other/",
|
| 26 |
-
#"other2": "other2/"
|
| 27 |
}
|
| 28 |
|
| 29 |
-
# Cargar índices
|
| 30 |
indices: Dict[str, VectorStoreIndex] = {}
|
| 31 |
for source, rel_path in SOURCES.items():
|
| 32 |
full_path = os.path.join(DOCUMENTS_BASE_PATH, rel_path)
|
| 33 |
if os.path.exists(full_path):
|
| 34 |
storage_context = StorageContext.from_defaults(persist_dir=full_path)
|
| 35 |
-
|
|
|
|
| 36 |
|
| 37 |
|
| 38 |
# Recurso dinámico para búsqueda
|
|
|
|
| 1 |
from mcp.server.fastmcp import FastMCP
|
| 2 |
from datetime import datetime
|
| 3 |
+
from llama_index.core import VectorStoreIndex
|
| 4 |
from llama_index.core import (
|
| 5 |
StorageContext,
|
| 6 |
load_index_from_storage,
|
|
|
|
| 19 |
|
| 20 |
|
| 21 |
|
|
|
|
| 22 |
DOCUMENTS_BASE_PATH = "./"
|
| 23 |
SOURCES = {
|
| 24 |
"oms": "oms/",
|
| 25 |
+
# "other": "other/",
|
| 26 |
+
# "other2": "other2/"
|
| 27 |
}
|
| 28 |
|
| 29 |
+
# Cargar índices
|
| 30 |
indices: Dict[str, VectorStoreIndex] = {}
|
| 31 |
for source, rel_path in SOURCES.items():
|
| 32 |
full_path = os.path.join(DOCUMENTS_BASE_PATH, rel_path)
|
| 33 |
if os.path.exists(full_path):
|
| 34 |
storage_context = StorageContext.from_defaults(persist_dir=full_path)
|
| 35 |
+
index = load_index_from_storage(storage_context, index_id="vector_index")
|
| 36 |
+
indices[source] = index
|
| 37 |
|
| 38 |
|
| 39 |
# Recurso dinámico para búsqueda
|