geronimo-pericoli commited on
Commit
4ee4e2e
·
verified ·
1 Parent(s): 7f73e5e

Update server.py

Browse files
Files changed (1) hide show
  1. server.py +6 -5
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 (se ejecuta una vez al iniciar el servidor)
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
- indices[source] = load_index_from_storage(storage_context, index_id=source)
 
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