File size: 1,511 Bytes
76398fd
 
 
 
0c78e88
c60f0be
76398fd
94ea10a
c60f0be
 
 
 
 
 
 
 
 
 
 
 
 
 
94ea10a
 
 
 
 
 
 
0c78e88
 
 
 
 
 
 
 
0ddd1d3
 
 
2e3b72e
 
 
 
94ea10a
 
0c78e88
76398fd
94ea10a
0c78e88
 
94ea10a
 
76398fd
94ea10a
0ddd1d3
76398fd
94ea10a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""
Application entry point for the Joule Dynamics Intelligence API.
"""

import os
import uvicorn
from fastapi import FastAPI, APIRouter
from fastapi.middleware.cors import CORSMiddleware
from dotenv import load_dotenv

load_dotenv()

from langfuse import get_client
from openinference.instrumentation.groq import GroqInstrumentor

langfuse = get_client()
if not langfuse.auth_check():
    print("WARNING: Langfuse auth failed - check your keys ✋")

GroqInstrumentor().instrument()

from services.observability import setup_logger
logger = setup_logger(__name__)

app = FastAPI(
    title="Joule Dynamics Intelligence API",
    description="Real Estate Rate Monitor + RAG Customer Support",
    version="1.0.0",
)

app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_methods=["POST", "GET"],
    allow_headers=["*"],
)

import unified_ingest
unified_ingest.ensure_ingested()

from services.market_registry import market_registry
market_registry.refresh()
logger.info(f"Market registry initialized: {market_registry.get_markets()}")

from routes import v1_router
app.include_router(v1_router)

from routes.v1.rag import router as _rag_router, rag_chat, RagChatRequest
_compat = APIRouter(tags=["Deprecated — use /api/v1/rag/chat"])


@_compat.post("/api/rag/chat", deprecated=True, include_in_schema=False)
def rag_chat_compat(req: RagChatRequest):
    """Deprecated: forwards to /api/v1/rag/chat for backwards compatibility."""
    return rag_chat(req)


app.include_router(_compat)