Integrate Meilisearch + Redis deeply for cache, locks, searchable decisions/insights, and health telemetry
This commit is contained in:
7
app.py
7
app.py
@@ -6,7 +6,7 @@ from datetime import datetime, timedelta
|
||||
import threading
|
||||
from db import init_db, SessionLocal, BotDecision, TradeExecution, CuratedInsight
|
||||
from bot import start_scheduler, run_cycle, curate_cycle
|
||||
from services import account_snapshot, qdrant_memory_health
|
||||
from services import account_snapshot, qdrant_memory_health, meili_health, meili_search
|
||||
|
||||
app = FastAPI(title="alpaca-llm-bot-v1")
|
||||
templates = Jinja2Templates(directory="templates")
|
||||
@@ -34,6 +34,10 @@ def curate_now():
|
||||
def api_account():
|
||||
return JSONResponse(account_snapshot())
|
||||
|
||||
@app.get('/api/search')
|
||||
def api_search(q: str, index: str = 'decisions', limit: int = 20):
|
||||
return JSONResponse(meili_search(index, q, limit))
|
||||
|
||||
@app.get("/api/metrics")
|
||||
def api_metrics(hours: int = 72):
|
||||
db = SessionLocal()
|
||||
@@ -95,6 +99,7 @@ def api_metrics(hours: int = 72):
|
||||
},
|
||||
"leaderboard": leaderboard,
|
||||
"qdrant": qdrant_memory_health(),
|
||||
"meili": meili_health(),
|
||||
}
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
Reference in New Issue
Block a user