Update app.py
Browse files
app.py
CHANGED
|
@@ -52,7 +52,7 @@ from typing import Any, Awaitable, Callable, Deque, Dict, List, Optional, Tuple
|
|
| 52 |
import httpx
|
| 53 |
from fastapi import (Body, Depends, FastAPI, Header, HTTPException, Query,
|
| 54 |
WebSocket, WebSocketDisconnect)
|
| 55 |
-
from pydantic import BaseModel, Field
|
| 56 |
|
| 57 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 58 |
# CONFIG
|
|
@@ -101,6 +101,7 @@ class LLMRequest(BaseModel):
|
|
| 101 |
"""Public /llm request β driver-aligned. Extra fields are accepted but
|
| 102 |
optional so that internal callers (Forge) can pass system + routing hints
|
| 103 |
without breaking the driver contract."""
|
|
|
|
| 104 |
prompt: str
|
| 105 |
model: Optional[str] = None
|
| 106 |
temperature: float = 0.7
|
|
@@ -141,6 +142,7 @@ class SimilarRequest(BaseModel):
|
|
| 141 |
|
| 142 |
|
| 143 |
class ScoreRequest(BaseModel):
|
|
|
|
| 144 |
text: str
|
| 145 |
dimensions: List[str]
|
| 146 |
model_class: str = "balanced"
|
|
@@ -785,6 +787,12 @@ async def _shutdown() -> None:
|
|
| 785 |
_HTTP = None
|
| 786 |
|
| 787 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 788 |
@app.get("/healthz")
|
| 789 |
async def healthz() -> Dict[str, Any]:
|
| 790 |
return {
|
|
@@ -804,7 +812,6 @@ async def healthz() -> Dict[str, Any]:
|
|
| 804 |
@app.post("/llm", dependencies=[Depends(require_token)])
|
| 805 |
async def http_llm(req: LLMRequest) -> Dict[str, Any]:
|
| 806 |
res = await llm(req)
|
| 807 |
-
# contract returns {text} β we return text plus metadata for radar consumers
|
| 808 |
return res.dict()
|
| 809 |
|
| 810 |
|
|
@@ -824,6 +831,13 @@ async def http_similar(req: SimilarRequest) -> Dict[str, Any]:
|
|
| 824 |
return {"hits": hits}
|
| 825 |
|
| 826 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 827 |
@app.post("/score", dependencies=[Depends(require_token)])
|
| 828 |
async def http_score(req: ScoreRequest) -> Dict[str, Any]:
|
| 829 |
return await score_text(req)
|
|
@@ -866,7 +880,6 @@ async def ws_radar(ws: WebSocket) -> None:
|
|
| 866 |
radar.detach(ws)
|
| 867 |
|
| 868 |
|
| 869 |
-
# ββ back-compat aliases βββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 870 |
@app.get("/health")
|
| 871 |
async def http_health_alias() -> Dict[str, Any]:
|
| 872 |
return await healthz()
|
|
|
|
| 52 |
import httpx
|
| 53 |
from fastapi import (Body, Depends, FastAPI, Header, HTTPException, Query,
|
| 54 |
WebSocket, WebSocketDisconnect)
|
| 55 |
+
from pydantic import BaseModel, ConfigDict, Field
|
| 56 |
|
| 57 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 58 |
# CONFIG
|
|
|
|
| 101 |
"""Public /llm request β driver-aligned. Extra fields are accepted but
|
| 102 |
optional so that internal callers (Forge) can pass system + routing hints
|
| 103 |
without breaking the driver contract."""
|
| 104 |
+
model_config = ConfigDict(protected_namespaces=())
|
| 105 |
prompt: str
|
| 106 |
model: Optional[str] = None
|
| 107 |
temperature: float = 0.7
|
|
|
|
| 142 |
|
| 143 |
|
| 144 |
class ScoreRequest(BaseModel):
|
| 145 |
+
model_config = ConfigDict(protected_namespaces=())
|
| 146 |
text: str
|
| 147 |
dimensions: List[str]
|
| 148 |
model_class: str = "balanced"
|
|
|
|
| 787 |
_HTTP = None
|
| 788 |
|
| 789 |
|
| 790 |
+
@app.get("/")
|
| 791 |
+
async def root() -> Dict[str, Any]:
|
| 792 |
+
"""Root sinkhole β proof-of-life for OMNI's Cybernetic God Cortex."""
|
| 793 |
+
return {"status": "OMNI Cortex Online", "state": "Absolute Autonomy"}
|
| 794 |
+
|
| 795 |
+
|
| 796 |
@app.get("/healthz")
|
| 797 |
async def healthz() -> Dict[str, Any]:
|
| 798 |
return {
|
|
|
|
| 812 |
@app.post("/llm", dependencies=[Depends(require_token)])
|
| 813 |
async def http_llm(req: LLMRequest) -> Dict[str, Any]:
|
| 814 |
res = await llm(req)
|
|
|
|
| 815 |
return res.dict()
|
| 816 |
|
| 817 |
|
|
|
|
| 831 |
return {"hits": hits}
|
| 832 |
|
| 833 |
|
| 834 |
+
@app.post("/search", dependencies=[Depends(require_token)])
|
| 835 |
+
async def http_search(req: SimilarRequest) -> Dict[str, Any]:
|
| 836 |
+
"""Akashic Index alias of /similar β used by Forge for retrieval-augmented
|
| 837 |
+
template injection before any LLM synthesis."""
|
| 838 |
+
return await http_similar(req)
|
| 839 |
+
|
| 840 |
+
|
| 841 |
@app.post("/score", dependencies=[Depends(require_token)])
|
| 842 |
async def http_score(req: ScoreRequest) -> Dict[str, Any]:
|
| 843 |
return await score_text(req)
|
|
|
|
| 880 |
radar.detach(ws)
|
| 881 |
|
| 882 |
|
|
|
|
| 883 |
@app.get("/health")
|
| 884 |
async def http_health_alias() -> Dict[str, Any]:
|
| 885 |
return await healthz()
|