Spaces:
Sleeping
Sleeping
Update server.py
Browse files
server.py
CHANGED
|
@@ -1,6 +1,9 @@
|
|
| 1 |
from mcp.server.fastmcp import FastMCP
|
| 2 |
from datetime import datetime
|
| 3 |
-
from llama_index import
|
|
|
|
|
|
|
|
|
|
| 4 |
from typing import Dict, Optional
|
| 5 |
import json
|
| 6 |
import os
|
|
@@ -28,8 +31,9 @@ indices: Dict[str, VectorStoreIndex] = {}
|
|
| 28 |
for source, rel_path in SOURCES.items():
|
| 29 |
full_path = os.path.join(DOCUMENTS_BASE_PATH, rel_path)
|
| 30 |
if os.path.exists(full_path):
|
| 31 |
-
|
| 32 |
-
indices[source] =
|
|
|
|
| 33 |
|
| 34 |
# Recurso dinámico para búsqueda
|
| 35 |
@mcp.resource(
|
|
|
|
| 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,
|
| 6 |
+
)
|
| 7 |
from typing import Dict, Optional
|
| 8 |
import json
|
| 9 |
import os
|
|
|
|
| 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
|
| 39 |
@mcp.resource(
|