Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
|
@@ -7,7 +7,7 @@ from numpy.linalg import norm
|
|
| 7 |
from scipy.linalg import expm
|
| 8 |
|
| 9 |
from fastapi import FastAPI
|
| 10 |
-
from pydantic import BaseModel
|
| 11 |
|
| 12 |
from sentence_transformers import SentenceTransformer
|
| 13 |
from huggingface_hub import hf_hub_download
|
|
@@ -32,12 +32,11 @@ except Exception as e:
|
|
| 32 |
print("🔄 [Startup] Descargando meta-logit desde HF Hub...", flush=True)
|
| 33 |
try:
|
| 34 |
meta_logit_path = hf_hub_download(
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
)
|
| 39 |
-
|
| 40 |
-
print("🔄 [Startup] Cargando modelo meta-logit v...", flush=True)
|
| 41 |
meta_logit = joblib.load(meta_logit_path)
|
| 42 |
print("✅ [Startup] Meta-logit cargado.", flush=True)
|
| 43 |
except Exception as e:
|
|
@@ -283,30 +282,34 @@ class EvaluateRequest(BaseModel):
|
|
| 283 |
answer: str
|
| 284 |
model_label: Optional[str] = None
|
| 285 |
|
|
|
|
| 286 |
class EvaluateResponse(BaseModel):
|
| 287 |
scores: Dict[str, float]
|
| 288 |
features: Dict[str, float]
|
| 289 |
sim_summary: Dict[str, Any]
|
| 290 |
|
|
|
|
| 291 |
app = FastAPI(
|
| 292 |
title="Savant RRF Φ12.0 API",
|
| 293 |
description="Dirac-Resonant conceptual quality layer for LLM-generated text.",
|
| 294 |
version="1.0.0",
|
| 295 |
)
|
| 296 |
|
|
|
|
| 297 |
@app.get("/")
|
| 298 |
def root():
|
| 299 |
return {"message": "Savant RRF Φ12.0 API running", "docs": "/docs"}
|
| 300 |
|
|
|
|
| 301 |
@app.get("/health")
|
| 302 |
def health():
|
| 303 |
return {"status": "ok"}
|
| 304 |
|
|
|
|
| 305 |
@app.post("/evaluate", response_model=EvaluateResponse)
|
| 306 |
def evaluate(req: EvaluateRequest):
|
| 307 |
scores, feats = compute_scores_srff_crff_ephi(req.prompt, req.answer)
|
| 308 |
|
| 309 |
-
# pequeño resumen adicional de simulación fresca (opcional)
|
| 310 |
H = build_dirac_hamiltonian(
|
| 311 |
m=0.25, v=1.0, sigma=0.618,
|
| 312 |
alpha_log=0.10, q=1.0,
|
|
|
|
| 7 |
from scipy.linalg import expm
|
| 8 |
|
| 9 |
from fastapi import FastAPI
|
| 10 |
+
from pydantic import BaseModel
|
| 11 |
|
| 12 |
from sentence_transformers import SentenceTransformer
|
| 13 |
from huggingface_hub import hf_hub_download
|
|
|
|
| 32 |
print("🔄 [Startup] Descargando meta-logit desde HF Hub...", flush=True)
|
| 33 |
try:
|
| 34 |
meta_logit_path = hf_hub_download(
|
| 35 |
+
repo_id=META_LOGIT_REPO,
|
| 36 |
+
filename=META_LOGIT_FILENAME,
|
| 37 |
+
token=os.environ.get("HF_TOKEN"), # si el repo es público, puede ser None
|
| 38 |
+
)
|
| 39 |
+
print("🔄 [Startup] Cargando modelo meta-logit...", flush=True)
|
|
|
|
| 40 |
meta_logit = joblib.load(meta_logit_path)
|
| 41 |
print("✅ [Startup] Meta-logit cargado.", flush=True)
|
| 42 |
except Exception as e:
|
|
|
|
| 282 |
answer: str
|
| 283 |
model_label: Optional[str] = None
|
| 284 |
|
| 285 |
+
|
| 286 |
class EvaluateResponse(BaseModel):
|
| 287 |
scores: Dict[str, float]
|
| 288 |
features: Dict[str, float]
|
| 289 |
sim_summary: Dict[str, Any]
|
| 290 |
|
| 291 |
+
|
| 292 |
app = FastAPI(
|
| 293 |
title="Savant RRF Φ12.0 API",
|
| 294 |
description="Dirac-Resonant conceptual quality layer for LLM-generated text.",
|
| 295 |
version="1.0.0",
|
| 296 |
)
|
| 297 |
|
| 298 |
+
|
| 299 |
@app.get("/")
|
| 300 |
def root():
|
| 301 |
return {"message": "Savant RRF Φ12.0 API running", "docs": "/docs"}
|
| 302 |
|
| 303 |
+
|
| 304 |
@app.get("/health")
|
| 305 |
def health():
|
| 306 |
return {"status": "ok"}
|
| 307 |
|
| 308 |
+
|
| 309 |
@app.post("/evaluate", response_model=EvaluateResponse)
|
| 310 |
def evaluate(req: EvaluateRequest):
|
| 311 |
scores, feats = compute_scores_srff_crff_ephi(req.prompt, req.answer)
|
| 312 |
|
|
|
|
| 313 |
H = build_dirac_hamiltonian(
|
| 314 |
m=0.25, v=1.0, sigma=0.618,
|
| 315 |
alpha_log=0.10, q=1.0,
|