Spaces:
Sleeping
Sleeping
Update server.py
Browse files
server.py
CHANGED
|
@@ -41,18 +41,7 @@ Settings.embed_model = embed_model
|
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
port = int(os.getenv("PORT", 7860))
|
| 48 |
-
mcp = FastMCP("OnBase", port=port)
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
DOCUMENTS_BASE_PATH = "./"
|
| 57 |
SOURCES = {
|
| 58 |
"oms": "oms/", # Esta será la carpeta base que contiene todos los subíndices
|
|
@@ -85,20 +74,31 @@ for source, rel_path in SOURCES.items():
|
|
| 85 |
print(f"Error cargando índice en {root}: {str(e)}")
|
| 86 |
continue
|
| 87 |
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
def retrieve_docs(query: str, fuente: str = 'oms', top_k: int = 3) -> dict:
|
| 96 |
"""
|
|
|
|
|
|
|
| 97 |
Parameters:
|
| 98 |
query: Search query (required).
|
| 99 |
fuente: Source name (default: 'oms').
|
| 100 |
top_k: Number of results to return (default: 3).
|
| 101 |
"""
|
|
|
|
|
|
|
|
|
|
| 102 |
if fuente not in indices:
|
| 103 |
available = [k for k in indices.keys() if k.startswith("oms_")] if fuente.startswith("oms") else list(indices.keys())
|
| 104 |
return {"error": f"Fuente '{fuente}' no disponible. Opciones: {available}"}
|
|
|
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
+
# Configuración inicial (esto probablemente estaría en otro módulo)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
DOCUMENTS_BASE_PATH = "./"
|
| 46 |
SOURCES = {
|
| 47 |
"oms": "oms/", # Esta será la carpeta base que contiene todos los subíndices
|
|
|
|
| 74 |
print(f"Error cargando índice en {root}: {str(e)}")
|
| 75 |
continue
|
| 76 |
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
port = int(os.getenv("PORT", 7860))
|
| 85 |
+
mcp = FastMCP("OnBase", port=port)
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
@mcp.tool()
|
| 90 |
def retrieve_docs(query: str, fuente: str = 'oms', top_k: int = 3) -> dict:
|
| 91 |
"""
|
| 92 |
+
Retrieve documents from different regulations using semantic search.
|
| 93 |
+
|
| 94 |
Parameters:
|
| 95 |
query: Search query (required).
|
| 96 |
fuente: Source name (default: 'oms').
|
| 97 |
top_k: Number of results to return (default: 3).
|
| 98 |
"""
|
| 99 |
+
if not query:
|
| 100 |
+
return {"error": "Query parameter is required"}
|
| 101 |
+
|
| 102 |
if fuente not in indices:
|
| 103 |
available = [k for k in indices.keys() if k.startswith("oms_")] if fuente.startswith("oms") else list(indices.keys())
|
| 104 |
return {"error": f"Fuente '{fuente}' no disponible. Opciones: {available}"}
|